Skip to content

Commit 1b17dee

Browse files
committed
Add protection from double --target specification in rustc wrapper
This may be a little bit too strict; we'll have to see.
1 parent 2105763 commit 1b17dee

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/Runner.jl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,6 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
457457

458458
# Rust stuff
459459
function rust_flags!(p::AbstractPlatform, flags::Vector{String} = String[])
460-
push!(flags, "--target=$(map_rust_target(p))")
461460
if Sys.islinux(p)
462461
push!(flags, "-Clinker=$(aatriplet(p))-gcc")
463462

@@ -474,7 +473,20 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
474473
end
475474
return flags
476475
end
477-
rustc(io::IO, p::AbstractPlatform) = wrapper(io, "/opt/$(host_target)/bin/rustc"; flags=rust_flags!(p), allow_ccache=false)
476+
function rustc(io::IO, p::AbstractPlatform)
477+
extra_cmds = """
478+
if [[ " \${ARGS[@]} " == *'--target'* ]]; then
479+
if ! [[ " \${ARGS[@]} " =~ --target(=| )$(map_rust_target(p)) ]]; then
480+
echo "Attempting to invoke targeted 'rustc' wrapper with a different target! (Expected $(map_rust_target(p)))" >&2
481+
echo "args: \${ARGS[@]}" >&2
482+
exit 1
483+
fi
484+
else
485+
PRE_FLAGS+=( '--target=$(map_rust_target(p))' )
486+
fi
487+
"""
488+
wrapper(io, "/opt/$(host_target)/bin/rustc"; flags=rust_flags!(p), allow_ccache=false, extra_cmds=extra_cmds)
489+
end
478490
rustup(io::IO, p::AbstractPlatform) = wrapper(io, "/opt/$(host_target)/bin/rustup"; allow_ccache=false)
479491
cargo(io::IO, p::AbstractPlatform) = wrapper(io, "/opt/$(host_target)/bin/cargo"; allow_ccache=false)
480492

0 commit comments

Comments
 (0)