Skip to content

Commit b6240f1

Browse files
committed
clean files before compiling because it may try to link the wrong one
1 parent f528153 commit b6240f1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/SPC/builder/unix/UnixBuilderBase.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,17 +205,19 @@ protected function sanityCheck(int $build_target): void
205205
if (PHP_OS_FAMILY === 'Linux' && getenv('SPC_LIBC') === 'musl') {
206206
$lens .= ' -static';
207207
}
208-
[$ret, $out] = shell()->cd($sample_file_path)->execWithResult(getenv('CC') . ' -o embed embed.c ' . $lens);
209-
if ($ret !== 0) {
210-
throw new RuntimeException('embed failed sanity check: build failed. Error message: ' . implode("\n", $out));
211-
}
212208
// if someone changed to EMBED_TYPE=shared, we need to add LD_LIBRARY_PATH
213209
if (getenv('SPC_CMD_VAR_PHP_EMBED_TYPE') === 'shared') {
214210
$ext_path = 'LD_LIBRARY_PATH=' . BUILD_ROOT_PATH . '/lib:$LD_LIBRARY_PATH ';
215211
FileSystem::removeFileIfExists(BUILD_ROOT_PATH . '/lib/libphp.a');
216212
} else {
217213
$ext_path = '';
218-
FileSystem::removeFileIfExists(BUILD_ROOT_PATH . '/lib/libphp.so');
214+
foreach (glob(BUILD_LIB_PATH . '/libphp*.so') as $file) {
215+
unlink($file);
216+
}
217+
}
218+
[$ret, $out] = shell()->cd($sample_file_path)->execWithResult(getenv('CC') . ' -o embed embed.c ' . $lens);
219+
if ($ret !== 0) {
220+
throw new RuntimeException('embed failed sanity check: build failed. Error message: ' . implode("\n", $out));
219221
}
220222
[$ret, $output] = shell()->cd($sample_file_path)->execWithResult($ext_path . './embed');
221223
if ($ret !== 0 || trim(implode('', $output)) !== 'hello') {

0 commit comments

Comments
 (0)