Skip to content

Commit fce115d

Browse files
authored
Merge pull request #747 from crazywhalecc/feat/h3
fix ngtcp2 with openssl on glibc <= 2.17, macos still pending
2 parents f75ab9f + 301f2d8 commit fce115d

File tree

8 files changed

+34
-22
lines changed

8 files changed

+34
-22
lines changed

config/lib.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -635,9 +635,6 @@
635635
],
636636
"lib-depends": [
637637
"openssl"
638-
],
639-
"lib-suggests": [
640-
"ngtcp2"
641638
]
642639
},
643640
"ngtcp2": {
@@ -655,6 +652,10 @@
655652
],
656653
"lib-depends": [
657654
"openssl"
655+
],
656+
"lib-suggests": [
657+
"nghttp3",
658+
"brotli"
658659
]
659660
},
660661
"onig": {

src/SPC/builder/linux/LinuxBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function makeAutoconfArgs(string $name, array $libSpecs): string
8181
foreach ($libSpecs as $libName => $arr) {
8282
$lib = $this->getLib($libName);
8383
if ($lib === null && str_starts_with($libName, 'lib')) {
84-
$lib = $this->getExt(substr($libName, 3));
84+
$lib = $this->getLib(substr($libName, 3));
8585
}
8686

8787
$arr = $arr ?? [];

src/SPC/builder/linux/library/openssl.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,4 +92,13 @@ public function build(): void
9292
FileSystem::replaceFileRegex(BUILD_LIB_PATH . '/pkgconfig/libcrypto.pc', '/Libs.private:.*/m', 'Libs.private: ${libdir}/libz.a');
9393
FileSystem::replaceFileRegex(BUILD_LIB_PATH . '/cmake/OpenSSL/OpenSSLConfig.cmake', '/set\(OPENSSL_LIBCRYPTO_DEPENDENCIES .*\)/m', 'set(OPENSSL_LIBCRYPTO_DEPENDENCIES "${OPENSSL_LIBRARY_DIR}/libz.a")');
9494
}
95+
96+
public function getStaticLibFiles(string $style = 'autoconf', bool $recursive = true): string
97+
{
98+
$libFiles = parent::getStaticLibFiles($style, $recursive);
99+
if (!str_contains('-ldl -lpthread', $libFiles)) {
100+
$libFiles .= ' -ldl -lpthread';
101+
}
102+
return $libFiles;
103+
}
95104
}

src/SPC/builder/macos/MacOSBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function makeAutoconfArgs(string $name, array $lib_specs): string
5656
foreach ($lib_specs as $libName => $arr) {
5757
$lib = $this->getLib($libName);
5858
if ($lib === null && str_starts_with($libName, 'lib')) {
59-
$lib = $this->getExt(substr($libName, 3));
59+
$lib = $this->getLib(substr($libName, 3));
6060
}
6161

6262
$arr = $arr ?? [];

src/SPC/builder/unix/library/nghttp2.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ protected function build(): void
3131
'jemalloc' => null,
3232
'systemd' => null,
3333
]);
34+
if ($brotli = $this->builder->getLib('brotli')) {
35+
/* @phpstan-ignore-next-line */
36+
$args .= ' --with-libbrotlidec=yes LIBBROTLIDEC_CFLAGS="-I' . BUILD_ROOT_PATH . '/include" LIBBROTLIDEC_LIBS="' . $brotli->getStaticLibFiles() . '"';
37+
/* @phpstan-ignore-next-line */
38+
$args .= ' --with-libbrotlienc=yes LIBBROTLIENC_CFLAGS="-I' . BUILD_ROOT_PATH . '/include" LIBBROTLIENC_LIBS="' . $brotli->getStaticLibFiles() . '"';
39+
}
3440

3541
[,,$destdir] = SEPARATED_PATH;
3642

src/SPC/builder/unix/library/nghttp3.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,15 @@
66

77
use SPC\exception\FileSystemException;
88
use SPC\exception\RuntimeException;
9-
use SPC\exception\WrongUsageException;
109

1110
trait nghttp3
1211
{
1312
/**
1413
* @throws FileSystemException
1514
* @throws RuntimeException
16-
* @throws WrongUsageException
1715
*/
1816
protected function build(): void
1917
{
20-
$args = $this->builder->makeAutoconfArgs(static::NAME, [
21-
'zlib' => null,
22-
'openssl' => null,
23-
]);
24-
2518
shell()->cd($this->source_dir)
2619
->setEnv([
2720
'CFLAGS' => $this->getLibExtraCFlags(),
@@ -34,7 +27,6 @@ protected function build(): void
3427
'--disable-shared ' .
3528
'--with-pic ' .
3629
'--enable-lib-only ' .
37-
$args . ' ' .
3830
'--prefix='
3931
)
4032
->execWithEnv('make clean')

src/SPC/builder/unix/library/ngtcp2.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@ trait ngtcp2
1818
protected function build(): void
1919
{
2020
$args = $this->builder->makeAutoconfArgs(static::NAME, [
21-
'zlib' => null,
2221
'openssl' => null,
23-
'libxml2' => null,
2422
'libev' => null,
2523
'jemalloc' => null,
24+
'libnghttp3' => null,
2625
]);
26+
if ($brotli = $this->builder->getLib('brotli')) {
27+
/* @phpstan-ignore-next-line */
28+
$args .= ' --with-libbrotlidec=yes LIBBROTLIDEC_CFLAGS="-I' . BUILD_ROOT_PATH . '/include" LIBBROTLIDEC_LIBS="' . $brotli->getStaticLibFiles() . '"';
29+
/* @phpstan-ignore-next-line */
30+
$args .= ' --with-libbrotlienc=yes LIBBROTLIENC_CFLAGS="-I' . BUILD_ROOT_PATH . '/include" LIBBROTLIENC_LIBS="' . $brotli->getStaticLibFiles() . '"';
31+
}
2732

2833
shell()->cd($this->source_dir)
2934
->setEnv([
@@ -43,7 +48,6 @@ protected function build(): void
4348
->execWithEnv('make clean')
4449
->execWithEnv("make -j{$this->builder->concurrency}")
4550
->execWithEnv('make install DESTDIR=' . BUILD_ROOT_PATH);
46-
$this->patchPkgconfPrefix(['libngtcp2.pc']);
47-
$this->patchPkgconfPrefix(['libngtcp2_crypto_ossl.pc']);
51+
$this->patchPkgconfPrefix(['libngtcp2.pc', 'libngtcp2_crypto_ossl.pc']);
4852
}
4953
}

src/globals/test-extensions.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
// test os (macos-13, macos-14, macos-15, ubuntu-latest, windows-latest are available)
2323
$test_os = [
2424
'macos-13',
25-
'macos-14',
25+
// 'macos-14',
2626
'macos-15',
2727
'ubuntu-latest',
2828
'ubuntu-22.04',
29-
'ubuntu-24.04',
29+
// 'ubuntu-24.04',
3030
'ubuntu-22.04-arm',
31-
'ubuntu-24.04-arm',
31+
// 'ubuntu-24.04-arm',
3232
// 'windows-latest',
3333
];
3434

@@ -45,7 +45,7 @@
4545

4646
// If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`).
4747
$extensions = match (PHP_OS_FAMILY) {
48-
'Linux', 'Darwin' => 'lz4',
48+
'Linux', 'Darwin' => 'openssl,curl',
4949
'Windows' => 'xlswriter,openssl',
5050
};
5151

@@ -57,7 +57,7 @@
5757

5858
// If you want to test lib-suggests feature with extension, add them below (comma separated, example `libwebp,libavif`).
5959
$with_libs = match (PHP_OS_FAMILY) {
60-
'Linux', 'Darwin' => '',
60+
'Linux', 'Darwin' => 'nghttp2,nghttp3,ngtcp2',
6161
'Windows' => '',
6262
};
6363

0 commit comments

Comments
 (0)