Debian Codegraph @

build/build-clang/llvmorg-20-init-7208-g631bcbe9de13.patch

raw
1 From b31ad413e1f1220320179853d019c8b9283fdf3f Mon Sep 17 00:00:00 2001
2 From: Mike Hommey <[email protected]>
3 Date: Fri, 27 Sep 2024 15:15:55 +0900
4 Subject: [PATCH] [llvm][cmake] Properly place clang runtime directory on
5 linker command line when WinMsvc.cmake is involved (#110084)
6
7 WinMsvc.cmake, used for cross-compiling LLVM, targetting Windows, puts
8 -libpath flags on the linker command line for the MSVC directories.
9 Those may contain clang runtime libraries that come from MSVC, and may
10 be incompatible with the clang compiler in use when it doesn't come from
11 MSVC (which is obviously the case on cross-compiles). By prioritizing
12 the clang runtime directory on the linker command line, we avoid those
13 libraries being picked up by the linker.
14 ---
15 llvm/cmake/modules/HandleLLVMOptions.cmake | 8 +++++++-
16 1 file changed, 7 insertions(+), 1 deletion(-)
17
18 diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
19 index 0699a8586fcc..e4dae07f071d 100644
20 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake
21 +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
22 @@ -293,6 +293,12 @@ function(append value)
23 endforeach(variable)
24 endfunction()
25
26 +function(prepend value)
27 + foreach(variable ${ARGN})
28 + set(${variable} "${value} ${${variable}}" PARENT_SCOPE)
29 + endforeach(variable)
30 +endfunction()
31 +
32 function(append_if condition value)
33 if (${condition})
34 foreach(variable ${ARGN})
35 @@ -1178,7 +1184,7 @@ if (CLANG_CL AND (LLVM_BUILD_INSTRUMENTED OR LLVM_USE_SANITIZER))
36 endif()
37 file(TO_CMAKE_PATH "${clang_compiler_rt_file}" clang_compiler_rt_file)
38 get_filename_component(clang_runtime_dir "${clang_compiler_rt_file}" DIRECTORY)
39 - append("/libpath:\"${clang_runtime_dir}\""
40 + prepend("/libpath:\"${clang_runtime_dir}\""
41 CMAKE_EXE_LINKER_FLAGS
42 CMAKE_MODULE_LINKER_FLAGS
43 CMAKE_SHARED_LINKER_FLAGS)
44 --
45 2.46.1.1.gad55fb22ef
46