@@ -112,6 +112,7 @@ final class BuildPlanTests: XCTestCase {
112
112
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
113
113
" -o " , " /path/to/build/debug/exe " , " -module-name " , " exe " ,
114
114
" -emit-executable " ,
115
+ " -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " ,
115
116
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
116
117
" -Xlinker " , " -rpath " , " -Xlinker " , " /fake/path/lib/swift/macosx " ,
117
118
" -target " , " x86_64-apple-macosx10.10 " , " -Xlinker " , " -add_ast_path " ,
@@ -228,6 +229,7 @@ final class BuildPlanTests: XCTestCase {
228
229
XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [
229
230
" /fake/path/to/swiftc " , " -g " , " -L " , " /path/to/build/release " ,
230
231
" -o " , " /path/to/build/release/exe " , " -module-name " , " exe " , " -emit-executable " ,
232
+ " -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " ,
231
233
" @/path/to/build/release/exe.product/Objects.LinkFileList " ,
232
234
" -Xlinker " , " -rpath " , " -Xlinker " , " /fake/path/lib/swift/macosx " ,
233
235
" -target " , " x86_64-apple-macosx10.10 " ,
@@ -327,6 +329,7 @@ final class BuildPlanTests: XCTestCase {
327
329
XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [
328
330
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
329
331
" -o " , " /path/to/build/debug/exe " , " -module-name " , " exe " , " -emit-executable " ,
332
+ " -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " ,
330
333
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
331
334
" -runtime-compatibility-version " , " none " ,
332
335
" -target " , " x86_64-apple-macosx10.10 " ,
@@ -386,6 +389,7 @@ final class BuildPlanTests: XCTestCase {
386
389
XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [
387
390
" /fake/path/to/swiftc " , " -lc++ " , " -L " , " /path/to/build/debug " , " -o " ,
388
391
" /path/to/build/debug/exe " , " -module-name " , " exe " , " -emit-executable " ,
392
+ " -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " ,
389
393
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
390
394
" -runtime-compatibility-version " , " none " ,
391
395
" -target " , " x86_64-apple-macosx10.10 " ,
@@ -460,6 +464,7 @@ final class BuildPlanTests: XCTestCase {
460
464
XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [
461
465
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
462
466
" -o " , " /path/to/build/debug/exe " , " -module-name " , " exe " , " -emit-executable " ,
467
+ " -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " ,
463
468
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
464
469
" -Xlinker " , " -rpath " , " -Xlinker " , " /fake/path/lib/swift/macosx " ,
465
470
" -target " , " x86_64-apple-macosx10.10 " ,
@@ -604,6 +609,7 @@ final class BuildPlanTests: XCTestCase {
604
609
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " , " -o " ,
605
610
" /path/to/build/debug/PkgPackageTests.xctest/Contents/MacOS/PkgPackageTests " , " -module-name " ,
606
611
" PkgPackageTests " , " -Xlinker " , " -bundle " ,
612
+ " -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " ,
607
613
" @/path/to/build/debug/PkgPackageTests.product/Objects.LinkFileList " ,
608
614
" -Xlinker " , " -rpath " , " -Xlinker " , " /fake/path/lib/swift/macosx " ,
609
615
" -target " , " x86_64-apple-macosx10.10 " ,
@@ -658,6 +664,7 @@ final class BuildPlanTests: XCTestCase {
658
664
XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [
659
665
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
660
666
" -o " , " /path/to/build/debug/exe " , " -module-name " , " exe " , " -emit-executable " ,
667
+ " -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " ,
661
668
" @/path/to/build/debug/exe.product/Objects.LinkFileList " ,
662
669
" -Xlinker " , " -rpath " , " -Xlinker " , " /fake/path/lib/swift/macosx " ,
663
670
" -target " , " x86_64-apple-macosx10.10 " ,
@@ -752,6 +759,7 @@ final class BuildPlanTests: XCTestCase {
752
759
XCTAssertEqual ( fooLinkArgs, [
753
760
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
754
761
" -o " , " /path/to/build/debug/Foo " , " -module-name " , " Foo " , " -lBar-Baz " , " -emit-executable " ,
762
+ " -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " ,
755
763
" @/path/to/build/debug/Foo.product/Objects.LinkFileList " ,
756
764
" -Xlinker " , " -rpath " , " -Xlinker " , " /fake/path/lib/swift/macosx " ,
757
765
" -target " , " x86_64-apple-macosx10.10 " ,
@@ -762,6 +770,8 @@ final class BuildPlanTests: XCTestCase {
762
770
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " , " -o " ,
763
771
" /path/to/build/debug/libBar-Baz.dylib " ,
764
772
" -module-name " , " Bar_Baz " , " -emit-library " ,
773
+ " -Xlinker " , " -install_name " , " -Xlinker " , " @rpath/libBar-Baz.dylib " ,
774
+ " -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " ,
765
775
" @/path/to/build/debug/Bar-Baz.product/Objects.LinkFileList " ,
766
776
" -target " , " x86_64-apple-macosx10.10 " ,
767
777
" -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/Bar.swiftmodule "
@@ -785,6 +795,15 @@ final class BuildPlanTests: XCTestCase {
785
795
] )
786
796
#endif
787
797
798
+ #if os(macOS)
799
+ XCTAssert (
800
+ barLinkArgs. contains ( " -install_name " )
801
+ && barLinkArgs. contains ( " @rpath/libBar-Baz.dylib " )
802
+ && barLinkArgs. contains ( " -rpath " )
803
+ && barLinkArgs. contains ( " @loader_path " ) ,
804
+ " The dynamic library will not work once moved outside the build directory. "
805
+ )
806
+ #endif
788
807
}
789
808
790
809
func testExecAsDependency( ) throws {
@@ -830,6 +849,8 @@ final class BuildPlanTests: XCTestCase {
830
849
" /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " ,
831
850
" -o " , " /path/to/build/debug/liblib.dylib " , " -module-name " , " lib " ,
832
851
" -emit-library " ,
852
+ " -Xlinker " , " -install_name " , " -Xlinker " , " @rpath/liblib.dylib " ,
853
+ " -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " ,
833
854
" @/path/to/build/debug/lib.product/Objects.LinkFileList " ,
834
855
" -target " , " x86_64-apple-macosx10.10 " ,
835
856
" -Xlinker " , " -add_ast_path " , " -Xlinker " , " /path/to/build/debug/lib.swiftmodule " ,
@@ -900,9 +921,9 @@ final class BuildPlanTests: XCTestCase {
900
921
XCTAssertEqual ( lib. moduleMap, AbsolutePath ( " /path/to/build/debug/lib.build/module.modulemap " ) )
901
922
902
923
#if os(macOS)
903
- XCTAssertEqual ( try result. buildProduct ( for: " lib " ) . linkArguments ( ) , [ " /fake/path/to/swiftc " , " -lc++ " , " -L " , " /path/to/build/debug " , " -o " , " /path/to/build/debug/liblib.dylib " , " -module-name " , " lib " , " -emit-library " , " @/path/to/build/debug/lib.product/Objects.LinkFileList " , " -runtime-compatibility-version " , " none " , " -target " , " x86_64-apple-macosx10.10 " ] )
924
+ XCTAssertEqual ( try result. buildProduct ( for: " lib " ) . linkArguments ( ) , [ " /fake/path/to/swiftc " , " -lc++ " , " -L " , " /path/to/build/debug " , " -o " , " /path/to/build/debug/liblib.dylib " , " -module-name " , " lib " , " -emit-library " , " -Xlinker " , " -install_name " , " -Xlinker " , " @rpath/liblib.dylib " , " -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " , " @/path/to/build/debug/lib.product/Objects.LinkFileList " , " -runtime-compatibility-version " , " none " , " -target " , " x86_64-apple-macosx10.10 " ] )
904
925
905
- XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [ " /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " , " -o " , " /path/to/build/debug/exe " , " -module-name " , " exe " , " -emit-executable " , " @/path/to/build/debug/exe.product/Objects.LinkFileList " , " -runtime-compatibility-version " , " none " , " -target " , " x86_64-apple-macosx10.10 " ] )
926
+ XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [ " /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " , " -o " , " /path/to/build/debug/exe " , " -module-name " , " exe " , " -emit-executable " , " -Xlinker " , " -rpath " , " -Xlinker " , " @loader_path " , " @/path/to/build/debug/exe.product/Objects.LinkFileList " , " -runtime-compatibility-version " , " none " , " -target " , " x86_64-apple-macosx10.10 " ] )
906
927
#else
907
928
XCTAssertEqual ( try result. buildProduct ( for: " lib " ) . linkArguments ( ) , [ " /fake/path/to/swiftc " , " -lstdc++ " , " -L " , " /path/to/build/debug " , " -o " , " /path/to/build/debug/liblib.so " , " -module-name " , " lib " , " -emit-library " , " -Xlinker " , " -rpath=$ORIGIN " , " @/path/to/build/debug/lib.product/Objects.LinkFileList " , " -runtime-compatibility-version " , " none " , " -target " , defaultTargetTriple] )
908
929
XCTAssertEqual ( try result. buildProduct ( for: " exe " ) . linkArguments ( ) , [ " /fake/path/to/swiftc " , " -L " , " /path/to/build/debug " , " -o " , " /path/to/build/debug/exe " , " -module-name " , " exe " , " -emit-executable " , " -Xlinker " , " -rpath=$ORIGIN " , " @/path/to/build/debug/exe.product/Objects.LinkFileList " , " -runtime-compatibility-version " , " none " , " -target " , defaultTargetTriple] )
0 commit comments