[llvm] 631bcbe - [llvm][cmake] Properly place clang runtime directory on linker command line when WinMsvc.cmake is involved (#110084)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 26 23:15:59 PDT 2024
Author: Mike Hommey
Date: 2024-09-27T06:15:55Z
New Revision: 631bcbe9de13e160d427ad7452a7ef2ca67911ab
URL: https://github.com/llvm/llvm-project/commit/631bcbe9de13e160d427ad7452a7ef2ca67911ab
DIFF: https://github.com/llvm/llvm-project/commit/631bcbe9de13e160d427ad7452a7ef2ca67911ab.diff
LOG: [llvm][cmake] Properly place clang runtime directory on linker command line when WinMsvc.cmake is involved (#110084)
WinMsvc.cmake, used for cross-compiling LLVM, targetting Windows, puts
-libpath flags on the linker command line for the MSVC directories.
Those may contain clang runtime libraries that come from MSVC, and may
be incompatible with the clang compiler in use when it doesn't come from
MSVC (which is obviously the case on cross-compiles). By prioritizing
the clang runtime directory on the linker command line, we avoid those
libraries being picked up by the linker.
Added:
Modified:
llvm/cmake/modules/HandleLLVMOptions.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index ed13a82905b4e3..e17e2169cd880f 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -324,6 +324,12 @@ function(append value)
endforeach(variable)
endfunction()
+function(prepend value)
+ foreach(variable ${ARGN})
+ set(${variable} "${value} ${${variable}}" PARENT_SCOPE)
+ endforeach(variable)
+endfunction()
+
function(append_if condition value)
if (${condition})
foreach(variable ${ARGN})
@@ -1196,7 +1202,7 @@ if (CLANG_CL AND (LLVM_BUILD_INSTRUMENTED OR LLVM_USE_SANITIZER))
endif()
file(TO_CMAKE_PATH "${clang_compiler_rt_file}" clang_compiler_rt_file)
get_filename_component(clang_runtime_dir "${clang_compiler_rt_file}" DIRECTORY)
- append("/libpath:\"${clang_runtime_dir}\""
+ prepend("/libpath:\"${clang_runtime_dir}\""
CMAKE_EXE_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS)
More information about the llvm-commits
mailing list