From a78a2d9119a3faed4ef50a15f4928b491c287f8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mos=C3=A8=20Giordano?= Date: Mon, 8 Nov 2021 21:57:25 +0000 Subject: [PATCH] Shake out some assumptions about architecture of host platform (#178) --- src/BuildToolchains.jl | 8 ++++++-- src/Platforms.jl | 2 +- src/Rootfs.jl | 2 +- src/Runner.jl | 6 +++--- src/utils.jl | 2 +- test/platforms.jl | 2 +- test/runners.jl | 4 ++-- 7 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/BuildToolchains.jl b/src/BuildToolchains.jl index 31fef5f0..e68bcebf 100644 --- a/src/BuildToolchains.jl +++ b/src/BuildToolchains.jl @@ -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) diff --git a/src/Platforms.jl b/src/Platforms.jl index ac81c7c1..f9577715 100644 --- a/src/Platforms.jl +++ b/src/Platforms.jl @@ -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") diff --git a/src/Rootfs.jl b/src/Rootfs.jl index 89a01bd7..3af648c6 100644 --- a/src/Rootfs.jl +++ b/src/Rootfs.jl @@ -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...) """ diff --git a/src/Runner.jl b/src/Runner.jl index cb3e9169..75f80b14 100644 --- a/src/Runner.jl +++ b/src/Runner.jl @@ -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") @@ -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, @@ -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", diff --git a/src/utils.jl b/src/utils.jl index 8a2147e5..0ac8070d 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -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) diff --git a/test/platforms.jl b/test/platforms.jl index 925fce51..4ec95672 100644 --- a/test/platforms.jl +++ b/test/platforms.jl @@ -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], diff --git a/test/runners.jl b/test/runners.jl index 9960000f..28e99def 100644 --- a/test/runners.jl +++ b/test/runners.jl @@ -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