Skip to content
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
10 changes: 5 additions & 5 deletions src/Runner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
return flags
end

function min_macos_version_flag(p::AbstractPlatform)
# Ask compilers to compile for a minimum macOS version
return "-mmacosx-version-min=$(macos_version(p))"
function min_macos_version_flags()
# Ask compilers to compile for a minimum macOS version, targeting that SDK.
return ("-mmacosx-version-min=\${MACOSX_DEPLOYMENT_TARGET}", "-Wl,-sdk_version,\${MACOSX_DEPLOYMENT_TARGET}")
end

function add_system_includedir(flags::Vector{String})
Expand Down Expand Up @@ -405,7 +405,7 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
# `clang` as a linker (and we have no real way to detect that in the wrapper), which will
# cause `clang` to complain about compiler flags being passed in.
"-Wno-unused-command-line-argument",
min_macos_version_flag(p),
min_macos_version_flags()...,
])
end
sanitize_compile_flags!(p, flags)
Expand Down Expand Up @@ -454,7 +454,7 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
if gcc_version.major in (4, 5)
push!(flags, "-Wl,-syslibroot,/opt/$(aatriplet(p))/$(aatriplet(p))/sys-root")
end
push!(flags, min_macos_version_flag(p))
append!(flags, min_macos_version_flags())
return flags
end

Expand Down
26 changes: 26 additions & 0 deletions test/runners.jl
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,32 @@ end
@test split(String(read(iobuff)), "\n")[2] == ""
end
end

@testset "macOS SDK setting" begin
mktempdir() do dir
platform = Platform("x86_64", "macos")
test_script = raw"""
set -e
prog='int main(void) { return 0; }'
echo "${prog}" | clang -x c - -o test-clang
otool -lV test-clang | grep sdk
# Set `MACOSX_DEPLOYMENT_TARGET` to override the value of the SDK
export MACOSX_DEPLOYMENT_TARGET=10.14
echo "${prog}" | gcc -x c - -o test-gcc
otool -lV test-gcc | grep sdk
"""
cmd = `/bin/bash -c "$(test_script)"`
ur = preferred_runner()(dir; platform=platform, allow_unsafe_flags=false)
iobuff = IOBuffer()
@test run(ur, cmd, iobuff; tee_stream=devnull)
seekstart(iobuff)
lines = readlines(iobuff)
# Make sure the SDK for this platform is set to 10.10, instead of other wrong
# values, and that we can set `MACOSX_DEPLOYMENT_TARGET` to control the value.
@test contains(lines[end - 1], r"^ +sdk 10\.10$")
@test contains(lines[end], r"^ +sdk 10\.14$")
end
end
end

@testset "Shards" begin
Expand Down