Skip to content

Commit a78a2d9

Browse files
authored
Shake out some assumptions about architecture of host platform (#178)
1 parent 73da943 commit a78a2d9

File tree

7 files changed

+15
-11
lines changed

7 files changed

+15
-11
lines changed

src/BuildToolchains.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,16 @@ meson_cxx_link_args(p::AbstractPlatform) = meson_c_link_args(p)
125125
meson_objc_link_args(p::AbstractPlatform) = meson_c_link_args(p)
126126
meson_fortran_link_args(p::AbstractPlatform) = meson_c_link_args(p)
127127

128-
# We can run native programs only on
128+
# We can run native programs only if the platform matches the default host
129+
# platform, but when this is `x86_64-linux-musl` we can run executables for
129130
# * i686-linux-gnu
130131
# * x86_64-linux-gnu
131132
# * x86_64-linux-musl
132133
function meson_is_foreign(p::AbstractPlatform)
133-
if Sys.islinux(p) && proc_family(p) == "intel" && (libc(p) == "glibc" || (libc(p) == "musl" && arch(p) == "x86_64"))
134+
if platforms_match(p, default_host_platform) ||
135+
(platforms_match(default_host_platform, Platform("x86_64", "linux"; libc="musl"))
136+
&& Sys.islinux(p) && proc_family(p) == "intel" &&
137+
(libc(p) == "glibc" || (libc(p) == "musl" && arch(p) == "x86_64")))
134138
# Better to explicitly return the string we expect rather than
135139
# relying on the representation of the boolean values (even though
136140
# the result is the same)

src/Platforms.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Base.BinaryPlatforms.tags(p::AnyPlatform) = Dict{String,String}()
1414
Base.BinaryPlatforms.triplet(::AnyPlatform) = "any"
1515
Base.BinaryPlatforms.arch(::AnyPlatform) = "any"
1616
Base.BinaryPlatforms.os(::AnyPlatform) = "any"
17-
nbits(::AnyPlatform) = 64
17+
nbits(::AnyPlatform) = nbits(default_host_platform)
1818
proc_family(::AnyPlatform) = "any"
1919
Base.show(io::IO, ::AnyPlatform) = print(io, "AnyPlatform")
2020

src/Rootfs.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ function choose_shards(p::AbstractPlatform;
631631
return shards
632632
end
633633

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

637637
"""

src/Runner.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default_host_platform
1111
1212
The default host platform in the build environment.
1313
"""
14-
const default_host_platform = Platform("x86_64", "linux"; libc="musl", cxxstring_abi="cxx11")
14+
const default_host_platform = Platform(arch(HostPlatform()), "linux"; libc="musl", cxxstring_abi="cxx11")
1515

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

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

901901
# Set location parameters
902902
"WORKSPACE" => "/workspace",

src/utils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ function get_concrete_platform(platform::AbstractPlatform; kwargs...)
5757
return get_concrete_platform(platform, shards)
5858
end
5959

60-
# XXX: we want the AnyPlatform to look like `x86_64-linux-musl`,
60+
# We want the AnyPlatform to look like `default_host_platform`,
6161
get_concrete_platform(::AnyPlatform, shards::Vector{CompilerShard}) =
6262
get_concrete_platform(default_host_platform, shards)

test/platforms.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ end
3939
@test arch(AnyPlatform()) == "any"
4040
@test repr(AnyPlatform()) == "AnyPlatform"
4141

42-
# In the build environment we want AnyPlatform to look like x86_64-linux-musl
42+
# In the build environment we want AnyPlatform to look like `default_host_platform`
4343
@test get_concrete_platform(
4444
AnyPlatform();
4545
compilers = [:c],

test/runners.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ end
7373
@info("Beginning full shard test... (this can take a while)")
7474
platforms = supported_platforms()
7575
else
76-
platforms = (Platform("x86_64", "linux"; libc="musl"),)
76+
platforms = (default_host_platform,)
7777
end
7878

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

0 commit comments

Comments
 (0)