Skip to content

[5.9][lldb][cmake] Remove local rpaths from the build host on ELF platforms #6779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler-rt/cmake/Modules/AddCompilerRT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,8 @@ function(add_compiler_rt_runtime name type)
target_link_libraries(${libname} PRIVATE ${builtins_${libname}})
endif()
if(${type} STREQUAL "SHARED")
if(COMMAND llvm_setup_rpath)
llvm_setup_rpath(${libname})
if(APPLE OR WIN32)
set_property(TARGET ${libname} PROPERTY BUILD_WITH_INSTALL_RPATH ON)
endif()
if(WIN32 AND NOT CYGWIN AND NOT MINGW)
set_target_properties(${libname} PROPERTIES IMPORT_PREFIX "")
Expand Down
16 changes: 10 additions & 6 deletions lldb/cmake/modules/AddLLDB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -172,25 +172,29 @@ function(add_properties_for_swift_modules target reldir)
target_link_directories(${target} PRIVATE
"${CMAKE_OSX_SYSROOT}/usr/lib/swift"
"${LLDB_SWIFT_LIBS}/macosx")
set(SWIFT_RPATH "/usr/lib/swift")
set(SWIFT_BUILD_RPATH "/usr/lib/swift")
set(SWIFT_INSTALL_RPATH "/usr/lib/swift")
elseif(APSM_BOOTSTRAPPING_MODE STREQUAL "BOOTSTRAPPING")
target_link_directories(${target} PRIVATE "${LLDB_SWIFT_LIBS}/macosx")
set(SWIFT_RPATH "${LLDB_SWIFT_LIBS}/macosx")
set(SWIFT_BUILD_RPATH "${LLDB_SWIFT_LIBS}/macosx")
set(SWIFT_INSTALL_RPATH "${LLDB_SWIFT_LIBS}/macosx")
else()
message(FATAL_ERROR "Unknown APSM_BOOTSTRAPPING_MODE '${APSM_BOOTSTRAPPING_MODE}'")
endif()

# Workaround for a linker crash related to autolinking: rdar://77839981
set_property(TARGET ${target} APPEND_STRING PROPERTY
LINK_FLAGS " -lobjc ")
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux")
elseif (CMAKE_SYSTEM_NAME MATCHES "Linux|Android|OpenBSD|FreeBSD")
string(REGEX MATCH "^[^-]*" arch ${LLVM_TARGET_TRIPLE})
target_link_libraries(${target} PRIVATE swiftCore-linux-${arch})
set(SWIFT_RPATH "${LLDB_SWIFT_LIBS}/linux;$ORIGIN/../lib/swift/linux")
string(TOLOWER ${CMAKE_SYSTEM_NAME} platform)
set(SWIFT_BUILD_RPATH "${LLDB_SWIFT_LIBS}/${platform}")
set(SWIFT_INSTALL_RPATH "$ORIGIN/swift/${platform}")
endif()

set_property(TARGET ${target} APPEND PROPERTY BUILD_RPATH "${SWIFT_RPATH}")
set_property(TARGET ${target} APPEND PROPERTY INSTALL_RPATH "${SWIFT_RPATH}")
set_property(TARGET ${target} APPEND PROPERTY BUILD_RPATH "${SWIFT_BUILD_RPATH}")
set_property(TARGET ${target} APPEND PROPERTY INSTALL_RPATH "${SWIFT_INSTALL_RPATH}")

if (SWIFT_SWIFT_PARSER)
set_property(TARGET ${target}
Expand Down
14 changes: 11 additions & 3 deletions llvm/cmake/modules/AddLLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2317,7 +2317,8 @@ function(llvm_setup_rpath name)
# FIXME: update this when there is better solution.
set(_install_rpath "${LLVM_LIBRARY_OUTPUT_INTDIR}" "${CMAKE_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
elseif(UNIX)
set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
set(_build_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}")
if(${CMAKE_SYSTEM_NAME} MATCHES "(FreeBSD|DragonFly)")
set_property(TARGET ${name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-z,origin ")
Expand All @@ -2331,9 +2332,16 @@ function(llvm_setup_rpath name)
return()
endif()

# Enable BUILD_WITH_INSTALL_RPATH unless CMAKE_BUILD_RPATH is set.
# Enable BUILD_WITH_INSTALL_RPATH unless CMAKE_BUILD_RPATH is set and not
# building for macOS or AIX, as those platforms seemingly require it.
# On AIX, the tool chain doesn't support modifying rpaths/libpaths for XCOFF
# on install at the moment, so BUILD_WITH_INSTALL_RPATH is required.
if("${CMAKE_BUILD_RPATH}" STREQUAL "")
set_property(TARGET ${name} PROPERTY BUILD_WITH_INSTALL_RPATH ON)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin|AIX")
set_property(TARGET ${name} PROPERTY BUILD_WITH_INSTALL_RPATH ON)
else()
set_property(TARGET ${name} APPEND PROPERTY BUILD_RPATH "${_build_rpath}")
endif()
endif()

set_target_properties(${name} PROPERTIES
Expand Down