Skip to content

Commit

Permalink
Shake out some assumptions about architecture of host platform (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
giordano authored Nov 8, 2021
1 parent 73da943 commit a78a2d9
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
8 changes: 6 additions & 2 deletions src/BuildToolchains.jl
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,16 @@ meson_cxx_link_args(p::AbstractPlatform) = meson_c_link_args(p)
meson_objc_link_args(p::AbstractPlatform) = meson_c_link_args(p)
meson_fortran_link_args(p::AbstractPlatform) = meson_c_link_args(p)

# We can run native programs only on
# We can run native programs only if the platform matches the default host
# platform, but when this is `x86_64-linux-musl` we can run executables for
# * i686-linux-gnu
# * x86_64-linux-gnu
# * x86_64-linux-musl
function meson_is_foreign(p::AbstractPlatform)
if Sys.islinux(p) && proc_family(p) == "intel" && (libc(p) == "glibc" || (libc(p) == "musl" && arch(p) == "x86_64"))
if platforms_match(p, default_host_platform) ||
(platforms_match(default_host_platform, Platform("x86_64", "linux"; libc="musl"))
&& Sys.islinux(p) && proc_family(p) == "intel" &&
(libc(p) == "glibc" || (libc(p) == "musl" && arch(p) == "x86_64")))
# Better to explicitly return the string we expect rather than
# relying on the representation of the boolean values (even though
# the result is the same)
Expand Down
2 changes: 1 addition & 1 deletion src/Platforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Base.BinaryPlatforms.tags(p::AnyPlatform) = Dict{String,String}()
Base.BinaryPlatforms.triplet(::AnyPlatform) = "any"
Base.BinaryPlatforms.arch(::AnyPlatform) = "any"
Base.BinaryPlatforms.os(::AnyPlatform) = "any"
nbits(::AnyPlatform) = 64
nbits(::AnyPlatform) = nbits(default_host_platform)
proc_family(::AnyPlatform) = "any"
Base.show(io::IO, ::AnyPlatform) = print(io, "AnyPlatform")

Expand Down
2 changes: 1 addition & 1 deletion src/Rootfs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ function choose_shards(p::AbstractPlatform;
return shards
end

# XXX: we want AnyPlatform to look like `x86_64-linux-musl` in the build environment.
# We want AnyPlatform to look like `default_host_platform` in the build environment.
choose_shards(::AnyPlatform; kwargs...) = choose_shards(default_host_platform; kwargs...)

"""
Expand Down
6 changes: 3 additions & 3 deletions src/Runner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default_host_platform
The default host platform in the build environment.
"""
const default_host_platform = Platform("x86_64", "linux"; libc="musl", cxxstring_abi="cxx11")
const default_host_platform = Platform(arch(HostPlatform()), "linux"; libc="musl", cxxstring_abi="cxx11")

function nbits(p::AbstractPlatform)
if arch(p) in ("i686", "armv6l", "armv7l")
Expand Down Expand Up @@ -44,7 +44,7 @@ function aatriplet(p::AbstractPlatform)
t = replace(t, "armv6l" => "arm")
return t
end
# XXX: we want AnyPlatform to look like `x86_64-linux-musl` in the build environment.
# We want AnyPlatform to look like `default_host_platform` in the build environment.
aatriplet(p::AnyPlatform) = aatriplet(default_host_platform)

function ld_library_path(target::AbstractPlatform,
Expand Down Expand Up @@ -896,7 +896,7 @@ function platform_envs(platform::AbstractPlatform, src_name::AbstractString;
"dlext" => platform_dlext(platform),
"exeext" => platform_exeext(platform),
"PATH" => "/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin",
"MACHTYPE" => "x86_64-linux-musl",
"MACHTYPE" => aatriplet(default_host_platform),

# Set location parameters
"WORKSPACE" => "/workspace",
Expand Down
2 changes: 1 addition & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ function get_concrete_platform(platform::AbstractPlatform; kwargs...)
return get_concrete_platform(platform, shards)
end

# XXX: we want the AnyPlatform to look like `x86_64-linux-musl`,
# We want the AnyPlatform to look like `default_host_platform`,
get_concrete_platform(::AnyPlatform, shards::Vector{CompilerShard}) =
get_concrete_platform(default_host_platform, shards)
2 changes: 1 addition & 1 deletion test/platforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ end
@test arch(AnyPlatform()) == "any"
@test repr(AnyPlatform()) == "AnyPlatform"

# In the build environment we want AnyPlatform to look like x86_64-linux-musl
# In the build environment we want AnyPlatform to look like `default_host_platform`
@test get_concrete_platform(
AnyPlatform();
compilers = [:c],
Expand Down
4 changes: 2 additions & 2 deletions test/runners.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ end
@info("Beginning full shard test... (this can take a while)")
platforms = supported_platforms()
else
platforms = (Platform("x86_64", "linux"; libc="musl"),)
platforms = (default_host_platform,)
end

# Checks that the wrappers provide the correct C++ string ABI
@testset "Compilation - C++ string ABI" begin
mktempdir() do dir
# Host is x86_64-linux-musl-cxx11 and target is x86_64-linux-musl-cxx03
ur = preferred_runner()(dir; platform=Platform("x86_64", "linux"; libc="musl", cxxstring_abi="cxx03"), preferred_gcc_version=v"5")
ur = preferred_runner()(dir; platform=Platform(arch(HostPlatform()), "linux"; libc="musl", cxxstring_abi="cxx03"), preferred_gcc_version=v"5")
iobuff = IOBuffer()
test_script = raw"""
set -e
Expand Down

0 comments on commit a78a2d9

Please sign in to comment.