From 66ac136dd6ef09f8ca2b2abc404cc32d46d05b7f Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Tue, 8 Apr 2025 01:58:46 +0200 Subject: [PATCH 1/6] rustc wrapper respects `CARGO_BUILD_TARGET` --- src/Runner.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Runner.jl b/src/Runner.jl index 1de63896..90a96d2e 100644 --- a/src/Runner.jl +++ b/src/Runner.jl @@ -743,8 +743,8 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr function rustc(io::IO, p::AbstractPlatform) extra_cmds = """ 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(=| )\${CARGO_BUILD_TARGET} ]]; then + echo "Attempting to invoke targeted 'rustc' wrapper with a different target! (Expected \${CARGO_BUILD_TARGET}, which is `CARGO_BUILD_TARGET`)" >&2 echo "args: \${ARGS[@]}" >&2 exit 1 fi From abfb732498167f003d3493ca07469de12caaa10d Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Tue, 8 Apr 2025 02:02:25 +0200 Subject: [PATCH 2/6] set in `--target` too --- src/Runner.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Runner.jl b/src/Runner.jl index 90a96d2e..fce7db71 100644 --- a/src/Runner.jl +++ b/src/Runner.jl @@ -749,7 +749,7 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr exit 1 fi else - PRE_FLAGS+=( '--target=$(map_rust_target(p))' ) + PRE_FLAGS+=( '--target=\${CARGO_BUILD_TARGET}' ) fi """ wrapper(io, "/opt/$(host_target)/bin/rustc"; flags=rust_flags!(p), allow_ccache=false, extra_cmds=extra_cmds) From 95fa38e384a269260f9d299b4146b2ee93419ea3 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Tue, 8 Apr 2025 02:16:55 +0200 Subject: [PATCH 3/6] use double-quotes for interpolation, avoid backticks --- src/Runner.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Runner.jl b/src/Runner.jl index fce7db71..01bc752d 100644 --- a/src/Runner.jl +++ b/src/Runner.jl @@ -744,12 +744,12 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr extra_cmds = """ if [[ " \${ARGS[@]} " == *'--target'* ]]; then if ! [[ " \${ARGS[@]} " =~ --target(=| )\${CARGO_BUILD_TARGET} ]]; then - echo "Attempting to invoke targeted 'rustc' wrapper with a different target! (Expected \${CARGO_BUILD_TARGET}, which is `CARGO_BUILD_TARGET`)" >&2 + echo "Attempting to invoke targeted 'rustc' wrapper with a different target! (Expected \${CARGO_BUILD_TARGET}, which is CARGO_BUILD_TARGET)" >&2 echo "args: \${ARGS[@]}" >&2 exit 1 fi else - PRE_FLAGS+=( '--target=\${CARGO_BUILD_TARGET}' ) + PRE_FLAGS+=( "--target=\${CARGO_BUILD_TARGET}" ) fi """ wrapper(io, "/opt/$(host_target)/bin/rustc"; flags=rust_flags!(p), allow_ccache=false, extra_cmds=extra_cmds) From 66d8f1effc4e663ef21c276d4bfa1d5418bf0bb4 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Wed, 26 Nov 2025 17:52:41 +0100 Subject: [PATCH 4/6] ignore manifest --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 22308b2d..c84235be 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /MutableArtifacts.toml +Manifest.toml From bcc3ee7de4ed19721182b15f152e48561df68df3 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Wed, 26 Nov 2025 18:20:13 +0100 Subject: [PATCH 5/6] fallback & fix test --- src/Runner.jl | 9 ++++++--- test/rootfs.jl | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Runner.jl b/src/Runner.jl index 61cdae60..d82f2fa5 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(=| )\${CARGO_BUILD_TARGET} ]]; then - echo "Attempting to invoke targeted 'rustc' wrapper with a different target! (Expected \${CARGO_BUILD_TARGET}, which is CARGO_BUILD_TARGET)" >&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=\${CARGO_BUILD_TARGET}" ) + PRE_FLAGS+=( "--target=\${rust_target}" ) fi """ wrapper(io, "/opt/$(host_target)/bin/rustc"; flags=rust_flags!(p), allow_ccache=false, extra_cmds=extra_cmds) 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") From a39ef1ee67cf4307b09fbe474c76728d181e1e53 Mon Sep 17 00:00:00 2001 From: Eric Hanson <5846501+ericphanson@users.noreply.github.com> Date: Thu, 27 Nov 2025 17:43:49 +0100 Subject: [PATCH 6/6] don't override build target (?), add host wrapper access --- src/Runner.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Runner.jl b/src/Runner.jl index d82f2fa5..6ff35051 100644 --- a/src/Runner.jl +++ b/src/Runner.jl @@ -1362,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)", ))