@@ -395,12 +395,14 @@ const available_llvm_builds = [
395395]
396396
397397"""
398- gcc_version(p::AbstractPlatform, , GCC_builds::Vector{GCCBuild})
398+ gcc_version(p::AbstractPlatform, , GCC_builds::Vector{GCCBuild};
399+ llvm_version::Union{Nothing,VersionNumber}=nothing)
399400
400401Returns the closest matching GCC version number for the given particular
401402platform, from the given set of options. The compiler ABI and the
402403microarchitecture of the platform will be taken into account. If no match is
403- found, returns an empty list.
404+ found, returns an empty list. If the keyword argument `llvm_version` is passed,
405+ it is used to filter the version of GCC for FreeBSD platforms.
404406
405407This method assumes that the compiler ABI of the platform represents a platform
406408that binaries will be run on, and thus versions are always rounded down; e.g. if
@@ -409,7 +411,8 @@ the only GCC versions available to be picked from are `4.8.5` and `5.2.0`, it
409411will return `4.8.5`, as binaries compiled with that version will run on this
410412platform, whereas binaries compiled with `5.2.0` may not.
411413"""
412- function gcc_version (p:: AbstractPlatform , GCC_builds:: Vector{GCCBuild} )
414+ function gcc_version (p:: AbstractPlatform , GCC_builds:: Vector{GCCBuild} ;
415+ llvm_version:: Union{Nothing,VersionNumber} = nothing )
413416 # First, filter by libgfortran version.
414417 if libgfortran_version (p) != = nothing
415418 GCC_builds = filter (b -> getabi (b). libgfortran_version == libgfortran_version (p), GCC_builds)
@@ -432,6 +435,16 @@ function gcc_version(p::AbstractPlatform, GCC_builds::Vector{GCCBuild})
432435 GCC_builds = filter (b -> getversion (b) >= v " 5" , GCC_builds)
433436 end
434437
438+ # LLVMBootstrap 12 needs to be built with GCCBootstrap ≥ 7, see
439+ # <https://github.com/JuliaPackaging/BinaryBuilderBase.jl/pull/112#issuecomment-776940748>.
440+ # However, when building for FreeBSD with LLVMBootstrap 12 we can't use `ld` from
441+ # binutils < 2.26 (which corresponds to GCCBootstrap < 6) to link some object files, see
442+ # <https://github.com/JuliaPackaging/BinaryBuilderBase.jl/issues/158>. The solution is
443+ # to not allow old GCCBootstrap with new versions of LLVMBootstrap for FreeBSD.
444+ if llvm_version != = nothing && Sys. isfreebsd (p) && llvm_version ≥ v " 12"
445+ GCC_builds = filter (b -> getversion (b) ≥ v " 6" , GCC_builds)
446+ end
447+
435448 # Filter the possible GCC versions depending on the microarchitecture
436449 if march (p) in (" avx" , " avx2" , " neonvfpv4" )
437450 # "sandybridge", "haswell", "cortex-a53" introduced in GCC v4.9.0:
@@ -467,20 +480,20 @@ function select_compiler_versions(p::AbstractPlatform,
467480 preferred_gcc_version:: VersionNumber = getversion (GCC_builds[1 ]),
468481 preferred_llvm_version:: VersionNumber = getversion (LLVM_builds[end ]),
469482 )
470- # Determine which GCC/LLVM build we're going to match with this Platform:
471- filtered_gcc_builds = gcc_version (p, GCC_builds)
472- if isempty (filtered_gcc_builds)
473- error (" Impossible compiler constraints $(p) upon $(GCC_builds) !" )
474- end
475-
483+ # Determine which GCC/LLVM build we're going to match with this Platform. We need to
484+ # pass the chosen version of LLVM to `gcc_version`, so we first select LLVM, then GCC.
476485 filtered_llvm_builds = llvm_version (p, LLVM_builds)
477486 if isempty (filtered_llvm_builds)
478487 error (" Impossible compiler constraints $(p) upon $(LLVM_builds) !" )
479488 end
489+ llvmv = select_closest_version (preferred_llvm_version, filtered_llvm_builds)
480490
481- # Otherwise, choose the version that is closest to our preferred version
491+ filtered_gcc_builds = gcc_version (p, GCC_builds; llvm_version= llvmv)
492+ if isempty (filtered_gcc_builds)
493+ error (" Impossible compiler constraints $(p) upon $(GCC_builds) !" )
494+ end
482495 gccv = select_closest_version (preferred_gcc_version, filtered_gcc_builds)
483- llvmv = select_closest_version (preferred_llvm_version, filtered_llvm_builds)
496+
484497 return gccv, llvmv
485498end
486499
0 commit comments