Skip to content

Commit a51e9a1

Browse files
committed
Merge branch 'master' into ib/no_ctx
2 parents 6119de1 + c25f6ed commit a51e9a1

File tree

7 files changed

+1064
-277
lines changed

7 files changed

+1064
-277
lines changed

Artifacts.toml

Lines changed: 918 additions & 214 deletions
Large diffs are not rendered by default.

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "BinaryBuilderBase"
22
uuid = "7f725544-6523-48cd-82d1-3fa08ff4056e"
33
authors = ["Elliot Saba <[email protected]>"]
4-
version = "1.35.2"
4+
version = "1.37.0"
55

66
[deps]
77
Bzip2_jll = "6e34b625-4abd-537c-b88f-471c36dfa7a0"

src/BuildToolchains.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ function toolchain_file(bt::CMake, p::AbstractPlatform, host_platform::AbstractP
9494
set(CMAKE_SYSROOT /opt/$(aatarget)/$(aatarget)/sys-root/)
9595
"""
9696
end
97+
98+
if arch(p) == "riscv64"
99+
# RISCV libraries are in a subdirectory corresponding to the ABI of the processor
100+
file *= """
101+
set(CMAKE_SYSTEM_LIBRARY_PATH \${CMAKE_SYSROOT}/usr/lib64/lp64d)
102+
"""
103+
end
104+
97105
file *= """
98106
set(CMAKE_INSTALL_PREFIX \$ENV{prefix})
99107

src/Rootfs.jl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,11 @@ const available_gcc_builds = [
407407
# GCCBuild(v"11.0.0-iains", (libgfortran_version = v"5", libstdcxx_version = v"3.4.28", cxxstring_abi = "cxx11")),
408408
GCCBuild(v"12.0.1-iains", (libgfortran_version = v"5", libstdcxx_version = v"3.4.29", cxxstring_abi = "cxx11")),
409409
]
410+
411+
# Since we read the Artifacts.toml at compile time, we need to make sure that we-reprecompile
412+
# if the file changes - let Julia know.
413+
Base.include_dependency(joinpath(dirname(@__DIR__), "Artifacts.toml"))
414+
410415
const available_llvm_builds = LLVMBuild.(get_available_builds("LLVMBootstrap."))
411416

412417
const available_go_builds = GoBuild.(get_available_builds("Go."))
@@ -469,9 +474,9 @@ function gcc_version(p::AbstractPlatform,
469474
GCC_builds = filter(b -> getversion(b) v"6", GCC_builds)
470475
end
471476

472-
# We don't have GCC 6 or older for FreeBSD AArch64
477+
# We don't have GCC 8 or older for FreeBSD 14.1+ on AArch64
473478
if Sys.isfreebsd(p) && arch(p) == "aarch64"
474-
GCC_builds = filter(b -> getversion(b) v"7", GCC_builds)
479+
GCC_builds = filter(b -> getversion(b) v"9", GCC_builds)
475480
end
476481

477482
# We only use GCC 14 or newer for riscv64.
@@ -576,7 +581,7 @@ function choose_shards(p::AbstractPlatform;
576581
compilers::Vector{Symbol} = [:c],
577582
# We always just use the latest Rootfs embedded within our Artifacts.toml
578583
rootfs_build::VersionNumber=last(BinaryBuilderBase.get_available_builds("Rootfs")),
579-
ps_build::VersionNumber=v"2024.08.10",
584+
ps_build::VersionNumber=v"2025.02.15",
580585
GCC_builds::Vector{GCCBuild}=available_gcc_builds,
581586
LLVM_builds::Vector{LLVMBuild}=available_llvm_builds,
582587
Rust_builds::Vector{RustBuild}=available_rust_builds,
@@ -809,10 +814,8 @@ function expand_gfortran_versions(platform::AbstractPlatform)
809814
# If this is an platform that has limited GCC support (such as aarch64-apple-darwin),
810815
# the libgfortran versions we can expand to are similarly limited.
811816
local libgfortran_versions
812-
if Sys.isapple(platform) && arch(platform) == "aarch64"
817+
if Sys.isbsd(platform) && arch(platform) == "aarch64"
813818
libgfortran_versions = [v"5"]
814-
elseif Sys.isfreebsd(platform) && arch(platform) == "aarch64"
815-
libgfortran_versions = [v"4", v"5"]
816819
elseif arch(platform) == "riscv64"
817820
# We don't have older GCC versions
818821
libgfortran_versions = [v"5"]

src/Runner.jl

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,12 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
382382
return flags
383383
end
384384

385-
function min_macos_version_flags()
386-
# Ask compilers to compile for a minimum macOS version, targeting that SDK.
387-
return ("-mmacosx-version-min=\${MACOSX_DEPLOYMENT_TARGET}", "-Wl,-sdk_version,\${MACOSX_DEPLOYMENT_TARGET}")
385+
# Ask compilers to compile for a minimum macOS version, targeting that SDK.
386+
function min_macos_version_compiler_flags()
387+
return ("-mmacosx-version-min=\${MACOSX_DEPLOYMENT_TARGET}",)
388+
end
389+
function min_macos_version_linker_flags()
390+
return ("-Wl,-sdk_version,\${MACOSX_DEPLOYMENT_TARGET}",)
388391
end
389392

390393
function add_system_includedir(flags::Vector{String})
@@ -455,9 +458,8 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
455458
])
456459

457460
if Sys.isapple(p)
458-
macos_version_flags = clang_use_lld ? (min_macos_version_flags()[1],) : min_macos_version_flags()
459461
append!(flags, String[
460-
macos_version_flags...,
462+
min_macos_version_compiler_flags()...,
461463
])
462464
end
463465

@@ -529,10 +531,14 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
529531
end
530532
sanitize_link_flags!(p, flags)
531533

532-
# On macos, we need to pass `-headerpad_max_install_names` so that we have lots of space
533-
# for `install_name_tool` shenanigans during audit fixups.
534534
if Sys.isapple(p)
535+
# On macos, we need to pass `-headerpad_max_install_names` so that we have lots
536+
# of space for `install_name_tool` shenanigans during audit fixups.
535537
push!(flags, "-headerpad_max_install_names")
538+
if !clang_use_lld
539+
# The `-sdk_version` flag is not implemented in lld yet.
540+
append!(flags, min_macos_version_linker_flags())
541+
end
536542
end
537543
return flags
538544
end
@@ -544,7 +550,7 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
544550
if gcc_version.major in (4, 5)
545551
push!(flags, "-Wl,-syslibroot,/opt/$(aatriplet(p))/$(aatriplet(p))/sys-root")
546552
end
547-
append!(flags, min_macos_version_flags())
553+
append!(flags, min_macos_version_compiler_flags())
548554
return flags
549555
end
550556

@@ -617,6 +623,7 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
617623
])
618624
elseif Sys.isapple(p)
619625
push!(flags, "-headerpad_max_install_names")
626+
append!(flags, min_macos_version_linker_flags())
620627
elseif Sys.iswindows(p) && gcc_version v"5"
621628
# Do not embed timestamps, for reproducibility:
622629
# https://github.com/JuliaPackaging/BinaryBuilder.jl/issues/1232
@@ -1037,10 +1044,47 @@ function generate_compiler_wrappers!(platform::AbstractPlatform; bin_path::Abstr
10371044
# `xcrun` is another macOS-specific tool, which is occasionally needed to run some
10381045
# commands, for example for the CGO linker. Ref:
10391046
# <https://github.com/JuliaPackaging/Yggdrasil/pull/2962>.
1047+
# Cf. <https://www.unix.com/man-page/osx/1/xcrun/>
10401048
xcrun_path = joinpath(bin_path, triplet(platform), "xcrun")
10411049
write(xcrun_path, """
10421050
#!/bin/sh
1043-
exec "\${@}"
1051+
1052+
sdk_path="\${SDKROOT}"
1053+
1054+
show_sdk_path() {
1055+
echo "\${1}"
1056+
}
1057+
1058+
show_sdk_version() {
1059+
plistutil -f xml -i "\${1}"/SDKSettings.plist \\
1060+
| grep -A1 '<key>Version</key>' \\
1061+
| tail -n1 \\
1062+
| sed -E -e 's/\\s*<string>([^<]+)<\\/string>\\s*/\\1/'
1063+
}
1064+
1065+
while [ "\${#}" -gt 0 ]; do
1066+
case "\${1}" in
1067+
--sdk)
1068+
sdk_path="\${2}"
1069+
shift 2
1070+
;;
1071+
--show-sdk-path)
1072+
show_sdk_path "\${sdk_path}"
1073+
shift
1074+
;;
1075+
--show-sdk-version)
1076+
show_sdk_version "\${sdk_path}"
1077+
shift
1078+
;;
1079+
*)
1080+
break
1081+
;;
1082+
esac
1083+
done
1084+
1085+
if [ "\${#}" -gt 0 ]; then
1086+
exec "\${@}"
1087+
fi
10441088
""")
10451089
chmod(xcrun_path, 0o775)
10461090
end
@@ -1294,6 +1338,7 @@ function platform_envs(platform::AbstractPlatform, src_name::AbstractString;
12941338
if Sys.isapple(platform)
12951339
mapping["LD"] = "/opt/bin/$(triplet(platform))/ld"
12961340
mapping["MACOSX_DEPLOYMENT_TARGET"] = macos_version(platform)
1341+
mapping["SDKROOT"] = "/opt/$(aatriplet(platform))/$(aatriplet(platform))/sys-root"
12971342
end
12981343

12991344
# There is no broad agreement on what host compilers should be called,

test/rootfs.jl

Lines changed: 69 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ using BinaryBuilderBase: RustBuild, CompilerShard
2626
Platform("x86_64", "macos"; libgfortran_version=v"5"),
2727
Platform("aarch64", "macos"; libgfortran_version=v"5"),
2828
]
29-
@test expand_gfortran_versions(Platform("aarch64", "freebsd")) == [
30-
Platform("aarch64", "freebsd"; libgfortran_version=v"4"),
31-
Platform("aarch64", "freebsd"; libgfortran_version=v"5"),
32-
]
29+
@test expand_gfortran_versions(Platform("aarch64", "freebsd")) ==
30+
[Platform("aarch64", "freebsd"; libgfortran_version=v"5")]
3331
@test expand_gfortran_versions([Platform("x86_64", "linux"; sanitize="memory")]) ==
3432
[Platform("x86_64", "linux"; sanitize="memory")]
3533
@test expand_gfortran_versions(Platform[]) isa Vector{Platform}
@@ -178,9 +176,9 @@ end
178176
# With LLVM 12 we can only use GCC 6+
179177
@test gcc_version(Platform("x86_64", "freebsd"), available_gcc_builds; llvm_version=v"12") ==
180178
filter((v"6"), getversion.(available_gcc_builds))
181-
# We can only use GCC 7+ on AArch64
179+
# We can only use GCC 9+ on AArch64
182180
@test gcc_version(Platform("aarch64", "freebsd"), available_gcc_builds) ==
183-
filter((v"7"), getversion.(available_gcc_builds))
181+
filter((v"9"), getversion.(available_gcc_builds))
184182

185183
# libgfortran v3 and libstdcxx 22 restrict us to only v4.8, v5.2 and v6.1
186184
p = Platform("x86_64", "linux"; libgfortran_version=v"3", libstdcxx_version=v"3.4.22")
@@ -219,52 +217,79 @@ end
219217

220218
@testset "Compiler wrappers" begin
221219
platform = Platform("x86_64", "linux"; libc="musl")
222-
mktempdir() do bin_path
223-
platform_bin_dir = joinpath(bin_path, triplet(platform))
224-
generate_compiler_wrappers!(platform; bin_path = bin_path)
225-
# Make sure the C++ string ABI is not set
226-
@test !occursin("-D_GLIBCXX_USE_CXX11_ABI", read(joinpath(platform_bin_dir, "gcc"), String))
227-
# Make sure gfortran doesn't uses ccache when BinaryBuilderBase.use_ccache is true
228-
BinaryBuilderBase.use_ccache[] && @test !occursin("ccache", read(joinpath(platform_bin_dir, "gfortran"), String))
220+
@testset "$(triplet(platform))" begin
221+
mktempdir() do bin_path
222+
platform_bin_dir = joinpath(bin_path, triplet(platform))
223+
generate_compiler_wrappers!(platform; bin_path = bin_path)
224+
# Make sure the C++ string ABI is not set
225+
@test !occursin("-D_GLIBCXX_USE_CXX11_ABI", read(joinpath(platform_bin_dir, "gcc"), String))
226+
# Make sure gfortran doesn't uses ccache when BinaryBuilderBase.use_ccache is true
227+
BinaryBuilderBase.use_ccache[] && @test !occursin("ccache", read(joinpath(platform_bin_dir, "gfortran"), String))
228+
end
229229
end
230230
platform = Platform("x86_64", "linux"; libc="musl", cxxstring_abi="cxx03")
231-
mktempdir() do bin_path
232-
platform_bin_dir = joinpath(bin_path, triplet(platform))
233-
generate_compiler_wrappers!(platform; bin_path = bin_path)
234-
gcc = read(joinpath(platform_bin_dir, "gcc"), String)
235-
# Make sure the C++ string ABI is set as expected
236-
@test occursin("-D_GLIBCXX_USE_CXX11_ABI=0", gcc)
237-
# Make sure the unsafe flags check is there
238-
@test occursin("You used one or more of the unsafe flags", gcc)
231+
@testset "$(triplet(platform))" begin
232+
mktempdir() do bin_path
233+
platform_bin_dir = joinpath(bin_path, triplet(platform))
234+
generate_compiler_wrappers!(platform; bin_path = bin_path)
235+
gcc = read(joinpath(platform_bin_dir, "gcc"), String)
236+
# Make sure the C++ string ABI is set as expected
237+
@test occursin("-D_GLIBCXX_USE_CXX11_ABI=0", gcc)
238+
# Make sure the unsafe flags check is there
239+
@test occursin("You used one or more of the unsafe flags", gcc)
240+
end
239241
end
240242
platform = Platform("x86_64", "linux"; libc="musl", cxxstring_abi="cxx11")
241-
mktempdir() do bin_path
242-
platform_bin_dir = joinpath(bin_path, triplet(platform))
243-
generate_compiler_wrappers!(platform; bin_path = bin_path, allow_unsafe_flags = true)
244-
gcc = read(joinpath(platform_bin_dir, "gcc"), String)
245-
# Make sure the C++ string ABI is set as expected
246-
@test occursin("-D_GLIBCXX_USE_CXX11_ABI=1", gcc)
247-
# Make sure the unsafe flags check is not there in this case
248-
@test !occursin("You used one or more of the unsafe flags", gcc)
243+
@testset "$(triplet(platform))" begin
244+
mktempdir() do bin_path
245+
platform_bin_dir = joinpath(bin_path, triplet(platform))
246+
generate_compiler_wrappers!(platform; bin_path = bin_path, allow_unsafe_flags = true)
247+
gcc = read(joinpath(platform_bin_dir, "gcc"), String)
248+
# Make sure the C++ string ABI is set as expected
249+
@test occursin("-D_GLIBCXX_USE_CXX11_ABI=1", gcc)
250+
# Make sure the unsafe flags check is not there in this case
251+
@test !occursin("You used one or more of the unsafe flags", gcc)
252+
end
253+
end
254+
platform = Platform("aarch64", "macos")
255+
@testset "$(triplet(platform))" begin
256+
mktempdir() do bin_path
257+
platform_bin_dir = joinpath(bin_path, triplet(platform))
258+
generate_compiler_wrappers!(platform; bin_path = bin_path, gcc_version = v"4")
259+
if Sys.isunix()
260+
cd(platform_bin_dir) do
261+
@test readchomp(`./xcrun echo foo`) == "foo"
262+
withenv("SDKROOT" => "/bar") do
263+
@test readchomp(`./xcrun --show-sdk-path`) == "/bar"
264+
@test readchomp(`./xcrun --show-sdk-path echo foo`) == "/bar\nfoo"
265+
@test readchomp(`./xcrun --sdk /baz --show-sdk-path echo foo`) == "/baz\nfoo"
266+
end
267+
end
268+
end
269+
end
249270
end
250271
platform = Platform("x86_64", "freebsd")
251-
mktempdir() do bin_path
252-
platform_bin_dir = joinpath(bin_path, triplet(platform))
253-
generate_compiler_wrappers!(platform; bin_path = bin_path, compilers = [:c, :rust, :go])
254-
clang = read(joinpath(platform_bin_dir, "clang"), String)
255-
# Check link flags
256-
@test occursin("-L/opt/$(triplet(platform))/$(triplet(platform))/lib", clang)
257-
# Other compilers
258-
@test occursin("GOOS=\"freebsd\"", read(joinpath(platform_bin_dir, "go"), String))
259-
@test occursin("--target=x86_64-unknown-freebsd", read(joinpath(platform_bin_dir, "rustc"), String))
272+
@testset "$(triplet(platform))" begin
273+
mktempdir() do bin_path
274+
platform_bin_dir = joinpath(bin_path, triplet(platform))
275+
generate_compiler_wrappers!(platform; bin_path = bin_path, compilers = [:c, :rust, :go])
276+
clang = read(joinpath(platform_bin_dir, "clang"), String)
277+
# Check link flags
278+
@test occursin("-L/opt/$(triplet(platform))/$(triplet(platform))/lib", clang)
279+
# Other compilers
280+
@test occursin("GOOS=\"freebsd\"", read(joinpath(platform_bin_dir, "go"), String))
281+
@test occursin("--target=x86_64-unknown-freebsd", read(joinpath(platform_bin_dir, "rustc"), String))
282+
end
260283
end
261284
platform = Platform("x86_64", "linux"; libc="glibc", cxxstring_abi="cxx11")
262-
mktempdir() do bin_path
263-
platform_bin_dir = joinpath(bin_path, triplet(platform))
264-
generate_compiler_wrappers!(platform; bin_path = bin_path, compilers = [:c], gcc_version=v"5")
265-
clang = read(joinpath(platform_bin_dir, "clang"), String)
266-
# Check link flags
267-
@test occursin("-L/opt/$(aatriplet(platform))/lib/gcc/opt/$(aatriplet(platform))/lib/gcc", clang)
285+
@testset "$(triplet(platform))" begin
286+
mktempdir() do bin_path
287+
platform_bin_dir = joinpath(bin_path, triplet(platform))
288+
generate_compiler_wrappers!(platform; bin_path = bin_path, compilers = [:c], gcc_version=v"5")
289+
clang = read(joinpath(platform_bin_dir, "clang"), String)
290+
# Check link flags
291+
@test occursin("-L/opt/$(aatriplet(platform))/lib/gcc/opt/$(aatriplet(platform))/lib/gcc", clang)
292+
end
268293
end
269294
end
270295
end

test/runners.jl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -458,12 +458,14 @@ end
458458
platform = Platform("x86_64", "macos")
459459
test_script = raw"""
460460
set -e
461-
prog='int main(void) { return 0; }'
462-
echo "${prog}" | clang -x c - -o test-clang
461+
echo 'int main(void) { return 0; }' > test.c
462+
clang -Wall -Werror -Werror=unused-command-line-argument test.c -c -o test-clang.o
463+
clang -Wall -Werror -Werror=unused-command-line-argument test-clang.o -o test-clang
463464
otool -lV test-clang | grep sdk
464465
# Set `MACOSX_DEPLOYMENT_TARGET` to override the value of the SDK
465466
export MACOSX_DEPLOYMENT_TARGET=10.14
466-
echo "${prog}" | gcc -x c - -o test-gcc
467+
gcc -Wall -Werror test.c -c -o test-gcc.o
468+
gcc -Wall -Werror test-gcc.o -o test-gcc
467469
otool -lV test-gcc | grep sdk
468470
"""
469471
cmd = `/bin/bash -c "$(test_script)"`

0 commit comments

Comments
 (0)