@@ -395,12 +395,14 @@ const available_llvm_builds = [
395
395
]
396
396
397
397
"""
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)
399
400
400
401
Returns the closest matching GCC version number for the given particular
401
402
platform, from the given set of options. The compiler ABI and the
402
403
microarchitecture 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.
404
406
405
407
This method assumes that the compiler ABI of the platform represents a platform
406
408
that 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
409
411
will return `4.8.5`, as binaries compiled with that version will run on this
410
412
platform, whereas binaries compiled with `5.2.0` may not.
411
413
"""
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 )
413
416
# First, filter by libgfortran version.
414
417
if libgfortran_version (p) != = nothing
415
418
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})
432
435
GCC_builds = filter (b -> getversion (b) >= v " 5" , GCC_builds)
433
436
end
434
437
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
+
435
448
# Filter the possible GCC versions depending on the microarchitecture
436
449
if march (p) in (" avx" , " avx2" , " neonvfpv4" )
437
450
# "sandybridge", "haswell", "cortex-a53" introduced in GCC v4.9.0:
@@ -467,20 +480,20 @@ function select_compiler_versions(p::AbstractPlatform,
467
480
preferred_gcc_version:: VersionNumber = getversion (GCC_builds[1 ]),
468
481
preferred_llvm_version:: VersionNumber = getversion (LLVM_builds[end ]),
469
482
)
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.
476
485
filtered_llvm_builds = llvm_version (p, LLVM_builds)
477
486
if isempty (filtered_llvm_builds)
478
487
error (" Impossible compiler constraints $(p) upon $(LLVM_builds) !" )
479
488
end
489
+ llvmv = select_closest_version (preferred_llvm_version, filtered_llvm_builds)
480
490
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
482
495
gccv = select_closest_version (preferred_gcc_version, filtered_gcc_builds)
483
- llvmv = select_closest_version (preferred_llvm_version, filtered_llvm_builds)
496
+
484
497
return gccv, llvmv
485
498
end
486
499
0 commit comments