Skip to content

Commit bcc3ee7

Browse files
committed
fallback & fix test
1 parent 66d8f1e commit bcc3ee7

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Runner.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,14 +792,17 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
792792
end
793793
function rustc(io::IO, p::AbstractPlatform)
794794
extra_cmds = """
795+
# Default to this platform's target unless overridden in the environment
796+
rust_target="\${CARGO_BUILD_TARGET:-$(map_rust_target(p))}"
797+
795798
if [[ " \${ARGS[@]} " == *'--target'* ]]; then
796-
if ! [[ " \${ARGS[@]} " =~ --target(=| )\${CARGO_BUILD_TARGET} ]]; then
797-
echo "Attempting to invoke targeted 'rustc' wrapper with a different target! (Expected \${CARGO_BUILD_TARGET}, which is CARGO_BUILD_TARGET)" >&2
799+
if ! [[ " \${ARGS[@]} " =~ --target(=| )\${rust_target} ]]; then
800+
echo "Attempting to invoke targeted 'rustc' wrapper with a different target! (Expected \${rust_target} from CARGO_BUILD_TARGET or default)" >&2
798801
echo "args: \${ARGS[@]}" >&2
799802
exit 1
800803
fi
801804
else
802-
PRE_FLAGS+=( "--target=\${CARGO_BUILD_TARGET}" )
805+
PRE_FLAGS+=( "--target=\${rust_target}" )
803806
fi
804807
"""
805808
wrapper(io, "/opt/$(host_target)/bin/rustc"; flags=rust_flags!(p), allow_ccache=false, extra_cmds=extra_cmds)

test/rootfs.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ end
310310
@test occursin("-L/opt/$(triplet(platform))/$(triplet(platform))/lib", clang)
311311
# Other compilers
312312
@test occursin("GOOS=\"freebsd\"", read(joinpath(platform_bin_dir, "go"), String))
313-
@test occursin("--target=x86_64-unknown-freebsd", read(joinpath(platform_bin_dir, "rustc"), String))
313+
rustc_script = read(joinpath(platform_bin_dir, "rustc"), String)
314+
@test occursin("rust_target=\"\${CARGO_BUILD_TARGET:-x86_64-unknown-freebsd}\"", rustc_script)
315+
@test occursin("--target=\${rust_target}", rustc_script)
314316
end
315317
end
316318
platform = Platform("x86_64", "linux"; libc="glibc", cxxstring_abi="cxx11")

0 commit comments

Comments
 (0)