swiftlang / swift-package-manager

The Package Manager for the Swift Programming Language
Apache License 2.0
9.75k stars 1.35k forks source link

[SR-10529] SwiftPM related tools included in Command Line Tools fail to launch with error: dyld: Library not loaded: @rpath/llbuild.framework/Versions/A/llbuild #4717

Open norio-nomura opened 5 years ago

norio-nomura commented 5 years ago
Previous ID SR-10529
Radar rdar://problem/49521846
Original Reporter @norio-nomura
Type Bug
Environment Command Line Tools (macOS 10.14) for Xcode 10.2.1
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Package Manager | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 1aeea099d3b2b37888ab832703422247

Issue Description:

$ xcrun swift-build
dyld: Library not loaded: @rpath/llbuild.framework/Versions/A/llbuild
  Referenced from: /Library/Developer/CommandLineTools/usr/bin/swift-build
  Reason: image not found
[1]    20585 abort      xcrun swift-build
$ xcrun swift-package
dyld: Library not loaded: @rpath/llbuild.framework/Versions/A/llbuild
  Referenced from: /Library/Developer/CommandLineTools/usr/bin/swift-package
  Reason: image not found
[1]    20621 abort      xcrun swift-package
$ xcrun swift-run
dyld: Library not loaded: @rpath/llbuild.framework/Versions/A/llbuild
  Referenced from: /Library/Developer/CommandLineTools/usr/bin/swift-run
  Reason: image not found
[1]    20630 abort      xcrun swift-run
$ xcrun swift-test
dyld: Library not loaded: @rpath/llbuild.framework/Versions/A/llbuild
  Referenced from: /Library/Developer/CommandLineTools/usr/bin/swift-test
  Reason: image not found
[1]    20639 abort      xcrun swift-test
belkadan commented 5 years ago

Maybe the rpath isn't set up correctly for Command Line Tools installs?

norio-nomura commented 5 years ago

Maybe the rpath isn't set up correctly for Command Line Tools installs?

Yes, it has rpathes assuming placed inside bundle of Xcode.

$ otool -l /Library/Developer/CommandLineTools/usr/bin/swift-package
…
Load command 26
          cmd LC_RPATH
      cmdsize 32
         path /usr/lib/swift (offset 12)
Load command 27
          cmd LC_RPATH
      cmdsize 56
         path @executable_path/../../../../../Frameworks (offset 12)
Load command 28
          cmd LC_RPATH
      cmdsize 64
         path @executable_path/../../../../../SharedFrameworks (offset 12)

It should have rpathes like OSS Toolchains:

$ otool -l $(xcrun --toolchain org.swift.5120190417a --find swift-package)
…
Load command 27
          cmd LC_RPATH
      cmdsize 136
         path /Users/buildnode/jenkins/workspace/oss-swift-5.1-package-osx/build/buildbot_osx/swift-macosx-x86_64/lib/swift/macosx (offset 12)
Load command 28
          cmd LC_RPATH
      cmdsize 56
         path @executable_path/../lib/swift/macosx (offset 12)
Load command 29
          cmd LC_RPATH
      cmdsize 56
         path @executable_path/../lib/swift/pm/llbuild (offset 12)