[llvm] 36b87d8 - Set -rpath-link only if the path is nonempty.
Justin Lebar via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 21 10:14:13 PDT 2023
Author: Justin Lebar
Date: 2023-09-21T10:13:51-07:00
New Revision: 36b87d8043ee038b382fe734709ea1ab4b89238c
URL: https://github.com/llvm/llvm-project/commit/36b87d8043ee038b382fe734709ea1ab4b89238c
DIFF: https://github.com/llvm/llvm-project/commit/36b87d8043ee038b382fe734709ea1ab4b89238c.diff
LOG: Set -rpath-link only if the path is nonempty.
This cmake rule is used by external clients, who may or may not have
the LLVM_LIBRARY_OUTPUT_INTDIR variable set.
If it is not set, then we pass `-Wl,-rpath-link,` to the compiler. It
turns out that gcc and clang interpret this differently.
* gcc passes `-rpath-link ""` to the linker, which is what we want.
* clang passes `-rpath-link` to the linker. This is not what we want,
because then the linker gobbles the next command-line argument,
whatever it happens to be, and uses it as the -rpath-link target.
Fix this by passing -rpath-link only if we actually have a path we want.
Added:
Modified:
llvm/cmake/modules/AddLLVM.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake
index 77b4a51b13b8ca9..93011522e498e6e 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -2366,7 +2366,7 @@ function(llvm_setup_rpath name)
set_property(TARGET ${name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-z,origin ")
endif()
- if(LLVM_LINKER_IS_GNULD)
+ if(LLVM_LINKER_IS_GNULD AND NOT ${LLVM_LIBRARY_OUTPUT_INTDIR} STREQUAL "")
# $ORIGIN is not interpreted at link time by ld.bfd
set_property(TARGET ${name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-rpath-link,${LLVM_LIBRARY_OUTPUT_INTDIR} ")
More information about the llvm-commits
mailing list