[llvm] d5e91ca - [CMake] Limit -gsplit-dwarf option to C and C++ compilers
via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 15 09:59:05 PDT 2023
Author: George Lyon
Date: 2023-10-15T19:59:00+03:00
New Revision: d5e91ca5633e630f97777d96103aba3fa1247080
URL: https://github.com/llvm/llvm-project/commit/d5e91ca5633e630f97777d96103aba3fa1247080
DIFF: https://github.com/llvm/llvm-project/commit/d5e91ca5633e630f97777d96103aba3fa1247080.diff
LOG: [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++).
Added:
Modified:
llvm/cmake/modules/HandleLLVMOptions.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index c5142c9e660fba4..19cb881adc3fa95 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1007,7 +1007,7 @@ if (LLVM_USE_SPLIT_DWARF AND
# 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)
+ add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-gsplit-dwarf>)
include(LLVMCheckLinkerFlag)
llvm_check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX)
append_if(LINKER_SUPPORTS_GDB_INDEX "-Wl,--gdb-index"
More information about the llvm-commits
mailing list