diff --git a/bin/dump-cpp-ast.php b/bin/dump-cpp-ast.php new file mode 100644 index 00000000..e7a7fa26 --- /dev/null +++ b/bin/dump-cpp-ast.php @@ -0,0 +1,2 @@ + test.json'); \ No newline at end of file diff --git a/bin/gen_stub.php b/bin/gen_stub.php index f7d15ca5..33835225 100755 --- a/bin/gen_stub.php +++ b/bin/gen_stub.php @@ -6095,7 +6095,7 @@ function main() { global $argv, $argc, $translator; - error_reporting(E_ALL); + error_reporting(E_ALL & ~E_DEPRECATED); ini_set("precision", "-1"); require __DIR__ . '/bootstrap.php'; diff --git a/src/Php/CompilerBase.php b/src/Php/CompilerBase.php index 420b0b6e..f3da5c1f 100644 --- a/src/Php/CompilerBase.php +++ b/src/Php/CompilerBase.php @@ -1186,10 +1186,10 @@ class CompilerBase extends \PhpAot\Core\Translator protected function parseLibs(): string { - $list = [ - 'phpx', - 'php', - ]; + $list = ['phpx']; + if ($this->buildMode === 'bin') { + $list[] = 'php'; + } $out = ''; foreach ($list as $li) { $out .= '-l' . $li . ' '; @@ -1215,6 +1215,11 @@ class CompilerBase extends \PhpAot\Core\Translator $cmd .= ' -fPIC -D BUILD_PHP_EXTENSION=1'; } } + + if ($link) { + $cmd .= ' ' . $this->parseLdflags(); + $cmd .= ' ' . $this->parseLibs(); + } } protected function parseBinaryOpConcat(mixed $expr): string diff --git a/src/Php/Translator.php b/src/Php/Translator.php index 83c9d7f1..630ae539 100644 --- a/src/Php/Translator.php +++ b/src/Php/Translator.php @@ -474,7 +474,7 @@ class Translator extends Preprocessor if ($this->buildMode == 'ext' and !str_ends_with($targetFile, '.so')) { $targetFile .= '.so'; } - $linkCmd = $this->cppCompiler . ' ' . $objectList . ' -o ' . $targetFile . ' ' . $this->parseLdflags() . $this->parseLibs(); + $linkCmd = $this->cppCompiler . ' ' . $objectList . ' -o ' . $targetFile; $this->addCompilationOption($linkCmd, true); $this->climate->comment($linkCmd); shell_exec($linkCmd); @@ -578,7 +578,7 @@ class Translator extends Preprocessor $this->climate->comment($genStubCmd); $stubFilenameWithoutExtension = str_replace([".stub.php", '.php'], "", $file); $headerFile = $this->getArgInfoHeaderFile($stubFilenameWithoutExtension, true); - if (!str_starts_with($output, "Saved")) { + if (!str_contains($output, "Saved")) { $this->error("failed to generate arginfo header file: `$headerFile`, output: $output"); } $this->argInfoHeaderFiles[] = $headerFile;