Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/MutableArtifacts.toml
Manifest.toml
12 changes: 8 additions & 4 deletions src/Runner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -792,14 +792,17 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
end
function rustc(io::IO, p::AbstractPlatform)
extra_cmds = """
# Default to this platform's target unless overridden in the environment
rust_target="\${CARGO_BUILD_TARGET:-$(map_rust_target(p))}"

if [[ " \${ARGS[@]} " == *'--target'* ]]; then
if ! [[ " \${ARGS[@]} " =~ --target(=| )$(map_rust_target(p)) ]]; then
echo "Attempting to invoke targeted 'rustc' wrapper with a different target! (Expected $(map_rust_target(p)))" >&2
if ! [[ " \${ARGS[@]} " =~ --target(=| )\${rust_target} ]]; then
echo "Attempting to invoke targeted 'rustc' wrapper with a different target! (Expected \${rust_target} from CARGO_BUILD_TARGET or default)" >&2
echo "args: \${ARGS[@]}" >&2
exit 1
fi
else
PRE_FLAGS+=( '--target=$(map_rust_target(p))' )
PRE_FLAGS+=( "--target=\${rust_target}" )
fi
"""
wrapper(io, "/opt/$(host_target)/bin/rustc"; flags=rust_flags!(p), allow_ccache=false, extra_cmds=extra_cmds)
Expand Down Expand Up @@ -1359,7 +1362,8 @@ function platform_envs(platform::AbstractPlatform, src_name::AbstractString;
"RUSTC" => "rustc",
"CARGO" => "cargo",
"CARGO_BUILD_JOBS" => nproc,
"CARGO_BUILD_TARGET" => map_rust_target(platform),
# "CARGO_BUILD_TARGET" => map_rust_target(platform),
"CARGO_HOST_WRAPPER" => "$(host_target)-cargo",
"CARGO_HOME" => "/opt/$(host_target)",
"RUSTUP_HOME" => "/opt/$(host_target)",
))
Expand Down
4 changes: 3 additions & 1 deletion test/rootfs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ end
@test occursin("-L/opt/$(triplet(platform))/$(triplet(platform))/lib", clang)
# Other compilers
@test occursin("GOOS=\"freebsd\"", read(joinpath(platform_bin_dir, "go"), String))
@test occursin("--target=x86_64-unknown-freebsd", read(joinpath(platform_bin_dir, "rustc"), String))
rustc_script = read(joinpath(platform_bin_dir, "rustc"), String)
@test occursin("rust_target=\"\${CARGO_BUILD_TARGET:-x86_64-unknown-freebsd}\"", rustc_script)
@test occursin("--target=\${rust_target}", rustc_script)
end
end
platform = Platform("x86_64", "linux"; libc="glibc", cxxstring_abi="cxx11")
Expand Down