diff --git a/.gitignore b/.gitignore index 22308b2d..c84235be 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /MutableArtifacts.toml +Manifest.toml diff --git a/src/Runner.jl b/src/Runner.jl index ef5afba1..6ff35051 100644 --- a/src/Runner.jl +++ b/src/Runner.jl @@ -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) @@ -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)", )) diff --git a/test/rootfs.jl b/test/rootfs.jl index 73241d8c..18b568bb 100644 --- a/test/rootfs.jl +++ b/test/rootfs.jl @@ -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")