From 1343ac74aad59181ff0322e35d42f337edcc1afc Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Mon, 8 Apr 2024 18:29:07 +0900 Subject: [PATCH] GH-41061: [C++] Ignore ARROW_USE_MOLD/ARROW_USE_LLD with clang < 12 (#41062) ### Rationale for this change `--ld-path` is available since clang 12 or later. ### What changes are included in this PR? Ignore `ARROW_USE_MOLD`/`ARROW_USE_LLD` with clang < 12. ### Are these changes tested? Yes. ### Are there any user-facing changes? Yes. * GitHub Issue: #41061 Authored-by: Sutou Kouhei Signed-off-by: Sutou Kouhei --- cpp/cmake_modules/SetupCxxFlags.cmake | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/cpp/cmake_modules/SetupCxxFlags.cmake b/cpp/cmake_modules/SetupCxxFlags.cmake index 3e580dfc109cf..d56609c123968 100644 --- a/cpp/cmake_modules/SetupCxxFlags.cmake +++ b/cpp/cmake_modules/SetupCxxFlags.cmake @@ -640,19 +640,23 @@ if(NOT WIN32 AND NOT APPLE) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12.1.0") set(MOLD_LINKER_FLAGS "-fuse-ld=mold") - message(STATUS "Using optional mold linker") else() message(STATUS "Need GCC 12.1.0 or later to use mold linker: ${CMAKE_CXX_COMPILER_VERSION}" ) endif() elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set(MOLD_LINKER_FLAGS "--ld-path=${LD_MOLD}") - message(STATUS "Using optional mold linker") + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12.0.0") + set(MOLD_LINKER_FLAGS "--ld-path=${LD_MOLD}") + else() + message(STATUS "Need clang 12.0.0 or later to use mold linker: ${CMAKE_CXX_COMPILER_VERSION}" + ) + endif() else() message(STATUS "Using the default linker because compiler doesn't support mold: ${CMAKE_CXX_COMPILER_ID}" ) endif() if(MOLD_LINKER_FLAGS) + message(STATUS "Using optional mold linker") string(APPEND CMAKE_EXE_LINKER_FLAGS " ${MOLD_LINKER_FLAGS}") string(APPEND CMAKE_MODULE_LINKER_FLAGS " ${MOLD_LINKER_FLAGS}") string(APPEND CMAKE_SHARED_LINKER_FLAGS " ${MOLD_LINKER_FLAGS}") @@ -675,7 +679,12 @@ if(ARROW_USE_LLD) ) endif() elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set(LLD_LINKER_FLAGS "--ld-path=${LD_LLD}") + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12.0.0") + set(LLD_LINKER_FLAGS "--ld-path=${LD_LLD}") + else() + message(STATUS "Need clang 12.0.0 or later to use LLD linker: ${CMAKE_CXX_COMPILER_VERSION}" + ) + endif() else() message(STATUS "Using the default linker because compiler doesn't support LLD: ${CMAKE_CXX_COMPILER_ID}" )