@@ -868,12 +868,15 @@ async function buildPhp(config: BuildConfig): Promise<string> {
868
868
buildEnv . PKG_CONFIG_PATH = pkgConfigPaths . join ( ':' )
869
869
}
870
870
871
- // Filter out libstdcxx paths on Linux to avoid linking issues
871
+ // Filter out libstdcxx and gcc paths on Linux to avoid linking issues
872
872
const filteredLibPaths = config . platform === 'linux'
873
- ? libPaths . filter ( path => ! path . includes ( 'libstdcxx' ) )
873
+ ? libPaths . filter ( path => ! path . includes ( 'libstdcxx' ) && ! path . includes ( 'gcc' ) )
874
874
: libPaths
875
875
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
877
880
buildEnv . CPPFLAGS = includePaths . map ( path => `-I${ path } ` ) . join ( ' ' )
878
881
879
882
// Add macOS-specific linker flags for DNS resolver functions
@@ -901,9 +904,12 @@ async function buildPhp(config: BuildConfig): Promise<string> {
901
904
buildEnv . CXX = 'g++'
902
905
buildEnv . CFLAGS = ( buildEnv . CFLAGS || '' ) + ' -O2 -fPIC'
903
906
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++'
905
909
// Set preprocessor to avoid traditional-cpp issues
906
910
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 ( ':' )
907
913
// Disable iconv completely on Linux due to glibc errno check failure
908
914
}
909
915
0 commit comments