Skip to content

Commit 45bc58a

Browse files
committed
chore: wip
1 parent 3a70d34 commit 45bc58a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

scripts/build-php.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -868,12 +868,15 @@ async function buildPhp(config: BuildConfig): Promise<string> {
868868
buildEnv.PKG_CONFIG_PATH = pkgConfigPaths.join(':')
869869
}
870870

871-
// Filter out libstdcxx paths on Linux to avoid linking issues
871+
// Filter out libstdcxx and gcc paths on Linux to avoid linking issues
872872
const filteredLibPaths = config.platform === 'linux'
873-
? libPaths.filter(path => !path.includes('libstdcxx'))
873+
? libPaths.filter(path => !path.includes('libstdcxx') && !path.includes('gcc'))
874874
: libPaths
875875

876-
buildEnv.LDFLAGS = filteredLibPaths.map(path => `-L${path}`).join(' ')
876+
const ldflags = filteredLibPaths.map(path => `-L${path}`).join(' ')
877+
buildEnv.LDFLAGS = config.platform === 'linux'
878+
? `${ldflags} -lstdc++`
879+
: ldflags
877880
buildEnv.CPPFLAGS = includePaths.map(path => `-I${path}`).join(' ')
878881

879882
// Add macOS-specific linker flags for DNS resolver functions
@@ -901,9 +904,12 @@ async function buildPhp(config: BuildConfig): Promise<string> {
901904
buildEnv.CXX = 'g++'
902905
buildEnv.CFLAGS = (buildEnv.CFLAGS || '') + ' -O2 -fPIC'
903906
buildEnv.CXXFLAGS = (buildEnv.CXXFLAGS || '') + ' -O2 -fPIC'
904-
// Use system libstdc++ instead of Launchpad's to avoid linking issues
907+
// Force use of system libstdc++ and prevent Launchpad gcc paths
908+
buildEnv.LDFLAGS = (buildEnv.LDFLAGS || '') + ' -lstdc++'
905909
// Set preprocessor to avoid traditional-cpp issues
906910
buildEnv.CPP = 'gcc -E'
911+
// Clear any existing PKG_CONFIG_PATH that might include gcc paths
912+
buildEnv.PKG_CONFIG_PATH = pkgConfigPaths.filter(path => !path.includes('gcc')).join(':')
907913
// Disable iconv completely on Linux due to glibc errno check failure
908914
}
909915

0 commit comments

Comments
 (0)