Skip to content

Do not test inferior Swift libraries on Darwin #5611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2022

Conversation

neonichu
Copy link
Contributor

On platforms with ABI-stable Swift runtime libraries (currently only Darwin), we should not set DYLD_LIBRARY_PATHS to include the inferior Swift libs in bootstrap because compatibility issues can arise from SwiftPM's use of Foundation (which itself is a client of the stdlib) and from using dyld4 (which is used on macOS 12+).

rdar://88475529

@neonichu neonichu requested a review from shahmishal June 21, 2022 17:14
@neonichu neonichu self-assigned this Jun 21, 2022
@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

@tomerd
Copy link
Contributor

tomerd commented Jun 21, 2022

@shahmishal can you test this before we merge?

@shahmishal
Copy link
Member

Yes, I will reply back here once I have results

@neonichu
Copy link
Contributor Author

2022-06-21 18:16:07.699 swiftpm-xctest-helper[65989:431473] Error loading /Users/ec2-user/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swiftpm-macosx-x86_64/x86_64-apple-macosx/release/SwiftPMPackageTests.xctest/Contents/MacOS/SwiftPMPackageTests:  dlopen(/Users/ec2-user/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swiftpm-macosx-x86_64/x86_64-apple-macosx/release/SwiftPMPackageTests.xctest/Contents/MacOS/SwiftPMPackageTests, 265): Library not loaded: @rpath/libswift_Concurrency.dylib
      Referenced from: /Users/ec2-user/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swiftpm-macosx-x86_64/x86_64-apple-macosx/release/SwiftPMPackageTests.xctest/Contents/MacOS/SwiftPMPackageTests
      Reason: image not found

Looks like this doesn't work as-is because some tests are linking libswift_Concurrency.dylib but it isn't present on the system. I think we have to include the back deployment path in DYLD_LIBRARY_PATH.

@neonichu neonichu force-pushed the do-not-include-swift-libs-in-dyld-library-path branch from 4f2bca3 to 9116d30 Compare June 21, 2022 19:03
@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

@neonichu
Copy link
Contributor Author

TypeError: can only concatenate list (not "str") to list 🤣

@neonichu neonichu force-pushed the do-not-include-swift-libs-in-dyld-library-path branch from 9116d30 to c3f7692 Compare June 21, 2022 19:53
@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

@neonichu
Copy link
Contributor Author

Missing a / in the computed path

@neonichu neonichu force-pushed the do-not-include-swift-libs-in-dyld-library-path branch from c3f7692 to de4301f Compare June 21, 2022 21:43
@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

On platforms with ABI-stable Swift runtime libraries (currently only Darwin), we should not set `DYLD_LIBRARY_PATHS` to include the inferior Swift libs in `bootstrap` because compatibility issues can arise from SwiftPM's use of Foundation (which itself is a client of the stdlib) and from using dyld4 (which is used on macOS 12+).

rdar://88475529
@neonichu neonichu force-pushed the do-not-include-swift-libs-in-dyld-library-path branch from de4301f to 6290e2e Compare June 21, 2022 22:53
@neonichu
Copy link
Contributor Author

@swift-ci please smoke test

@neonichu
Copy link
Contributor Author

Same error as before:

2022-06-21 23:33:52.020 swiftpm-xctest-helper[66157:1081111] Error loading /Users/ec2-user/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swiftpm-macosx-x86_64/x86_64-apple-macosx/release/SwiftPMPackageTests.xctest/Contents/MacOS/SwiftPMPackageTests:  dlopen(/Users/ec2-user/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swiftpm-macosx-x86_64/x86_64-apple-macosx/release/SwiftPMPackageTests.xctest/Contents/MacOS/SwiftPMPackageTests, 265): Library not loaded: @rpath/libswift_Concurrency.dylib
      Referenced from: /Users/ec2-user/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swiftpm-macosx-x86_64/x86_64-apple-macosx/release/SwiftPMPackageTests.xctest/Contents/MacOS/SwiftPMPackageTests
      Reason: image not found

@neonichu
Copy link
Contributor Author

neonichu commented Jun 21, 2022

What I see locally is:

❯ otool -l ./x86_64-apple-macosx/debug/SwiftPMPackageTests.xctest/Contents/MacOS/SwiftPMPackageTests
[...]
          cmd LC_RPATH
      cmdsize 200
         path /Volumes/Xcode.../Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx (offset 12)
Load command 43
          cmd LC_RPATH
      cmdsize 32
         path /usr/lib/swift (offset 12)
Load command 44
          cmd LC_RPATH
      cmdsize 216
         path /Volumes/Xcode.../Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/../../swift-5.5/macosx (offset 12)
Load command 45
          cmd LC_RPATH
      cmdsize 56
         path @executable_path/../lib/swift/macosx (offset 12)

which looks correct to me.

So there are a couple of options:
a) we are not getting the right base paths from swiftc -print-target-info
b) the inferior toolchain is organized differently so the path computation doesn't match up
c) the inferior toolchain doesn't contain the compatibility libs at all

@neonichu
Copy link
Contributor Author

The rpath looks legitimate: /Users/ec2-user/jenkins/workspace/swift-package-manager-PR-macos-smoke-test/branch-main/build/buildbot_incremental/toolchain-macosx-x86_64/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/../../swift-5.5/macosx so I think either the layout is different here or we don't have the compatibility libs at all.

@neonichu
Copy link
Contributor Author

OK, toolchain-macosx-x86_64/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.5/macosx does not exist, so we don't have the concurrency compatibility lib on CI.

@shahmishal
Copy link
Member

swiftlang/swift#59628
@swift-ci please smoke test macOS

1 similar comment
@shahmishal
Copy link
Member

swiftlang/swift#59628
@swift-ci please smoke test macOS

@neonichu neonichu merged commit d045aa6 into main Jun 22, 2022
@neonichu neonichu deleted the do-not-include-swift-libs-in-dyld-library-path branch June 22, 2022 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants