Skip to content

Commit 1a52d3d

Browse files
committed
[cmake] Fix LLVM_USE_SPLIT_DWARF
Summary: - Add `-gsplit-dwarf` as an option instead of a definition. - Only add that option on compilers supporting dwarf splitting, such as clang and gcc. Reviewers: echristo, pcc Subscribers: mgorny, aprantl, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D75328
1 parent a1f3eb2 commit 1a52d3d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

llvm/cmake/modules/HandleLLVMOptions.cmake

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,9 +746,15 @@ if(LLVM_USE_SANITIZER)
746746
endif()
747747
endif()
748748

749-
# Turn on -gsplit-dwarf if requested
750-
if(LLVM_USE_SPLIT_DWARF)
751-
add_definitions("-gsplit-dwarf")
749+
# Turn on -gsplit-dwarf if requested in debug builds.
750+
if (LLVM_USE_SPLIT_DWARF AND
751+
((uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") OR
752+
(uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")))
753+
# Limit to clang and gcc so far. Add compilers supporting this option.
754+
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
755+
CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
756+
add_compile_options(-gsplit-dwarf)
757+
endif()
752758
endif()
753759

754760
add_definitions( -D__STDC_CONSTANT_MACROS )

0 commit comments

Comments
 (0)