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
endif()
endif()
-# Turn on -gsplit-dwarf if requested
-if(LLVM_USE_SPLIT_DWARF)
- add_definitions("-gsplit-dwarf")
+# Turn on -gsplit-dwarf if requested in debug builds.
+if (LLVM_USE_SPLIT_DWARF AND
+ ((uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") OR
+ (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")))
+ # Limit to clang and gcc so far. Add compilers supporting this option.
+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
+ CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ add_compile_options(-gsplit-dwarf)
+ endif()
endif()
add_definitions( -D__STDC_CONSTANT_MACROS )