From a3f834d19a7f4a496d9beb3403abc9998a5d463d Mon Sep 17 00:00:00 2001 From: Rintaro Ishizaki Date: Wed, 23 Aug 2023 06:11:43 +0000 Subject: [PATCH] [CMake] Add padding to RUNPATH in linux Shared libraries RUNPATH will be updated when they are copied to swift build directory. CMake's 'file(SET_RPATH ...)' requires RUNPATH field have enough lengh before updating. (cherry picked from commit 7ecd25e9d4392e803f3c411e040bde5524562251) (cherry picked from commit 6958b666305c8dd25192673e9b6d39ad043987cf) --- cmake/modules/AddSwiftHostLibrary.cmake | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/cmake/modules/AddSwiftHostLibrary.cmake b/cmake/modules/AddSwiftHostLibrary.cmake index c6c69f71715..cd13e47df88 100644 --- a/cmake/modules/AddSwiftHostLibrary.cmake +++ b/cmake/modules/AddSwiftHostLibrary.cmake @@ -66,10 +66,16 @@ function(add_swift_host_library name) ) get_target_property(lib_type ${name} TYPE) - if(lib_type STREQUAL SHARED_LIBRARY AND CMAKE_SYSTEM_NAME STREQUAL Darwin) - # Allow install_name_tool to update paths (for rdar://109473564) - set_property(TARGET ${name} APPEND_STRING PROPERTY - LINK_FLAGS " -Xlinker -headerpad_max_install_names") + if(lib_type STREQUAL SHARED_LIBRARY) + if (CMAKE_SYSTEM_NAME STREQUAL Darwin) + # Allow install_name_tool to update paths (for rdar://109473564) + set_property(TARGET ${name} APPEND_STRING PROPERTY + LINK_FLAGS " -Xlinker -headerpad_max_install_names") + elseif (CMAKE_SYSTEM_NAME STREQUAL Linux) + # Make some room to update paths. + set_property(TARGET ${name} APPEND PROPERTY + INSTALL_RPATH ":::::::::::::::::::::::::::::::::::::::::::::::::::::::") + endif() endif() # Install this target