Skip to content

Commit 15d8ce0

Browse files
authored
[BuildToolchains] Use <aatriplet>-cc as linker in Cargo config (#189)
I don't understand why we were forcing `gcc`, on `aarch64-apple-darwin` this causes lots of trouble, because Cargo would pass in the argument `-arch arm64` which isn't accepted by GCC, but it is by LLVM. Now that we can JIT-generate the file, write the config only for host and target platforms, we don't have the toolchains for the other platforms anyway. Additionally, remove some workarounds previously added in `Runner.jl` to fix errors in the old static config file.
1 parent f348315 commit 15d8ce0

File tree

4 files changed

+11
-26
lines changed

4 files changed

+11
-26
lines changed

src/BuildToolchains.jl

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -254,20 +254,21 @@ function generate_toolchain_files!(platform::AbstractPlatform, envs::Dict{String
254254
end
255255
end
256256

257-
function cargo_config_file!(dir::AbstractString)
258-
# Generate "${CARGO_HOME}/config.toml" file for Cargo where we give it the
259-
# linkers for all our targets
257+
function cargo_config_file!(dir::AbstractString, platform::AbstractPlatform;
258+
host_platform::AbstractPlatform=default_host_platform,
259+
)
260+
# Generate "${CARGO_HOME}/config.toml" file for Cargo where we give it the linkers for
261+
# the host and target platforms.
260262
open(joinpath(dir, "config.toml"), "w") do io
261263
write(io, """
262264
# Configuration file for `cargo`
263265
""")
264-
for platform in supported_platforms(; experimental=true)
265-
# Use `aatriplet` for the linker to match how the wrappers are
266-
# written in
266+
for p in unique(abi_agnostic.((platform, host_platform)))
267+
# Use `aatriplet` for the linker to match how the wrappers are written in
267268
# https://github.com/JuliaPackaging/BinaryBuilderBase.jl/blob/30d056ef68f81dca9cb91ededcce6b68c6466b37/src/Runner.jl#L599.
268269
write(io, """
269-
[target.$(map_rust_target(platform))]
270-
linker = "$(aatriplet(platform))-gcc"
270+
[target.$(map_rust_target(p))]
271+
linker = "$(aatriplet(p))-cc"
271272
""")
272273
end
273274
end

src/DockerRunner.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function DockerRunner(workspace_root::String;
103103
# Generate directory where to write Cargo config files
104104
if isone(length(collect(compilers))) && :rust in collect(compilers)[1].second
105105
cargo_dir = mktempdir()
106-
cargo_config_file!(cargo_dir)
106+
cargo_config_file!(cargo_dir, platform)
107107
# Add to the list of mappings a subdirectory of ${CARGO_HOME}, whose content
108108
# will be put in ${CARGO_HOME}.
109109
push!(workspaces, cargo_dir => envs["CARGO_HOME"] * "/" * randstring())

src/Runner.jl

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -765,22 +765,6 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
765765
write_wrapper(rustc, p, "$(t)-rustc")
766766
write_wrapper(rustup, p, "$(t)-rustup")
767767
write_wrapper(cargo, p, "$(t)-cargo")
768-
769-
# For FreeBSD and macOS we need to create an unversioned link for
770-
# gcc because that's the linker our Rust toolchain expects:
771-
# https://github.com/JuliaPackaging/Yggdrasil/blob/fff0583bc2d8f32e450c427684f295524f38535d/0_RootFS/Rust/build_tarballs.jl#L115-L126.
772-
if Sys.isbsd(p) && os_version(p) !== nothing
773-
tmp_p = deepcopy(p)
774-
delete!(tags(tmp_p), "os_version")
775-
symlink("$(t)-gcc", joinpath(bin_path, triplet(p), "$(aatriplet(tmp_p))-gcc"))
776-
end
777-
# Currently our Rust toolchain expects the linker for armv7l and
778-
# armv6l with the platform "*l" suffix in the platform. Until
779-
# https://github.com/JuliaPackaging/Yggdrasil/pull/2168 makes it to
780-
# the Rust toolchain, we create a symlink to work around this issue.
781-
if proc_family(p) == "arm" && nbits(p) == 32
782-
symlink("$(t)-gcc", joinpath(bin_path, triplet(p), "$(triplet(abi_agnostic(p)))-gcc"))
783-
end
784768
end
785769
end
786770

src/UserNSRunner.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function UserNSRunner(workspace_root::String;
5858
# Generate directory where to write Cargo config files
5959
if isone(length(collect(compilers))) && :rust in collect(compilers)[1].second
6060
cargo_dir = mktempdir()
61-
cargo_config_file!(cargo_dir)
61+
cargo_config_file!(cargo_dir, platform)
6262
# Add to the list of mappings a subdirectory of ${CARGO_HOME}, whose content
6363
# will be put in ${CARGO_HOME}.
6464
push!(mappings, cargo_dir => envs["CARGO_HOME"] * "/" * randstring())

0 commit comments

Comments
 (0)