Skip to content

Commit 36b87d8

Browse files
committed
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.
1 parent e2bc0f9 commit 36b87d8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2366,7 +2366,7 @@ function(llvm_setup_rpath name)
23662366
set_property(TARGET ${name} APPEND_STRING PROPERTY
23672367
LINK_FLAGS " -Wl,-z,origin ")
23682368
endif()
2369-
if(LLVM_LINKER_IS_GNULD)
2369+
if(LLVM_LINKER_IS_GNULD AND NOT ${LLVM_LIBRARY_OUTPUT_INTDIR} STREQUAL "")
23702370
# $ORIGIN is not interpreted at link time by ld.bfd
23712371
set_property(TARGET ${name} APPEND_STRING PROPERTY
23722372
LINK_FLAGS " -Wl,-rpath-link,${LLVM_LIBRARY_OUTPUT_INTDIR} ")

0 commit comments

Comments
 (0)