Skip to content

Commit 2bec212

Browse files
authored
On ELF platforms, remove the host toolchain rpath from executables and shared libraries (#2901)
before installing.
1 parent f1dbbab commit 2bec212

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Sources/PackageDescription/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ foreach(PACKAGE_DESCRIPTION_VERSION 4 4_2)
4747
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
4848
target_link_libraries(PD${PACKAGE_DESCRIPTION_VERSION} PRIVATE
4949
Foundation)
50+
target_link_options(PD${PACKAGE_DESCRIPTION_VERSION} PRIVATE
51+
"SHELL:-no-toolchain-stdlib-rpath")
5052
endif()
5153

5254
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Darwin)

Utilities/bootstrap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,11 @@ def get_swiftpm_flags(args):
610610
elif cross_compile_hosts:
611611
error("cannot cross-compile for %s" % cross_compile_hosts)
612612

613+
# On ELF platforms, remove the host toolchain's stdlib absolute rpath from
614+
# installed executables and shared libraries.
615+
if platform.system() != "Darwin" and args.command == 'install':
616+
build_flags.extend(["-Xswiftc", "-no-toolchain-stdlib-rpath"])
617+
613618
return build_flags
614619

615620
if __name__ == '__main__':

0 commit comments

Comments
 (0)