Skip to content

Add protection from double --target specification in rustc wrapper #138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 27, 2021
Merged
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ jobs:
version: ${{ matrix.julia-version }}
arch: x64
- uses: julia-actions/julia-buildpkg@latest
- name: Clean up
run: sudo rm -rf /opt
- name: System info
run: julia --project=. --color=yes -e "using BinaryBuilderBase; BinaryBuilderBase.versioninfo()"
- uses: julia-actions/julia-runtest@latest
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BinaryBuilderBase"
uuid = "7f725544-6523-48cd-82d1-3fa08ff4056e"
authors = ["Elliot Saba <[email protected]>"]
version = "0.6.0"
version = "0.6.1"

[deps]
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
Expand Down
16 changes: 14 additions & 2 deletions src/Runner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,6 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr

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

Expand All @@ -474,7 +473,20 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
end
return flags
end
rustc(io::IO, p::AbstractPlatform) = wrapper(io, "/opt/$(host_target)/bin/rustc"; flags=rust_flags!(p), allow_ccache=false)
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
echo "args: \${ARGS[@]}" >&2
exit 1
fi
else
PRE_FLAGS+=( '--target=$(map_rust_target(p))' )
fi
"""
wrapper(io, "/opt/$(host_target)/bin/rustc"; flags=rust_flags!(p), allow_ccache=false, extra_cmds=extra_cmds)
end
rustup(io::IO, p::AbstractPlatform) = wrapper(io, "/opt/$(host_target)/bin/rustup"; allow_ccache=false)
cargo(io::IO, p::AbstractPlatform) = wrapper(io, "/opt/$(host_target)/bin/cargo"; allow_ccache=false)

Expand Down
15 changes: 15 additions & 0 deletions test/runners.jl
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,18 @@ end
end
end
end

@testset "Shards" begin
# Run the testsuite as sanity check
@testset "testsuite" begin
mktempdir() do dir
ur = preferred_runner()(dir; platform=Platform("x86_64", "linux"; libc="glibc"), preferred_gcc_version=v"5", compilers=[:c, :rust, :go])
iobuff = IOBuffer()
test_script = raw"""
set -e
make -j${nproc} -sC /usr/share/testsuite install
"""
@test run(ur, `/bin/bash -c "$(test_script)"`, iobuff; tee_stream=devnull)
end
end
end