From 695b9616d954524108ea5f2c300229bdf307666e Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Wed, 10 Sep 2025 11:13:28 +0100 Subject: [PATCH 1/6] [Bootstrap] Add an extra argument to set a library path. During Swift PR testing, we run the SwiftPM tests. Unfortunately, the SwiftPM tests always try to link with the system version of the Swift runtime libraries. This would be fine, except that Swift Testing has been built against the *new* runtimes and as a result has ended up referencing symbols from them that might not be present in the system runtime libraries. To fix this, add an extra argument to allow us to add to the `DYLD_LIBRARY_PATH` setting SwiftPM uses to run its tests. rdar://160273124 --- Utilities/bootstrap | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Utilities/bootstrap b/Utilities/bootstrap index d6bdd3d2f2f..b35f028b297 100755 --- a/Utilities/bootstrap +++ b/Utilities/bootstrap @@ -167,6 +167,9 @@ def add_build_args(parser): "--llbuild-link-framework", action="store_true", help="whether to link to the llbuild framework") + parser.add_argument( + "--extra-dynamic-library-path", + help="path to add to DYLD/LD_LIBRARY_PATH", parser.add_argument( "--release", action="store_true", @@ -891,6 +894,9 @@ def get_swiftpm_env_cmd(args): os.path.join(args.build_dirs["swift-build"], "lib"), ] + if args.extra_dynamic_library_path: + libs.append(args.extra_dynamic_library_path) + if platform.system() == 'Darwin': env_cmd.append("DYLD_LIBRARY_PATH=%s" % ":".join(libs)) else: From 723b7c815392985f62e3c4cffcc4ad62313c1f0d Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Wed, 10 Sep 2025 13:48:54 +0100 Subject: [PATCH 2/6] [Bootstrap] Fix typo. Fixed a typo in the script. rdar://160273124 --- Utilities/bootstrap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/bootstrap b/Utilities/bootstrap index b35f028b297..a3523e1ac40 100755 --- a/Utilities/bootstrap +++ b/Utilities/bootstrap @@ -169,7 +169,7 @@ def add_build_args(parser): help="whether to link to the llbuild framework") parser.add_argument( "--extra-dynamic-library-path", - help="path to add to DYLD/LD_LIBRARY_PATH", + help="path to add to DYLD/LD_LIBRARY_PATH") parser.add_argument( "--release", action="store_true", From 65287dd5d0e816e08acdb2952b2bc6b6eef8dbfd Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Mon, 29 Sep 2025 10:44:58 +0100 Subject: [PATCH 3/6] [Bootstrap] Force-enable the backtracer. This *might* break things, but I need it to debug a test. rdar://160273124 --- Utilities/bootstrap | 1 + 1 file changed, 1 insertion(+) diff --git a/Utilities/bootstrap b/Utilities/bootstrap index a3523e1ac40..59c83ef1abb 100755 --- a/Utilities/bootstrap +++ b/Utilities/bootstrap @@ -907,6 +907,7 @@ def get_swiftpm_env_cmd(args): env_cmd.append("SWIFTCI_DISABLE_SDK_DEPENDENT_TESTS=YES") env_cmd += [ + "SWIFT_BACKTRACE=enable=yes,warnings=suppressed", "SWIFT_EXEC=" + args.swiftc_path, "SWIFT_DRIVER_SWIFT_EXEC=" + args.swiftc_path, "CC=" + args.clang_path, From 6a2b600ab29e7641243ebb2c4a1a525a79f7af7a Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Wed, 1 Oct 2025 09:57:57 +0100 Subject: [PATCH 4/6] [Bootstrap] Set `(DY)LD_LIBRARY_PATH` even if not bootstrapping. We should set `(DY)LD_LIBRARY_PATH` if we need to, even if we aren't bootstrapping. rdar://160273124 --- Utilities/bootstrap | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Utilities/bootstrap b/Utilities/bootstrap index 59c83ef1abb..a36bdce901d 100755 --- a/Utilities/bootstrap +++ b/Utilities/bootstrap @@ -879,8 +879,9 @@ def get_swiftpm_env_cmd(args): if not '-macosx' in args.build_target and args.command == 'install': env_cmd.append("SWIFTCI_INSTALL_RPATH_OS=%s" % args.platform_path.group(2)) + libs = [] if args.bootstrap: - libs = [ + libs += [ os.path.join(args.bootstrap_dir, "lib"), os.path.join(args.build_dirs["tsc"], "lib"), os.path.join(args.build_dirs["llbuild"], "lib"), @@ -894,9 +895,10 @@ def get_swiftpm_env_cmd(args): os.path.join(args.build_dirs["swift-build"], "lib"), ] - if args.extra_dynamic_library_path: - libs.append(args.extra_dynamic_library_path) + if args.extra_dynamic_library_path: + libs.append(args.extra_dynamic_library_path) + if libs: if platform.system() == 'Darwin': env_cmd.append("DYLD_LIBRARY_PATH=%s" % ":".join(libs)) else: From a3c36da287112f48f91ec36c5578dafc5694b86d Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Tue, 14 Oct 2025 15:26:19 +0100 Subject: [PATCH 5/6] [Bootstrap] Also set `DYLD_INSERT_LIBRARIES`. This fixes a problem where `dyld` loads the new `libswiftCore.dylib`, but doesn't realise it's a replacement for the system `libswiftCore.dylib`, so doesn't fix up all the places where there are calls into the latter, the upshot being some very bizarre behaviour. rdar://160273124 --- Utilities/bootstrap | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Utilities/bootstrap b/Utilities/bootstrap index a36bdce901d..e91eefe6545 100755 --- a/Utilities/bootstrap +++ b/Utilities/bootstrap @@ -900,6 +900,13 @@ def get_swiftpm_env_cmd(args): if libs: if platform.system() == 'Darwin': + # This DYLD_INSERT_LIBRARIES command is necessary to prevent problems + # with dyld failing to realise that the newly built libswiftCore is + # the replacement for the system version. + # + # (This is caused by the install name in the newly built version + # using an `@rpath`.) + env_cmd.append("DYLD_INSERT_LIBRARIES=/usr/lib/swift/libswiftCore.dylib") env_cmd.append("DYLD_LIBRARY_PATH=%s" % ":".join(libs)) else: libs_joined = ":".join(libs + args.target_info["paths"]["runtimeLibraryPaths"]) From a85579964751d9da7d2ca5668689b4436e6d9a74 Mon Sep 17 00:00:00 2001 From: Alastair Houghton Date: Wed, 15 Oct 2025 14:55:32 +0100 Subject: [PATCH 6/6] [Bootstrap] Also add `libswift_Concurrency.dylib`. We need the Concurrency library in `DYLD_INSERT_LIBRARIES` as well. rdar://160273124 --- Utilities/bootstrap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Utilities/bootstrap b/Utilities/bootstrap index e91eefe6545..4dda41c8449 100755 --- a/Utilities/bootstrap +++ b/Utilities/bootstrap @@ -901,12 +901,12 @@ def get_swiftpm_env_cmd(args): if libs: if platform.system() == 'Darwin': # This DYLD_INSERT_LIBRARIES command is necessary to prevent problems - # with dyld failing to realise that the newly built libswiftCore is + # with dyld failing to realise that the newly built libraries are # the replacement for the system version. # # (This is caused by the install name in the newly built version # using an `@rpath`.) - env_cmd.append("DYLD_INSERT_LIBRARIES=/usr/lib/swift/libswiftCore.dylib") + env_cmd.append("DYLD_INSERT_LIBRARIES=/usr/lib/swift/libswiftCore.dylib:/usr/lib/swift/libswift_Concurrency.dylib") env_cmd.append("DYLD_LIBRARY_PATH=%s" % ":".join(libs)) else: libs_joined = ":".join(libs + args.target_info["paths"]["runtimeLibraryPaths"])