[PATCH] D134165: [llvm] prefix linker flag on non-MSVC compilers with `-Wl,`
Ashay Rane via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 21 09:03:05 PDT 2022
ashay-github updated this revision to Diff 461915.
ashay-github added a comment.
- Explicitly added a case for MingW
- Quoted flag in the MingW case
- Added a catch-all block that throws an error
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134165/new/
https://reviews.llvm.org/D134165
Files:
llvm/cmake/modules/AddLLVM.cmake
Index: llvm/cmake/modules/AddLLVM.cmake
===================================================================
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -118,7 +118,7 @@
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--version-script,\"${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}\"")
endif()
- else()
+ elseif(WIN32)
set(native_export_file "${target_name}.def")
add_custom_command(OUTPUT ${native_export_file}
@@ -129,7 +129,18 @@
COMMENT "Creating export file for ${target_name}")
set(export_file_linker_flag "${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
if(MSVC)
+ # cl.exe or clang-cl, i.e. MSVC style command line interface
set(export_file_linker_flag "/DEF:\"${export_file_linker_flag}\"")
+ elseif(CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
+ # clang in msvc mode, calling a link.exe/lld-link style linker
+ set(export_file_linker_flag "-Wl,/DEF:\"${export_file_linker_flag}\"")
+ elseif(MINGW)
+ # ${export_file_linker_flag}, which is the plain file name, works as is
+ # when passed to the compiler driver, which then passes it on to the
+ # linker as an input file.
+ set(export_file_linker_flag "\"${export_file_linker_flag}\"")
+ else()
+ message(FATAL_ERROR "Unsupported Windows toolchain")
endif()
set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " ${export_file_linker_flag}")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134165.461915.patch
Type: text/x-patch
Size: 1528 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220921/c8eb3930/attachment.bin>
More information about the llvm-commits
mailing list