Skip to content

Commit

Permalink
[clang-repl][CMake][MSVC] Wrap /EXPORT linker option for ICX (#112867)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Maetveis authored Oct 23, 2024
1 parent ba19e98 commit eb9af19
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
6 changes: 2 additions & 4 deletions clang/tools/clang-repl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 2 additions & 5 deletions clang/unittests/Interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit eb9af19

Please sign in to comment.