use extra COMPILER_EXTRA env variable to make sure it's actually passed to compiler

This commit is contained in:
DubbleClick 2025-06-28 21:21:29 +07:00
parent aa516522aa
commit 61274cb865
2 changed files with 11 additions and 22 deletions

View File

@ -16,20 +16,14 @@ trait libaom
*/
protected function build(): void
{
$cc = getenv('CC');
$cxx = getenv('CXX');
if (str_contains($cc, 'zig') && getenv('SPC_LIBC') === 'musl') {
f_putenv('CC=' . $cc . ' -D_POSIX_SOURCE');
f_putenv('CXX=' . $cxx . ' -D_POSIX_SOURCE');
if (getenv('SPC_LIBC') === 'musl' && str_contains(getenv('CC'), 'zig')) {
f_putenv('COMPILER_EXTRA=-D_POSIX_SOURCE');
}
UnixCMakeExecutor::create($this)
->setBuildDir("{$this->source_dir}/builddir")
->addConfigureArgs('-DAOM_TARGET_CPU=generic')
->build();
if (str_contains($cc, 'zig') && getenv('SPC_LIBC') === 'musl') {
f_putenv('CC=' . $cc);
f_putenv('CXX=' . $cxx);
}
f_putenv('COMPILER_EXTRA');
$this->patchPkgconfPrefix(['aom.pc']);
}
}

View File

@ -61,38 +61,33 @@ if [ "$SPC_LIBC" = "glibc" ]; then
fi
if [ "$SPC_TARGET_WAS_SET" -eq 0 ] && [ -z "$SPC_LIBC" ] && [ -z "$SPC_LIBC_VERSION" ]; then
exec zig cc "${PARSED_ARGS[@]}"
exec zig cc "${COMPILER_EXTRA}" "${PARSED_ARGS[@]}"
elif [ -z "$SPC_LIBC" ] && [ -z "$SPC_LIBC_VERSION" ]; then
exec zig cc -target ${SPC_TARGET} "${PARSED_ARGS[@]}"
exec zig cc -target "${SPC_TARGET}" "${COMPILER_EXTRA}" "${PARSED_ARGS[@]}"
else
TARGET="${SPC_TARGET}-${SPC_LIBC}"
[ -n "$SPC_LIBC_VERSION" ] && TARGET="${TARGET}.${SPC_LIBC_VERSION}"
output=$(zig cc -target "$TARGET" -lstdc++ "${PARSED_ARGS[@]}" 2>&1)
output=$(zig cc -target "$TARGET" -lstdc++ "${COMPILER_EXTRA}" "${PARSED_ARGS[@]}" 2>&1)
status=$?
filtered_output=$(echo "$output" | grep -v "version '.*' in target triple")
if [ $status -eq 0 ]; then
echo "$filtered_output"
echo "$output" | grep -v "version '.*' in target triple"
exit 0
fi
if echo "$output" | grep -q "version '.*' in target triple"; then
TARGET_FALLBACK="${SPC_TARGET}-${SPC_LIBC}"
output=$(zig cc -target "$TARGET_FALLBACK" -lstdc++ "${PARSED_ARGS[@]}" 2>&1)
output=$(zig cc -target "$TARGET_FALLBACK" -lstdc++ "${COMPILER_EXTRA}" "${PARSED_ARGS[@]}" 2>&1)
status=$?
filtered_output=$(echo "$output" | grep -v "version '.*' in target triple")
if [ $status -eq 0 ]; then
echo "$filtered_output"
echo "$output"
exit 0
else
exec zig cc -target "$TARGET_FALLBACK" "${PARSED_ARGS[@]}"
exec zig cc -target "$TARGET_FALLBACK" "${COMPILER_EXTRA}" "${PARSED_ARGS[@]}"
fi
else
echo "$filtered_output"
exec zig cc -target "$TARGET" "${PARSED_ARGS[@]}"
exec zig cc -target "$TARGET" "${COMPILER_EXTRA}" "${PARSED_ARGS[@]}"
fi
fi