Skip to content

Commit eb46e08

Browse files
committed
[build] Add an rpath of $ORIGIN.
- This allows XCTest to find Foundation adjacent to itself, and fixes runtime linker problems when using Gold, which automatically uses DT_RUNPATH instead of DT_RPATH and so no longer inherits the search path into the Swift runtime libraries location used at build time on the client (which `swiftc` currently automatically injects). - Fixes SR-1631.
1 parent 4f7b21c commit eb46e08

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

build_script.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ def build(args):
155155
source_paths=" ".join(sourcePaths)))
156156
run("{swiftc} -emit-library {build_dir}/XCTest.o "
157157
"-L {foundation_build_dir} -lswiftGlibc -lswiftCore -lFoundation -lm "
158+
# We embed an rpath of `$ORIGIN` to ensure other referenced
159+
# libraries (like `Foundation`) can be found solely via XCTest.
160+
"-Xlinker -rpath=\\$ORIGIN "
158161
"-o {build_dir}/libXCTest.so".format(
159162
swiftc=swiftc,
160163
build_dir=build_dir,

0 commit comments

Comments
 (0)