mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-15 12:55:36 +08:00
fix(php): pass /FORCE:MULTIPLE when linking php-cgi.exe and micro.sfx
- php.exe already links with /FORCE:MULTIPLE for extension-bundled duplicate symbols, cgi and micro did not - imagick's MagickCore defines gettimeofday, also defined in php's time.obj, and both links failed with LNK2005
This commit is contained in:
@@ -201,7 +201,10 @@ trait windows
|
|||||||
throw new PatchException('Windows Makefile patching for php-cgi.exe target', 'Cannot patch windows CGI Makefile, Makefile does not contain "$(BUILD_DIR)\php-cgi.exe:" line');
|
throw new PatchException('Windows Makefile patching for php-cgi.exe target', 'Cannot patch windows CGI Makefile, Makefile does not contain "$(BUILD_DIR)\php-cgi.exe:" line');
|
||||||
}
|
}
|
||||||
$lines[$line_num] = '$(BUILD_DIR)\php-cgi.exe: $(DEPS_CGI) $(CGI_GLOBAL_OBJS) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(BUILD_DIR)\php-cgi.exe.res $(BUILD_DIR)\php-cgi.exe.manifest';
|
$lines[$line_num] = '$(BUILD_DIR)\php-cgi.exe: $(DEPS_CGI) $(CGI_GLOBAL_OBJS) $(PHP_GLOBAL_OBJS) $(STATIC_EXT_OBJS) $(ASM_OBJS) $(BUILD_DIR)\php-cgi.exe.res $(BUILD_DIR)\php-cgi.exe.manifest';
|
||||||
$lines[$line_num + 1] = "\t" . '@"$(LINK)" /nologo $(PHP_GLOBAL_OBJS_RESP) $(CGI_GLOBAL_OBJS_RESP) $(STATIC_EXT_OBJS_RESP) $(STATIC_EXT_LIBS) $(ASM_OBJS) $(LIBS) $(LIBS_CGI) $(BUILD_DIR)\php-cgi.exe.res /out:$(BUILD_DIR)\php-cgi.exe $(LDFLAGS) $(LDFLAGS_CGI) /ltcg /nodefaultlib:msvcrt /nodefaultlib:msvcrtd /ignore:4286';
|
// /FORCE:MULTIPLE /ignore:4006: same reason as the php.exe target above. Without it the
|
||||||
|
// CGI link fails with LNK2005 (e.g. imagick's MagickCore defines gettimeofday, which
|
||||||
|
// php's time.obj also defines).
|
||||||
|
$lines[$line_num + 1] = "\t" . '@"$(LINK)" /nologo $(PHP_GLOBAL_OBJS_RESP) $(CGI_GLOBAL_OBJS_RESP) $(STATIC_EXT_OBJS_RESP) $(STATIC_EXT_LIBS) $(ASM_OBJS) $(LIBS) $(LIBS_CGI) $(BUILD_DIR)\php-cgi.exe.res /out:$(BUILD_DIR)\php-cgi.exe $(LDFLAGS) $(LDFLAGS_CGI) /ltcg /nodefaultlib:msvcrt /nodefaultlib:msvcrtd /ignore:4286 /FORCE:MULTIPLE /ignore:4006';
|
||||||
FileSystem::writeFile("{$package->getSourceDir()}\\Makefile", implode("\r\n", $lines));
|
FileSystem::writeFile("{$package->getSourceDir()}\\Makefile", implode("\r\n", $lines));
|
||||||
|
|
||||||
// Patch cgi-static, comment ZEND_TSRMLS_CACHE_DEFINE()
|
// Patch cgi-static, comment ZEND_TSRMLS_CACHE_DEFINE()
|
||||||
@@ -268,6 +271,19 @@ trait windows
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[BeforeStage('php', [self::class, 'makeMicroForWindows'])]
|
||||||
|
#[PatchDescription('Add /FORCE:MULTIPLE to the micro.sfx link, matching the CLI and CGI targets')]
|
||||||
|
public function patchMicroTarget(TargetPackage $package): void
|
||||||
|
{
|
||||||
|
$makefile = "{$package->getSourceDir()}\\Makefile";
|
||||||
|
if (str_contains(FileSystem::readFile($makefile), 'LDFLAGS_MICRO=/FORCE:MULTIPLE')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Same reason as the php.exe and php-cgi.exe targets: extension-bundled libs duplicate
|
||||||
|
// symbols from php's own objects and the link fails with LNK2005.
|
||||||
|
FileSystem::replaceFileStr($makefile, "\r\nLDFLAGS_MICRO=", "\r\nLDFLAGS_MICRO=/FORCE:MULTIPLE /ignore:4006 ");
|
||||||
|
}
|
||||||
|
|
||||||
#[Stage]
|
#[Stage]
|
||||||
public function makeMicroForWindows(TargetPackage $package, PackageBuilder $builder, PackageInstaller $installer): void
|
public function makeMicroForWindows(TargetPackage $package, PackageBuilder $builder, PackageInstaller $installer): void
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user