Skip to content

Commit 61274cb

Browse files
committed
use extra COMPILER_EXTRA env variable to make sure it's actually passed to compiler
1 parent aa51652 commit 61274cb

File tree

2 files changed

+11
-22
lines changed

2 files changed

+11
-22
lines changed

src/SPC/builder/unix/library/libaom.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,14 @@ trait libaom
1616
*/
1717
protected function build(): void
1818
{
19-
$cc = getenv('CC');
20-
$cxx = getenv('CXX');
21-
if (str_contains($cc, 'zig') && getenv('SPC_LIBC') === 'musl') {
22-
f_putenv('CC=' . $cc . ' -D_POSIX_SOURCE');
23-
f_putenv('CXX=' . $cxx . ' -D_POSIX_SOURCE');
19+
if (getenv('SPC_LIBC') === 'musl' && str_contains(getenv('CC'), 'zig')) {
20+
f_putenv('COMPILER_EXTRA=-D_POSIX_SOURCE');
2421
}
2522
UnixCMakeExecutor::create($this)
2623
->setBuildDir("{$this->source_dir}/builddir")
2724
->addConfigureArgs('-DAOM_TARGET_CPU=generic')
2825
->build();
29-
if (str_contains($cc, 'zig') && getenv('SPC_LIBC') === 'musl') {
30-
f_putenv('CC=' . $cc);
31-
f_putenv('CXX=' . $cxx);
32-
}
26+
f_putenv('COMPILER_EXTRA');
3327
$this->patchPkgconfPrefix(['aom.pc']);
3428
}
3529
}

src/SPC/store/scripts/zig-cc.sh

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,38 +61,33 @@ if [ "$SPC_LIBC" = "glibc" ]; then
6161
fi
6262

6363
if [ "$SPC_TARGET_WAS_SET" -eq 0 ] && [ -z "$SPC_LIBC" ] && [ -z "$SPC_LIBC_VERSION" ]; then
64-
exec zig cc "${PARSED_ARGS[@]}"
64+
exec zig cc "${COMPILER_EXTRA}" "${PARSED_ARGS[@]}"
6565
elif [ -z "$SPC_LIBC" ] && [ -z "$SPC_LIBC_VERSION" ]; then
66-
exec zig cc -target ${SPC_TARGET} "${PARSED_ARGS[@]}"
66+
exec zig cc -target "${SPC_TARGET}" "${COMPILER_EXTRA}" "${PARSED_ARGS[@]}"
6767
else
6868
TARGET="${SPC_TARGET}-${SPC_LIBC}"
6969
[ -n "$SPC_LIBC_VERSION" ] && TARGET="${TARGET}.${SPC_LIBC_VERSION}"
7070

71-
output=$(zig cc -target "$TARGET" -lstdc++ "${PARSED_ARGS[@]}" 2>&1)
71+
output=$(zig cc -target "$TARGET" -lstdc++ "${COMPILER_EXTRA}" "${PARSED_ARGS[@]}" 2>&1)
7272
status=$?
7373

74-
filtered_output=$(echo "$output" | grep -v "version '.*' in target triple")
75-
7674
if [ $status -eq 0 ]; then
77-
echo "$filtered_output"
75+
echo "$output" | grep -v "version '.*' in target triple"
7876
exit 0
7977
fi
8078

8179
if echo "$output" | grep -q "version '.*' in target triple"; then
8280
TARGET_FALLBACK="${SPC_TARGET}-${SPC_LIBC}"
83-
output=$(zig cc -target "$TARGET_FALLBACK" -lstdc++ "${PARSED_ARGS[@]}" 2>&1)
81+
output=$(zig cc -target "$TARGET_FALLBACK" -lstdc++ "${COMPILER_EXTRA}" "${PARSED_ARGS[@]}" 2>&1)
8482
status=$?
8583

86-
filtered_output=$(echo "$output" | grep -v "version '.*' in target triple")
87-
8884
if [ $status -eq 0 ]; then
89-
echo "$filtered_output"
85+
echo "$output"
9086
exit 0
9187
else
92-
exec zig cc -target "$TARGET_FALLBACK" "${PARSED_ARGS[@]}"
88+
exec zig cc -target "$TARGET_FALLBACK" "${COMPILER_EXTRA}" "${PARSED_ARGS[@]}"
9389
fi
9490
else
95-
echo "$filtered_output"
96-
exec zig cc -target "$TARGET" "${PARSED_ARGS[@]}"
91+
exec zig cc -target "$TARGET" "${COMPILER_EXTRA}" "${PARSED_ARGS[@]}"
9792
fi
9893
fi

0 commit comments

Comments
 (0)