Skip to content

Commit d5e91ca

Browse files
authored
[CMake] Limit -gsplit-dwarf option to C and C++ compilers
Currently, If the C or C++ compiler supports the `-gsplit-dwarf` option it is added to _all_ compilers. If a project decides to use another language, such as Swift, this option will be sent to that compiler as well, regardless whether that compiler supports it or not (Swift doesnot). This patch uses [generator expressions](https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html) to limit the `-gsplit-dwarf` option to only those compilers that support it (C and C++).
1 parent 6dfea56 commit d5e91ca

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/cmake/modules/HandleLLVMOptions.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ if (LLVM_USE_SPLIT_DWARF AND
10071007
# Limit to clang and gcc so far. Add compilers supporting this option.
10081008
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
10091009
CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
1010-
add_compile_options(-gsplit-dwarf)
1010+
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-gsplit-dwarf>)
10111011
include(LLVMCheckLinkerFlag)
10121012
llvm_check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX)
10131013
append_if(LINKER_SUPPORTS_GDB_INDEX "-Wl,--gdb-index"

0 commit comments

Comments
 (0)