Skip to content

Commit

Permalink
GH-41061: [C++] Ignore ARROW_USE_MOLD/ARROW_USE_LLD with clang < 12 (#…
Browse files Browse the repository at this point in the history
…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 <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
  • Loading branch information
kou authored Apr 8, 2024
1 parent 84f6ede commit 1343ac7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions cpp/cmake_modules/SetupCxxFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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}"
)
Expand Down

0 comments on commit 1343ac7

Please sign in to comment.