mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-08 17:35:36 +08:00
building shared libphp.so on musl is really pointless and should be an error, since static compilations cannot load it
This commit is contained in:
@@ -139,6 +139,9 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
$embed_type = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static';
|
$embed_type = getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') ?: 'static';
|
||||||
|
if ($embed_type !== 'static' && getenv('SPC_LIBC') === 'musl') {
|
||||||
|
throw new RuntimeException('Musl libc does not support dynamic linking of PHP embed!');
|
||||||
|
}
|
||||||
shell()->cd(SOURCE_PATH . '/php-src')
|
shell()->cd(SOURCE_PATH . '/php-src')
|
||||||
->exec(
|
->exec(
|
||||||
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
|
getenv('SPC_CMD_PREFIX_PHP_CONFIGURE') . ' ' .
|
||||||
@@ -335,6 +338,9 @@ class LinuxBuilder extends UnixBuilderBase
|
|||||||
}
|
}
|
||||||
chdir($cwd);
|
chdir($cwd);
|
||||||
}
|
}
|
||||||
|
if (!$this->getOption('no-strip', false)) {
|
||||||
|
shell()->cd(SOURCE_PATH . '/php-src/sapi/cli')->exec('strip --strip-all php');
|
||||||
|
}
|
||||||
$this->patchPhpScripts();
|
$this->patchPhpScripts();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -327,9 +327,11 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
$debugFlags = $this->getOption('no-strip') ? "'-w -s' " : '';
|
$debugFlags = $this->getOption('no-strip') ? "'-w -s' " : '';
|
||||||
$extLdFlags = "-extldflags '-pie'";
|
$extLdFlags = "-extldflags '-pie'";
|
||||||
$muslTags = '';
|
$muslTags = '';
|
||||||
|
$staticFlags = '';
|
||||||
if (PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') === 'musl') {
|
if (PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') === 'musl') {
|
||||||
$extLdFlags = "-extldflags '-static-pie -Wl,-z,stack-size=0x80000'";
|
$extLdFlags = "-extldflags '-static-pie -Wl,-z,stack-size=0x80000'";
|
||||||
$muslTags = 'static_build,';
|
$muslTags = 'static_build,';
|
||||||
|
$staticFlags = '-static -static-pie';
|
||||||
}
|
}
|
||||||
|
|
||||||
$config = (new SPCConfigUtil($this))->config($this->ext_list, $this->lib_list, with_dependencies: true);
|
$config = (new SPCConfigUtil($this))->config($this->ext_list, $this->lib_list, with_dependencies: true);
|
||||||
@@ -337,7 +339,7 @@ abstract class UnixBuilderBase extends BuilderBase
|
|||||||
$env = [
|
$env = [
|
||||||
'CGO_ENABLED' => '1',
|
'CGO_ENABLED' => '1',
|
||||||
'CGO_CFLAGS' => $config['cflags'],
|
'CGO_CFLAGS' => $config['cflags'],
|
||||||
'CGO_LDFLAGS' => "{$config['ldflags']} {$config['libs']} {$lrt}",
|
'CGO_LDFLAGS' => "$staticFlags {$config['ldflags']} {$config['libs']} {$lrt}",
|
||||||
'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' .
|
'XCADDY_GO_BUILD_FLAGS' => '-buildmode=pie ' .
|
||||||
'-ldflags \"-linkmode=external ' . $extLdFlags . ' ' . $debugFlags .
|
'-ldflags \"-linkmode=external ' . $extLdFlags . ' ' . $debugFlags .
|
||||||
'-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' .
|
'-X \'github.com/caddyserver/caddy/v2.CustomVersion=FrankenPHP ' .
|
||||||
|
|||||||
Reference in New Issue
Block a user