Skip to content

Commit 0da8dcf

Browse files
committed
macos? 2
1 parent 190be6c commit 0da8dcf

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

src/SPC/builder/unix/UnixBuilderBase.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,17 @@ public function getDynamicExportSymbolsFile(): ?string
7070

7171
$exportList = BUILD_LIB_PATH . '/export-dynamic.list';
7272
$lines = [];
73-
$lines[] = '{';
74-
foreach ($defined as $sym) {
75-
$lines[] = " {$sym};";
73+
if (SPCTarget::getTargetOS() === 'Linux') {
74+
$lines[] = '{';
75+
foreach ($defined as $sym) {
76+
$lines[] = " {$sym};";
77+
}
78+
$lines[] = '};';
79+
} else {
80+
foreach ($defined as $sym) {
81+
$lines[] = "_{$sym}";
82+
}
7683
}
77-
$lines[] = '};';
7884
file_put_contents($exportList, implode("\n", $lines) . "\n");
7985

8086
$this->dynamic_export_list = $exportList;
@@ -202,8 +208,14 @@ protected function sanityCheck(int $build_target): void
202208
foreach (glob(BUILD_LIB_PATH . "/libphp*.{$suffix}") as $file) {
203209
unlink($file);
204210
}
205-
$symbolList = $this->getDynamicExportSymbolsFile();
206-
$dynamic_exports = $symbolList ? (' -Wl,--dynamic-list' . (SPCTarget::getTargetOS() === 'Darwin' ? '-file' : '') . '=' . $symbolList) : '';
211+
212+
if ($symbolList = $this->getDynamicExportSymbolsFile()) {
213+
if (SPCTarget::getTargetOS() === 'Linux') {
214+
$dynamic_exports = ' -Wl,--dynamic-list=' . $symbolList;
215+
} else {
216+
$dynamic_exports = ' -Wl,-exported_symbols_list,' . $symbolList;
217+
}
218+
}
207219
}
208220
[$ret, $out] = shell()->cd($sample_file_path)->execWithResult(getenv('CC') . ' -o embed embed.c ' . $lens . ' ' . $dynamic_exports);
209221
if ($ret !== 0) {

0 commit comments

Comments
 (0)