[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
Mon Sep 19 00:46:35 PDT 2022
ashay-github created this revision.
ashay-github added reviewers: rnk, beanz, stella.stamenova.
Herald added a project: All.
ashay-github requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Prior to this patch, a Windows build of llvm-lto using clang failed with
the error: `LTO.def: unknown file type`. The reason for this failure is
that .DEF files are used by the linker not by the clang compiler. The
MSVC compiler+linker handles this transparently, but if we're using
clang (or gcc), then we need to tell the compiler to forward this flag
to the linker. This patch adds the necessary `-Wl` flag to fix the
problem.
Repository:
rG LLVM Github Monorepo
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
@@ -130,6 +130,10 @@
set(export_file_linker_flag "${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}")
if(MSVC)
set(export_file_linker_flag "/DEF:\"${export_file_linker_flag}\"")
+ elseif(WIN32)
+ # If we're compiling on Windows and the compiler is not Visual Studio,
+ # then tell it to forward the `/DEF` flag to the linker.
+ set(export_file_linker_flag "-Wl,/DEF:\"${export_file_linker_flag}\"")
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.461155.patch
Type: text/x-patch
Size: 752 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220919/544444b4/attachment.bin>
More information about the llvm-commits
mailing list