Skip to content
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

Prepratory work for Darwin Aarch64 shard #28

Merged
merged 3 commits into from
Sep 2, 2020
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
21 changes: 15 additions & 6 deletions src/Rootfs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ end

# The inverse of `artifact_name(cs)`
function CompilerShard(art_name::String)
m = match(r"^([^-]+)(?:-(.+))?\.(v[\d\.]+)\.([^0-9].+-.+)\.(\w+)", art_name)
m = match(r"^([^-]+)(?:-(.+))?\.(v[\d\.]+(?:-[^\.]+)?)\.([^0-9].+-.+)\.(\w+)", art_name)
if m === nothing
error("Unable to parse '$(art_name)'")
end
Expand Down Expand Up @@ -476,11 +476,19 @@ function choose_shards(p::Platform;
preferred_llvm_version::VersionNumber = getversion(LLVM_builds[end]),
)

GCC_build = select_gcc_version(p, GCC_builds, preferred_gcc_version)
LLVM_build = select_closest_version(preferred_llvm_version, getversion.(LLVM_builds))
# Our host platform is x86_64-linux-musl
host_platform = Linux(:x86_64; libc=:musl)

make_gcc_shard(GCC_build, target) = CompilerShard("GCCBootstrap", GCC_build, host_platform, archive_type; target=target)

this_platform_GCC_builds = filter(GCC_builds) do GCC_build
make_gcc_shard(getversion(GCC_build), p) in all_compiler_shards() &&
make_gcc_shard(getversion(GCC_build), host_platform) in all_compiler_shards()
end

GCC_build = select_gcc_version(p, this_platform_GCC_builds, preferred_gcc_version)
LLVM_build = select_closest_version(preferred_llvm_version, getversion.(LLVM_builds))

shards = CompilerShard[]
if isempty(bootstrap_list)
append!(shards, [
Expand All @@ -492,14 +500,14 @@ function choose_shards(p::Platform;
platform_match(a, b) = ((typeof(a) <: typeof(b)) && (arch(a) == arch(b)) && (libc(a) == libc(b)))
if :c in compilers
append!(shards, [
CompilerShard("GCCBootstrap", GCC_build, host_platform, archive_type; target=p),
make_gcc_shard(GCC_build, p),
CompilerShard("LLVMBootstrap", LLVM_build, host_platform, archive_type),
])
# If we're not building for the host platform, then add host shard for host tools
if !platform_match(p, host_platform)
append!(shards, [
CompilerShard("PlatformSupport", ps_build, host_platform, archive_type; target=host_platform),
giordano marked this conversation as resolved.
Show resolved Hide resolved
CompilerShard("GCCBootstrap", GCC_build, host_platform, archive_type; target=host_platform),
make_gcc_shard(GCC_build, host_platform)
])
end
end
Expand All @@ -517,7 +525,7 @@ function choose_shards(p::Platform;

# We have to add these as well for access to linkers and whatnot for Rust. Sigh.
push!(shards, CompilerShard("PlatformSupport", ps_build, host_platform, archive_type; target=Rust_host))
push!(shards, CompilerShard("GCCBootstrap", GCC_build, host_platform, archive_type; target=Rust_host))
push!(shards, make_gcc_shard(GCC_build, Rust_host))
end
if !platform_match(p, host_platform)
push!(shards, CompilerShard("RustToolchain", Rust_build, Rust_host, archive_type; target=host_platform))
Expand All @@ -532,6 +540,7 @@ function choose_shards(p::Platform;
versions = [cs.version for cs in all_compiler_shards()
if cs.name == name && cs.archive_type == archive_type && (something(cs.target, p) == p)
]
isempty(versions) && error("No latest shard found for $name")
return maximum(versions)
end

Expand Down
7 changes: 6 additions & 1 deletion src/Runner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,12 @@ function generate_compiler_wrappers!(platform::Platform; bin_path::AbstractStrin
end
end

clang_targeting_laser(p::Platform) = "-target $(aatriplet(p)) --sysroot=/opt/$(aatriplet(p))/$(aatriplet(p))/sys-root"
clang_target_triplet(p::Platform) = aatriplet(p)
# For now this is required for Clang, since apple spells aarch64 "arm64".
# Should probably be fixed upstream, but will do for now
clang_target_triplet(p::MacOS) = replace(aatriplet(p), "aarch64" => "arm64")

clang_targeting_laser(p::Platform) = "-target $(clang_target_triplet(p)) --sysroot=/opt/$(aatriplet(p))/$(aatriplet(p))/sys-root"
# For MacOS and FreeBSD, we don't set `-rtlib`, and FreeBSD is special-cased within the LLVM source tree
# to not allow for -gcc-toolchain, which means that we have to manually add the location of libgcc_s. LE SIGH.
# We do that within `clang_linker_flags()`, so that we don't get "unused argument" warnings all over the place.
Expand Down