From 127fb1989f9f4ad40d1a2c2084e3fa6e28172808 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Tue, 16 Jun 2026 19:21:18 +0800 Subject: [PATCH] Add vs 18 support --- src/Package/Library/gettext_win.php | 5 ++++- src/Package/Library/libffi_win.php | 5 ++++- src/Package/Library/libiconv_win.php | 5 ++++- src/Package/Library/libsodium.php | 5 ++++- src/Package/Library/mpir.php | 1 + src/Package/Target/php/windows.php | 1 + src/StaticPHP/Runtime/Executor/WindowsCMakeExecutor.php | 4 ++++ 7 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/Package/Library/gettext_win.php b/src/Package/Library/gettext_win.php index 093e4a3a0..acb4946a8 100644 --- a/src/Package/Library/gettext_win.php +++ b/src/Package/Library/gettext_win.php @@ -22,6 +22,7 @@ public function validate(): void { $ver = WindowsUtil::findVisualStudio(); $vs_ver_dir = match ($ver['major_version']) { + '18', // VS 2026 reuses the VS2022 (MSVC17) solution, which msbuild builds via forward compatibility. '17' => '\MSVC17', '16' => '\MSVC16', default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported yet!"), @@ -44,7 +45,9 @@ public function build(LibraryPackage $lib): void { $vs_ver_dir = ApplicationContext::get('gettext_win_vs_ver_dir'); cmd()->cd("{$lib->getSourceDir()}{$vs_ver_dir}\\libintl_static") - ->exec('msbuild libintl_static.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0'); + // WholeProgramOptimization (/GL) emits LTCG objects that frankenphp's lld-link cannot + // read ("is not a native COFF file"); disable it so the .lib stays plain COFF. + ->exec('msbuild libintl_static.vcxproj /t:Rebuild /p:Configuration=Release /p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0 /p:WholeProgramOptimization=false'); FileSystem::createDir($lib->getLibDir()); FileSystem::createDir($lib->getIncludeDir()); // libintl_a.lib is the static library output; copy as libintl.lib for linker compatibility diff --git a/src/Package/Library/libffi_win.php b/src/Package/Library/libffi_win.php index 12faaabef..9e1640d81 100644 --- a/src/Package/Library/libffi_win.php +++ b/src/Package/Library/libffi_win.php @@ -21,6 +21,7 @@ public function validate(): void { $ver = WindowsUtil::findVisualStudio(); $vs_ver_dir = match ($ver['major_version']) { + '18', // VS 2026 reuses the vs17 solution, which msbuild builds via forward compatibility. '17' => '\win32\vs17_x64', '16' => '\win32\vs16_x64', default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported!"), @@ -33,7 +34,9 @@ public function build(LibraryPackage $lib): void { $vs_ver_dir = ApplicationContext::get('libffi_win_vs_ver_dir'); cmd()->cd("{$lib->getSourceDir()}{$vs_ver_dir}") - ->exec('msbuild libffi-msvc.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64'); + // WholeProgramOptimization (/GL) emits LTCG objects that frankenphp's lld-link cannot + // read ("is not a native COFF file"); disable it so the .lib stays plain COFF. + ->exec('msbuild libffi-msvc.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64 /p:WholeProgramOptimization=false'); FileSystem::createDir($lib->getLibDir()); FileSystem::createDir($lib->getIncludeDir()); diff --git a/src/Package/Library/libiconv_win.php b/src/Package/Library/libiconv_win.php index b6b0531df..630366c29 100644 --- a/src/Package/Library/libiconv_win.php +++ b/src/Package/Library/libiconv_win.php @@ -21,6 +21,7 @@ public function validate(): void { $ver = WindowsUtil::findVisualStudio(); $vs_ver_dir = match ($ver['major_version']) { + '18', // VS 2026 reuses the VS2022 (MSVC17) solution, which msbuild builds via forward compatibility. '17' => '\MSVC17', '16' => '\MSVC16', default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported yet!"), @@ -33,7 +34,9 @@ public function build(LibraryPackage $lib): void { $vs_ver_dir = ApplicationContext::get('vs_ver_dir'); cmd()->cd("{$lib->getSourceDir()}{$vs_ver_dir}") - ->exec('msbuild libiconv.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64'); + // WholeProgramOptimization (/GL) emits LTCG objects that frankenphp's lld-link cannot + // read ("is not a native COFF file"); disable it so the .lib stays plain COFF. + ->exec('msbuild libiconv.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64 /p:WholeProgramOptimization=false'); FileSystem::createDir($lib->getLibDir()); FileSystem::createDir($lib->getIncludeDir()); FileSystem::copy("{$lib->getSourceDir()}{$vs_ver_dir}\\x64\\lib\\libiconv.lib", "{$lib->getLibDir()}\\libiconv.lib"); diff --git a/src/Package/Library/libsodium.php b/src/Package/Library/libsodium.php index 0d4c8afef..bd70f7be3 100644 --- a/src/Package/Library/libsodium.php +++ b/src/Package/Library/libsodium.php @@ -42,13 +42,16 @@ public function buildWin(LibraryPackage $lib): void { $ver = WindowsUtil::findVisualStudio(); $vs_ver_dir = match ($ver['major_version']) { + '18', // VS 2026 reuses the vs2022 solution, which msbuild builds via forward compatibility. '17' => '\vs2022', '16' => '\vs2019', default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported yet!"), }; cmd()->cd("{$lib->getSourceDir()}\\builds\\msvc{$vs_ver_dir}") - ->exec('msbuild libsodium.sln /t:Rebuild /p:Configuration=StaticRelease /p:Platform=x64 /p:PreprocessorDefinitions="SODIUM_STATIC=1"'); + // WholeProgramOptimization (/GL) emits LTCG objects that frankenphp's lld-link cannot + // read ("is not a native COFF file"); disable it so the .lib stays plain COFF. + ->exec('msbuild libsodium.sln /t:Rebuild /p:Configuration=StaticRelease /p:Platform=x64 /p:WholeProgramOptimization=false /p:PreprocessorDefinitions="SODIUM_STATIC=1"'); FileSystem::createDir($lib->getLibDir()); FileSystem::createDir($lib->getIncludeDir()); diff --git a/src/Package/Library/mpir.php b/src/Package/Library/mpir.php index 8063b7826..53cf86587 100644 --- a/src/Package/Library/mpir.php +++ b/src/Package/Library/mpir.php @@ -21,6 +21,7 @@ public function validate(): void { $ver = WindowsUtil::findVisualStudio(); $vs_ver_dir = match ($ver['major_version']) { + '18', // VS 2026 reuses the build.vc17 solution, which msbuild builds via forward compatibility. '17' => '\build.vc17', '16' => '\build.vc16', default => throw new EnvironmentException("Current VS version {$ver['major_version']} is not supported yet!"), diff --git a/src/Package/Target/php/windows.php b/src/Package/Target/php/windows.php index d2f863327..a38da5b43 100644 --- a/src/Package/Target/php/windows.php +++ b/src/Package/Target/php/windows.php @@ -512,6 +512,7 @@ public function patchBeforeBuildconfForWindows(TargetPackage $package): void $vc_matches = ['unknown', 'unknown']; } else { $vc_matches = match ($vc['major_version']) { + '18', // VS 2026 shares the VS2022 (v143) runtime conventions, so it reports as VS17. '17' => ['VS17', 'Visual C++ 2022'], '16' => ['VS16', 'Visual C++ 2019'], default => ['unknown', 'unknown'], diff --git a/src/StaticPHP/Runtime/Executor/WindowsCMakeExecutor.php b/src/StaticPHP/Runtime/Executor/WindowsCMakeExecutor.php index 1f057f126..e7227cfd5 100644 --- a/src/StaticPHP/Runtime/Executor/WindowsCMakeExecutor.php +++ b/src/StaticPHP/Runtime/Executor/WindowsCMakeExecutor.php @@ -189,6 +189,10 @@ private function getDefaultCMakeArgs(): array { return $this->custom_default_args ?? [ '-A x64', + // CMake 4.x hard-errors on projects requesting compatibility with CMake < 3.5 + // (e.g. wineditline). This is the documented escape hatch; modern projects and + // older CMake releases ignore it. + '-DCMAKE_POLICY_VERSION_MINIMUM=3.5', '-DCMAKE_BUILD_TYPE=Release', '-DBUILD_SHARED_LIBS=OFF', '-DBUILD_STATIC_LIBS=ON',