Skip to content

Commit

Permalink
Shake out some assumptions about architecture of host platform
Browse files Browse the repository at this point in the history
  • Loading branch information
giordano committed Nov 6, 2021
1 parent 73da943 commit ac9acaf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 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/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)

0 comments on commit ac9acaf

Please sign in to comment.