Skip to content
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

[SR-12600] swiftpm-test-helper: "Library not loaded: @rpath/XCTest.framework/Versions/A/XCTest" in developer snapshots #4562

Closed
allevato opened this issue Apr 15, 2020 · 2 comments
Assignees
Labels

Comments

@allevato
Copy link

Previous ID SR-12600
Radar None
Original Reporter @allevato
Type Bug
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug
Assignee @dan-zheng
Priority Medium

md5: 51d2884b5d9a555b1fc271e9d6c258ea

Issue Description:

This may be similar to SR-12599.

Download any developer snapshot from swift.org and try to run `swift test` in a package. The project will build, and then output the following error:

error: signalled(6): /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2020-04-13-a.xctoolchain/usr/libexec/swift/pm/swiftpm-xctest-helper /<redacted>/swift-format/.build/x86_64-apple-macosx/debug/swift-formatPackageTests.xctest /var/folders/lp/b8svs5jj46d_g3t6smn3cj3h006b5z/T/TemporaryFile.ZxlFMg output:
{{ dyld: Library not loaded: @rpath/XCTest.framework/Versions/A/XCTest}}
{{ Referenced from: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2020-04-13-a.xctoolchain/usr/libexec/swift/pm/swiftpm-xctest-helper}}
{{ Reason: image not found }}

This seems to have broken sometime around the 5.2 cut, but I'm not sure exactly when.

If we run otool -l and compare the load commands of swiftpm-xctest-helper in a current toolchain and an older working toolchain, we see some differences:


Broken (2020-04-13):
Load command 32
cmd LC_RPATH
cmdsize 32
path /usr/lib/swift (offset 12)
Load command 33
cmd LC_RPATH
cmdsize 32
path @loader_path (offset 12)
Load command 34
cmd LC_RPATH
cmdsize 224
path /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift-nightly-install/Applications/Xcode.app/Contents/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2020-04-13-a.xctoolchain/usr/lib/swift/macosx (offset 12)
Load command 35
cmd LC_RPATH
cmdsize 56
path @executable_path/../lib/swift/macosx (offset 12)

Working (2019-09-26):
Load command 33
cmd LC_RPATH
cmdsize 32
path /usr/lib/swift (offset 12)
Load command 34
cmd LC_RPATH
cmdsize 32
path @loader_path (offset 12)
Load command 35
cmd LC_RPATH
cmdsize 56
path @executable_path/../lib/swift/macosx (offset 12)
Load command 36
cmd LC_RPATH
cmdsize 56
path @executable_path/../lib/swift/pm/llbuild (offset 12)
...
Load command 39
cmd LC_RPATH
cmdsize 56
path @executable_path/../../../lib/swift/macosx (offset 12)

Specifically, it looks like the one that's missing in the newer toolchains is @executable_path/../../../lib/swift/macosx, and that is where XCTest.swiftmodule lives; presumably if it found that, it would be able to resolve XCTest.framework from that overlay.

@dan-zheng
Copy link
Contributor

Tentative fix here: #2692
It adds @executable_path/../../../lib/swift/macosx as an rpath for SwiftPM.

I believe this regression occurred in #2462 which revamped the bootstrap script.

@dan-zheng
Copy link
Contributor

Fixed in #2785

@executable_path/../../../lib/swift/macosx is added as an rpath for swiftpm-xctest-helper.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants