Skip to content

Commit 83db186

Browse files
committed
Fix curl static build for Windows
1 parent 9af3b74 commit 83db186

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

config/env.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ PHP_SDK_PATH="${WORKING_DIR}\php-sdk-binary-tools"
6363
UPX_EXEC="${PKG_ROOT_PATH}\bin\upx.exe"
6464
; phpmicro patches, for more info, see: https://github.com/easysoft/phpmicro/tree/master/patches
6565
SPC_MICRO_PATCHES=static_extensions_win32,cli_checks,disable_huge_page,vcruntime140,win32,zend_stream,cli_static
66+
; Windows static linking system libs
67+
SPC_WINDOWS_EXEC_LIBS="ws2_32.lib shell32.lib"
6668

6769
[linux]
6870
; Linux can use different build toolchain, but the toolchain can not be changed in this file:

src/SPC/builder/extension/curl.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ public function patchBeforeConfigure(): bool
5757
return true;
5858
}
5959

60+
public function patchBeforeMake(): bool
61+
{
62+
$extra_libs = getenv('SPC_WINDOWS_EXEC_LIBS');
63+
if (!str_contains($extra_libs, 'secur32.lib')) {
64+
$extra_libs .= ' secur32.lib';
65+
putenv('SPC_WINDOWS_EXEC_LIBS=' . $extra_libs);
66+
return true;
67+
}
68+
return false;
69+
}
70+
6071
public function patchBeforeSharedConfigure(): bool
6172
{
6273
$file = $this->source_dir . '/config.m4';

src/SPC/builder/windows/WindowsBuilder.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,10 @@ public function buildCli(): void
162162
{
163163
SourcePatcher::patchWindowsCLITarget();
164164

165+
$extra_libs = getenv('SPC_WINDOWS_EXEC_LIBS') ?: '';
166+
165167
// add nmake wrapper
166-
FileSystem::writeFile(SOURCE_PATH . '\php-src\nmake_cli_wrapper.bat', "nmake /nologo LIBS_CLI=\"{$this->getOption('extra-libs')} ws2_32.lib shell32.lib\" EXTRA_LD_FLAGS_PROGRAM= %*");
168+
FileSystem::writeFile(SOURCE_PATH . '\php-src\nmake_cli_wrapper.bat', "nmake /nologo LIBS_CLI=\"{$extra_libs}\" EXTRA_LD_FLAGS_PROGRAM= %*");
167169

168170
cmd()->cd(SOURCE_PATH . '\php-src')->exec("{$this->sdk_prefix} nmake_cli_wrapper.bat --task-args php.exe");
169171

@@ -197,9 +199,11 @@ public function buildMicro(): void
197199
}
198200
FileSystem::writeFile(SOURCE_PATH . '\php-src\Makefile', $makefile);
199201

202+
$extra_libs = getenv('SPC_WINDOWS_EXEC_LIBS') ?: '';
203+
200204
// add nmake wrapper
201205
$fake_cli = $this->getOption('with-micro-fake-cli', false) ? ' /DPHP_MICRO_FAKE_CLI" ' : '';
202-
$wrapper = "nmake /nologo LIBS_MICRO=\"{$this->getOption('extra-libs')} ws2_32.lib shell32.lib\" CFLAGS_MICRO=\"/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1{$fake_cli}\" %*";
206+
$wrapper = "nmake /nologo LIBS_MICRO=\"{$extra_libs}\" CFLAGS_MICRO=\"/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1{$fake_cli}\" %*";
203207
FileSystem::writeFile(SOURCE_PATH . '\php-src\nmake_micro_wrapper.bat', $wrapper);
204208

205209
// phar patch for micro

src/SPC/builder/windows/library/curl.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ protected function build(): void
3737
'-DBUILD_EXAMPLES=OFF ' . // disable examples
3838
'-DUSE_LIBIDN2=OFF ' . // disable libidn2
3939
'-DCURL_USE_LIBPSL=OFF ' . // disable libpsl
40+
'-DUSE_WINDOWS_SSPI=ON ' . // use Schannel instead of OpenSSL
4041
'-DCURL_USE_SCHANNEL=ON ' . // use Schannel instead of OpenSSL
4142
'-DCURL_USE_OPENSSL=OFF ' . // disable openssl due to certificate issue
4243
'-DCURL_ENABLE_SSL=ON ' .

0 commit comments

Comments
 (0)