Index: cmake/modules/AddLLVM.cmake =================================================================== --- cmake/modules/AddLLVM.cmake +++ cmake/modules/AddLLVM.cmake @@ -1389,10 +1389,18 @@ endif() if(NOT LLVM_EXTERNALIZE_DEBUGINFO_SKIP_STRIP) - set(strip_command COMMAND xcrun strip -Sxl $) + if(APPLE) + set(strip_command COMMAND xcrun strip -Sxl $) + else() + set(strip_command COMMAND strip -gx $) + endif() endif() if(APPLE) + if(NOT LLVM_EXTERNALIZE_DEBUGINFO_SKIP_STRIP) + set(strip_command COMMAND xcrun strip -Sxl $) + endif() + if(CMAKE_CXX_FLAGS MATCHES "-flto" OR CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE} MATCHES "-flto") @@ -1405,7 +1413,14 @@ ${strip_command} ) else() - message(FATAL_ERROR "LLVM_EXTERNALIZE_DEBUGINFO isn't implemented for non-darwin platforms!") + if(NOT LLVM_EXTERNALIZE_DEBUGINFO_SKIP_STRIP) + set(strip_command COMMAND strip -gx $) + endif() + + add_custom_command(TARGET ${name} POST_BUILD + COMMAND objcopy --only-keep-debug $ $.dbg + ${strip_command} + ) endif() endfunction()