From 7ecd25e9d4392e803f3c411e040bde5524562251 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. --- 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 beca0d2511e..6428f806383 100644 --- a/cmake/modules/AddSwiftHostLibrary.cmake +++ b/cmake/modules/AddSwiftHostLibrary.cmake @@ -71,10 +71,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