[llvm] [LLVM][CMake][MSVC] Wrap linker options for ICX with LLVM_BUILD_INSTUMENTED (PR #124573)
Mészáros Gergely via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 27 07:47:24 PST 2025
https://github.com/Maetveis created https://github.com/llvm/llvm-project/pull/124573
RFC: https://discourse.llvm.org/t/rfc-cmake-linker-flags-need-wl-equivalent-for-intel-c-icx-on-windows/82446
The Intel C++ Compiler (ICX) passes linker flags through the driver unlike MSVC and clang-cl, and therefore needs them to be prefixed with `/Qoption,link` (the equivalent of `-Wl,` for gcc on *nix).
Previous PRs did not catch this because I did not try building with `LLVM_BUILD_INSTRUMENTED=ON`.
`CMAKE_CXX_LINKER_WRAPPER_FLAG` is empty for plain clang-cl (icx on windows behaves as clang-cl), so this is NFC for clang-cl.
The approach I used to find this is documented as github gist here: https://gist.github.com/Maetveis/00567488f0d6ff74095d91ed306fafc5
>From fffa3c84d1078216778b7d4cc8d0ec460e4ed0b1 Mon Sep 17 00:00:00 2001
From: Gergely Meszaros <gergely.meszaros at intel.com>
Date: Mon, 27 Jan 2025 07:36:11 -0800
Subject: [PATCH] [LLVM][CMake][MSVC] Wrap linker options for ICX with
LLVM_BUILD_INSTRUMENTED
RFC: https://discourse.llvm.org/t/rfc-cmake-linker-flags-need-wl-equivalent-for-intel-c-icx-on-windows/82446
The Intel C++ Compiler (ICX) passes linker flags through the driver
unlike MSVC and clang-cl, and therefore needs them to be prefixed with
`/Qoption,link` (the equivalent of `-Wl,` for gcc on *nix).
Previous PRs did not catch this because I did not try building with
`LLVM_BUILD_INSTRUMENTED=ON`.
`CMAKE_CXX_LINKER_WRAPPER_FLAG` is empty for plain clang-cl
(icx on windows behaves as clang-cl), so this is NFC for clang-cl.
The approach I used to find these is documented as github gist here:
https://gist.github.com/Maetveis/00567488f0d6ff74095d91ed306fafc5
---
llvm/cmake/modules/HandleLLVMOptions.cmake | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index f19125eb6bf273..bfcac4041e4d04 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1212,7 +1212,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)
- prepend("/libpath:\"${clang_runtime_dir}\""
+ prepend("${CMAKE_CXX_LINKER_WRAPPER_FLAG}/libpath:\"${clang_runtime_dir}\""
CMAKE_EXE_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS)
More information about the llvm-commits
mailing list