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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "BinaryBuilderBase"
uuid = "7f725544-6523-48cd-82d1-3fa08ff4056e"
authors = ["Elliot Saba <staticfloat@gmail.com>"]
version = "0.6.10"
version = "0.6.11"

[deps]
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
Expand Down
35 changes: 24 additions & 11 deletions src/Rootfs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -395,12 +395,14 @@ const available_llvm_builds = [
]

"""
gcc_version(p::AbstractPlatform, , GCC_builds::Vector{GCCBuild})
gcc_version(p::AbstractPlatform, , GCC_builds::Vector{GCCBuild};
llvm_version::Union{Nothing,VersionNumber}=nothing)

Returns the closest matching GCC version number for the given particular
platform, from the given set of options. The compiler ABI and the
microarchitecture of the platform will be taken into account. If no match is
found, returns an empty list.
found, returns an empty list. If the keyword argument `llvm_version` is passed,
it is used to filter the version of GCC for FreeBSD platforms.

This method assumes that the compiler ABI of the platform represents a platform
that binaries will be run on, and thus versions are always rounded down; e.g. if
Expand All @@ -409,7 +411,8 @@ the only GCC versions available to be picked from are `4.8.5` and `5.2.0`, it
will return `4.8.5`, as binaries compiled with that version will run on this
platform, whereas binaries compiled with `5.2.0` may not.
"""
function gcc_version(p::AbstractPlatform, GCC_builds::Vector{GCCBuild})
function gcc_version(p::AbstractPlatform, GCC_builds::Vector{GCCBuild};
llvm_version::Union{Nothing,VersionNumber}=nothing)
# First, filter by libgfortran version.
if libgfortran_version(p) !== nothing
GCC_builds = filter(b -> getabi(b).libgfortran_version == libgfortran_version(p), GCC_builds)
Expand All @@ -432,6 +435,16 @@ function gcc_version(p::AbstractPlatform, GCC_builds::Vector{GCCBuild})
GCC_builds = filter(b -> getversion(b) >= v"5", GCC_builds)
end

# LLVMBootstrap 12 needs to be built with GCCBootstrap ≥ 7, see
# <https://github.com/JuliaPackaging/BinaryBuilderBase.jl/pull/112#issuecomment-776940748>.
# However, when building for FreeBSD with LLVMBootstrap 12 we can't use `ld` from
# binutils < 2.26 (which corresponds to GCCBootstrap < 6) to link some object files, see
# <https://github.com/JuliaPackaging/BinaryBuilderBase.jl/issues/158>. The solution is
# to not allow old GCCBootstrap with new versions of LLVMBootstrap for FreeBSD.
if llvm_version !== nothing && Sys.isfreebsd(p) && llvm_version ≥ v"12"
GCC_builds = filter(b -> getversion(b) ≥ v"6", GCC_builds)
end

# Filter the possible GCC versions depending on the microarchitecture
if march(p) in ("avx", "avx2", "neonvfpv4")
# "sandybridge", "haswell", "cortex-a53" introduced in GCC v4.9.0:
Expand Down Expand Up @@ -467,20 +480,20 @@ function select_compiler_versions(p::AbstractPlatform,
preferred_gcc_version::VersionNumber = getversion(GCC_builds[1]),
preferred_llvm_version::VersionNumber = getversion(LLVM_builds[end]),
)
# Determine which GCC/LLVM build we're going to match with this Platform:
filtered_gcc_builds = gcc_version(p, GCC_builds)
if isempty(filtered_gcc_builds)
error("Impossible compiler constraints $(p) upon $(GCC_builds)!")
end

# Determine which GCC/LLVM build we're going to match with this Platform. We need to
# pass the chosen version of LLVM to `gcc_version`, so we first select LLVM, then GCC.
filtered_llvm_builds = llvm_version(p, LLVM_builds)
if isempty(filtered_llvm_builds)
error("Impossible compiler constraints $(p) upon $(LLVM_builds)!")
end
llvmv = select_closest_version(preferred_llvm_version, filtered_llvm_builds)

# Otherwise, choose the version that is closest to our preferred version
filtered_gcc_builds = gcc_version(p, GCC_builds; llvm_version=llvmv)
if isempty(filtered_gcc_builds)
error("Impossible compiler constraints $(p) upon $(GCC_builds)!")
end
gccv = select_closest_version(preferred_gcc_version, filtered_gcc_builds)
llvmv = select_closest_version(preferred_llvm_version, filtered_llvm_builds)

return gccv, llvmv
end

Expand Down
9 changes: 9 additions & 0 deletions test/rootfs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ end
# With no constraints, we should get them all back
@test gcc_version(Platform("x86_64", "linux"), available_gcc_builds) == getversion.(available_gcc_builds)

# Filter for FreeBSD. No version of LLVM is specified, all versions
# should be available
@test gcc_version(Platform("x86_64", "freebsd"), available_gcc_builds) == getversion.(available_gcc_builds)
# With LLVM 11 all versions of GCC are still allowed
@test gcc_version(Platform("x86_64", "freebsd"), available_gcc_builds; llvm_version=v"11") == getversion.(available_gcc_builds)
# With LLVM 12 we can only use GCC 6+
@test gcc_version(Platform("x86_64", "freebsd"), available_gcc_builds; llvm_version=v"12") ==
filter(≥(v"6"), getversion.(available_gcc_builds))

# libgfortran v3 and libstdcxx 22 restrict us to only v4.8, v5.2 and v6.1
p = Platform("x86_64", "linux"; libgfortran_version=v"3", libstdcxx_version=v"3.4.22")
@test gcc_version(p, available_gcc_builds) == [v"4.8.5", v"5.2.0", v"6.1.0"]
Expand Down