[clang] [clang-repl][CMake][MSVC] Wrap /EXPORT linker option for ICX (PR #112867)
Mészáros Gergely via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 23 04:04:25 PDT 2024
https://github.com/Maetveis updated https://github.com/llvm/llvm-project/pull/112867
>From 2c2b4070b05db0a550fb2a63458be85020963a9a Mon Sep 17 00:00:00 2001
From: Gergely Meszaros <gergely.meszaros at intel.com>
Date: Thu, 17 Oct 2024 05:35:37 -0700
Subject: [PATCH] [clang-repl][CMake][MSVC] Wrap /EXPORT linker option for ICX
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).
Use the `LINKER:` prefix for the `/EXPORT:` options in clang-repl, this
expands to the correct flag for ICX and nothing for MSVC / clang-cl.
RFC: https://discourse.llvm.org/t/rfc-cmake-linker-flags-need-wl-equivalent-for-intel-c-icx-on-windows/82446
---
clang/tools/clang-repl/CMakeLists.txt | 6 ++----
clang/unittests/Interpreter/CMakeLists.txt | 7 ++-----
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/clang/tools/clang-repl/CMakeLists.txt b/clang/tools/clang-repl/CMakeLists.txt
index 9ffe853d759caf..7aebbe7a19436a 100644
--- a/clang/tools/clang-repl/CMakeLists.txt
+++ b/clang/tools/clang-repl/CMakeLists.txt
@@ -48,11 +48,9 @@ if(MSVC)
endif()
# List to '/EXPORT:sym0 /EXPORT:sym1 /EXPORT:sym2 ...'
- foreach(sym ${clang_repl_exports})
- set(clang_repl_link_str "${clang_repl_link_str} /EXPORT:${sym}")
- endforeach(sym ${clang_repl_exports})
+ list(TRANSFORM clang_repl_exports PREPEND "LINKER:/EXPORT:")
- set_property(TARGET clang-repl APPEND_STRING PROPERTY LINK_FLAGS ${clang_repl_link_str})
+ set_property(TARGET clang-repl APPEND PROPERTY LINK_OPTIONS ${clang_repl_exports})
endif(MSVC)
diff --git a/clang/unittests/Interpreter/CMakeLists.txt b/clang/unittests/Interpreter/CMakeLists.txt
index 1ed1216c772e8f..95378f9cfe7370 100644
--- a/clang/unittests/Interpreter/CMakeLists.txt
+++ b/clang/unittests/Interpreter/CMakeLists.txt
@@ -67,10 +67,7 @@ if(MSVC)
endif()
# List to '/EXPORT:sym0 /EXPORT:sym1 /EXPORT:sym2 ...'
- foreach(sym ${ClangReplInterpreterTests_exports})
- set(ClangReplInterpreterTests_link_str "${ClangReplInterpreterTests_link_str} /EXPORT:${sym}")
- endforeach(sym ${ClangReplInterpreterTests_exports})
-
- set_property(TARGET ClangReplInterpreterTests APPEND_STRING PROPERTY LINK_FLAGS ${ClangReplInterpreterTests_link_str})
+ list(TRANSFORM ClangReplInterpreterTests_exports PREPEND "LINKER:/EXPORT:")
+ set_property(TARGET ClangReplInterpreterTests APPEND PROPERTY LINK_OPTIONS ${ClangReplInterpreterTests_exports})
endif(MSVC)
More information about the cfe-commits
mailing list