@@ -683,7 +683,7 @@ openssl.capath =
683
683
684
684
function createUnixPhpIni ( installPrefix : string , config : BuildConfig ) : void {
685
685
const phpIniPath = join ( installPrefix , 'lib' , 'php.ini' )
686
-
686
+
687
687
// Create comprehensive php.ini content for Unix builds
688
688
const phpIniContent = `; PHP Configuration File
689
689
; Generated automatically for Launchpad PHP build (Unix)
@@ -766,7 +766,7 @@ openssl.capath =
766
766
`
767
767
768
768
writeFileSync ( phpIniPath , phpIniContent )
769
-
769
+
770
770
// Also create a copy in the etc directory if it exists
771
771
const etcPhpIniPath = join ( installPrefix , 'etc' , 'php.ini' )
772
772
const etcDir = join ( installPrefix , 'etc' )
@@ -788,7 +788,7 @@ async function buildPhp(config: BuildConfig): Promise<string> {
788
788
log ( 'Using system libraries for Linux PHP build to avoid libstdc++ conflicts' )
789
789
return buildPhpWithSystemLibraries ( config , installPrefix )
790
790
}
791
-
791
+
792
792
log ( 'Using Launchpad-managed dependencies for PHP build' )
793
793
794
794
const phpSourceDir = downloadPhpSource ( config )
@@ -827,11 +827,11 @@ async function buildPhp(config: BuildConfig): Promise<string> {
827
827
`${ launchpadRoot } /sqlite.org/v3.47.2/lib/pkgconfig` ,
828
828
`${ launchpadRoot } /libzip.org/v1.11.4/lib/pkgconfig`
829
829
]
830
-
830
+
831
831
// Completely exclude libstdcxx and gcc paths on Linux
832
832
if ( config . platform === 'linux' ) {
833
- pkgConfigPaths = pkgConfigPaths . filter ( path =>
834
- ! path . includes ( 'libstdcxx' ) &&
833
+ pkgConfigPaths = pkgConfigPaths . filter ( path =>
834
+ ! path . includes ( 'libstdcxx' ) &&
835
835
! path . includes ( 'gcc' ) &&
836
836
! path . includes ( 'gnu.org/gcc' )
837
837
)
@@ -856,11 +856,11 @@ async function buildPhp(config: BuildConfig): Promise<string> {
856
856
`${ launchpadRoot } /sqlite.org/v3.47.2/lib` ,
857
857
`${ launchpadRoot } /libzip.org/v1.11.4/lib`
858
858
]
859
-
859
+
860
860
// Completely exclude libstdcxx and gcc paths on Linux
861
861
if ( config . platform === 'linux' ) {
862
- libPaths = libPaths . filter ( path =>
863
- ! path . includes ( 'libstdcxx' ) &&
862
+ libPaths = libPaths . filter ( path =>
863
+ ! path . includes ( 'libstdcxx' ) &&
864
864
! path . includes ( 'gcc' ) &&
865
865
! path . includes ( 'gnu.org/gcc' )
866
866
)
@@ -1102,17 +1102,24 @@ exec "$@"
1102
1102
log ( 'Building PHP...' )
1103
1103
const jobs = execSync ( 'nproc 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 2' , { encoding : 'utf8' } ) . trim ( )
1104
1104
1105
- execSync ( `make -j${ jobs } ` , {
1105
+ // Limit parallel jobs on macOS to prevent compilation hangs
1106
+ const maxJobs = config . platform === 'darwin' ? Math . min ( parseInt ( jobs ) , 2 ) : parseInt ( jobs )
1107
+ log ( `Using ${ maxJobs } parallel jobs for compilation` )
1108
+
1109
+ execSync ( `make -j${ maxJobs } ` , {
1106
1110
stdio : 'inherit' ,
1107
1111
cwd : phpSourceDir ,
1108
- env : buildEnv
1112
+ env : buildEnv ,
1113
+ // Add timeout to prevent infinite hangs
1114
+ timeout : 45 * 60 * 1000 // 45 minutes
1109
1115
} )
1110
1116
1111
1117
log ( 'Installing PHP...' )
1112
1118
execSync ( 'make install' , {
1113
1119
stdio : 'inherit' ,
1114
1120
cwd : phpSourceDir ,
1115
- env : buildEnv
1121
+ env : buildEnv ,
1122
+ timeout : 15 * 60 * 1000 // 15 minutes timeout for install
1116
1123
} )
1117
1124
1118
1125
// Create php.ini for Unix builds to enable OPcache and other extensions
@@ -1202,15 +1209,15 @@ exec "$@"
1202
1209
1203
1210
function buildPhpWithSystemLibraries ( config : BuildConfig , installPrefix : string ) : string {
1204
1211
log ( 'Building PHP with system libraries only (Linux)' )
1205
-
1212
+
1206
1213
const phpSourceDir = downloadPhpSource ( config )
1207
1214
mkdirSync ( installPrefix , { recursive : true } )
1208
1215
1209
1216
// Install required system packages for extensions
1210
1217
log ( 'Installing required system packages...' )
1211
1218
try {
1212
1219
execSync ( 'apt-get update && apt-get install -y libbz2-dev libzip-dev gettext libgettextpo-dev pkg-config' , { stdio : 'inherit' } )
1213
-
1220
+
1214
1221
// Verify libzip installation
1215
1222
try {
1216
1223
const libzipVersion = execSync ( 'pkg-config --modversion libzip' , { encoding : 'utf8' } ) . trim ( )
@@ -1312,18 +1319,18 @@ function buildPhpWithSystemLibraries(config: BuildConfig, installPrefix: string)
1312
1319
configureSuccess = true
1313
1320
} catch ( error ) {
1314
1321
log ( 'Full configure failed, trying individual extensions...' )
1315
-
1322
+
1316
1323
// Try with individual extensions to see which ones work
1317
1324
const workingArgs = [ ...baseConfigureArgs ]
1318
-
1325
+
1319
1326
// Test each extension individually with proper configuration
1320
1327
const extensionsToTest = [
1321
1328
{ flag : '--with-zip' , name : 'zip' } , // Use --with-zip instead of --enable-zip
1322
1329
{ flag : '--with-iconv' , name : 'iconv' } ,
1323
1330
{ flag : '--with-bz2' , name : 'bz2' } ,
1324
1331
{ flag : '--with-gettext' , name : 'gettext' }
1325
1332
]
1326
-
1333
+
1327
1334
for ( const ext of extensionsToTest ) {
1328
1335
try {
1329
1336
const testArgs = [ ...baseConfigureArgs , ext . flag ]
@@ -1338,7 +1345,7 @@ function buildPhpWithSystemLibraries(config: BuildConfig, installPrefix: string)
1338
1345
log ( `❌ ${ ext . name } extension: Not available, skipping` )
1339
1346
}
1340
1347
}
1341
-
1348
+
1342
1349
// Final configure with working extensions
1343
1350
execSync ( `./configure ${ workingArgs . join ( ' ' ) } ` , {
1344
1351
cwd : phpSourceDir ,
@@ -1347,24 +1354,29 @@ function buildPhpWithSystemLibraries(config: BuildConfig, installPrefix: string)
1347
1354
} )
1348
1355
configureSuccess = true
1349
1356
}
1350
-
1357
+
1351
1358
if ( ! configureSuccess ) {
1352
1359
throw new Error ( 'Configure failed even with minimal extensions' )
1353
1360
}
1354
1361
1355
1362
log ( 'Configure completed successfully, building PHP...' )
1356
1363
const jobs = execSync ( 'nproc 2>/dev/null || echo 2' , { encoding : 'utf8' } ) . trim ( )
1357
- execSync ( `make -j${ jobs } ` , {
1364
+ const maxJobs = Math . min ( parseInt ( jobs ) , 4 ) // Limit to 4 jobs max to prevent resource issues
1365
+ log ( `Using ${ maxJobs } parallel jobs for compilation` )
1366
+
1367
+ execSync ( `make -j${ maxJobs } ` , {
1358
1368
cwd : phpSourceDir ,
1359
1369
env : buildEnv ,
1360
- stdio : 'inherit'
1370
+ stdio : 'inherit' ,
1371
+ timeout : 45 * 60 * 1000 // 45 minutes timeout
1361
1372
} )
1362
1373
1363
1374
log ( 'Installing PHP...' )
1364
1375
execSync ( 'make install' , {
1365
1376
cwd : phpSourceDir ,
1366
1377
env : buildEnv ,
1367
- stdio : 'inherit'
1378
+ stdio : 'inherit' ,
1379
+ timeout : 30 * 60 * 1000 // 30 minutes timeout for install
1368
1380
} )
1369
1381
1370
1382
// Create php.ini for Unix builds
0 commit comments