Debian Codegraph @

build/build-clang/llvmorg-20-init-4204-g5013cf682cf0.patch

raw
1 From fea05619dccb54174b6cc3d4f3cef8c2d4edfe9d Mon Sep 17 00:00:00 2001
2 From: Mike Hommey <[email protected]>
3 Date: Sat, 31 Aug 2024 08:10:22 +0900
4 Subject: [PATCH] [cmake] Add symbolic links for MSVC libraries (#106710)
5
6 When cross-compiling a Windows clang with `-DLLVM_BUILD_INSTRUMENTED`,
7 the profiling compiler-rt is linked to binaries, as one would expect,
8 but the profiling compiler-rt contains objects with `/DEFAULTLIB:LIBCMT`
9 and `/DEFAULTLIB:OLDNAMES` directives, which makes the build expect
10 `LIBCMT.lib` and `OLDNAMES.lib`, but they are nowhere to be found
11 because they are in lowercase. While the WinMsvc.cmake helper recreates
12 symbolic links to work around such case sensitivity issues for the
13 Windows SDK libs, it doesn't do so for the MSVC libs, which we add here.
14 ---
15 llvm/cmake/platforms/WinMsvc.cmake | 25 +++++++++++++++++++++++++
16 1 file changed, 25 insertions(+)
17
18 diff --git a/llvm/cmake/platforms/WinMsvc.cmake b/llvm/cmake/platforms/WinMsvc.cmake
19 index 77c3ab3d8fc1..fc07498498bf 100644
20 --- a/llvm/cmake/platforms/WinMsvc.cmake
21 +++ b/llvm/cmake/platforms/WinMsvc.cmake
22 @@ -95,6 +95,7 @@ list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
23 LLVM_WINSYSROOT
24 MSVC_VER
25 WINSDK_VER
26 + msvc_lib_symlinks_dir
27 winsdk_lib_symlinks_dir
28 winsdk_vfs_overlay_path
29 )
30 @@ -156,6 +157,24 @@ function(generate_winsdk_lib_symlinks winsdk_um_lib_dir output_dir)
31 endforeach()
32 endfunction()
33
34 +function(generate_msvc_lib_symlinks msvc_lib_dir output_dir)
35 + execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${output_dir}")
36 + file(GLOB libraries RELATIVE "${msvc_lib_dir}" "${msvc_lib_dir}/*.lib")
37 + foreach(library ${libraries})
38 + get_filename_component(name_wle "${library}" NAME_WLE)
39 + get_filename_component(ext "${library}" LAST_EXT)
40 + string(TOLOWER "${ext}" lowercase_ext)
41 + string(TOUPPER "${name_wle}" all_uppercase_symlink_name_wle)
42 + set(uppercase_symlink_name "${all_uppercase_symlink_name_wle}${lowercase_ext}")
43 + if(NOT library STREQUAL uppercase_symlink_name)
44 + execute_process(COMMAND "${CMAKE_COMMAND}"
45 + -E create_symlink
46 + "${msvc_lib_dir}/${library}"
47 + "${output_dir}/${uppercase_symlink_name}")
48 + endif()
49 + endforeach()
50 +endfunction()
51 +
52 function(get_highest_version the_dir the_ver)
53 file(GLOB entries LIST_DIRECTORIES true RELATIVE "${the_dir}" "${the_dir}/[0-9.]*")
54 foreach(entry ${entries})
55 @@ -293,6 +312,12 @@ if(case_sensitive_filesystem)
56 endif()
57 list(APPEND LINK_FLAGS
58 -libpath:"${winsdk_lib_symlinks_dir}")
59 + if(NOT msvc_lib_symlinks_dir)
60 + set(msvc_lib_symlinks_dir "${CMAKE_BINARY_DIR}/msvc_lib_symlinks")
61 + generate_msvc_lib_symlinks("${MSVC_LIB}/${WINSDK_ARCH}" "${msvc_lib_symlinks_dir}")
62 + endif()
63 + list(APPEND LINK_FLAGS
64 + -libpath:"${msvc_lib_symlinks_dir}")
65 endif()
66
67 string(REPLACE ";" " " LINK_FLAGS "${LINK_FLAGS}")
68 --
69 2.45.2.2.g32a9d489d5
70