diff --git a/External/SPEC/CINT2000/186.crafty/CMakeLists.txt b/External/SPEC/CINT2000/186.crafty/CMakeLists.txt --- a/External/SPEC/CINT2000/186.crafty/CMakeLists.txt +++ b/External/SPEC/CINT2000/186.crafty/CMakeLists.txt @@ -26,7 +26,7 @@ list(APPEND CPPFLAGS -DHAS_LONGLONG) endif() -list(APPEND LDFLAGS -Wl,-zmuldefs) +list(APPEND LDFLAGS ${LD_MULTIDEF_FLAG}) set(SourceNames attacks.c diff --git a/External/SPEC/CINT2000/300.twolf/CMakeLists.txt b/External/SPEC/CINT2000/300.twolf/CMakeLists.txt --- a/External/SPEC/CINT2000/300.twolf/CMakeLists.txt +++ b/External/SPEC/CINT2000/300.twolf/CMakeLists.txt @@ -1,6 +1,6 @@ list(APPEND CPPFLAGS -DHAVE_SIGNED_CHAR) list(APPEND LDFLAGS -lm) -list(APPEND LDFLAGS -Wl,-zmuldefs) +list(APPEND LDFLAGS ${LD_MULTIDEF_FLAG}) list(APPEND CFLAGS -Wno-return-type) macro(test_input run_type) diff --git a/External/SPEC/SpecCPU2000.cmake b/External/SPEC/SpecCPU2000.cmake --- a/External/SPEC/SpecCPU2000.cmake +++ b/External/SPEC/SpecCPU2000.cmake @@ -1,4 +1,5 @@ include(External) +include(CheckCSourceCompiles) llvm_externals_find(TEST_SUITE_SPEC2000_ROOT "speccpu2000" "SPEC CPU2000") if(TEST_SUITE_SPEC2000_ROOT) # SPEC supports three "run types": ref, train and test @@ -33,4 +34,18 @@ function(llvm_test_data_spec_default target) llvm_test_data_spec(${target} data) endfunction() + + function(check_supports_zmuldefs) + # Does not check whether the option has an effect. + # -z options are usually ignored if the particular option. + # Alternative option is --allow-multiple-definition + set(CMAKE_REQUIRED_LINK_OPTIONS "-Wl,-zmuldefs") + check_c_source_compiles("int main() { return 0; };" LINKER_SUPPORTS_ZMULDEFS) + endfunction() + + check_supports_zmuldefs() + set(LD_MULTIDEF_FLAG) + if(LINKER_SUPPORTS_ZMULDEFS) + set(LD_MULTIDEF_FLAG "-Wl,-zmuldefs") + endif() endif()