mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
If we're on a system that has ld.gold 2.35 or earlier, we want to use lld instead because otherwise we end up with duplicate sections in the output. rdar://123504095
19 lines
697 B
CMake
19 lines
697 B
CMake
# Find the version of ld.gold, if installed.
|
|
#
|
|
# Versions prior to 2.36 break Swift programs because they won't coalesce
|
|
# sections with different SHF_GNU_RETAIN flags.
|
|
function(get_gold_version result_var_name)
|
|
find_program(gold_executable "ld.gold")
|
|
if(gold_executable)
|
|
execute_process(
|
|
COMMAND "${gold_executable}" "--version"
|
|
COMMAND "head" "-n" "1"
|
|
COMMAND "sed" "-e" "s/^.* (\\([^)]*\\)).*$/\\1/g;s/.* \\([0-9][0-9]*\\(\\.[0-9][0-9]*\\)*\\).*/\\1/g"
|
|
OUTPUT_VARIABLE gold_version
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
set("${result_var_name}" "${gold_version}" PARENT_SCOPE)
|
|
else()
|
|
set("${result_var_name}" "" PARENT_SCOPE)
|
|
endif()
|
|
endfunction()
|