Skip to content

Instantly share code, notes, and snippets.

@krzyzanowskim
Last active March 9, 2019 23:57
Show Gist options
  • Save krzyzanowskim/c6459344b0744e5d292830dcf75807aa to your computer and use it in GitHub Desktop.
Save krzyzanowskim/c6459344b0744e5d292830dcf75807aa to your computer and use it in GitHub Desktop.
Load command 12
cmd LC_LOAD_DYLIB
cmdsize 80
name @executable_path/../Frameworks/libSwiftSyntax.dylib (offset 24)
time stamp 2 Thu Jan 1 01:00:02 1970
current version 0.0.0
compatibility version 0.0.0
Load command 43
cmd LC_RPATH
cmdsize 32
path /usr/lib/swift (offset 12)
Load command 44
cmd LC_RPATH
cmdsize 48
path @executable_path/../Frameworks (offset 12)
$ otool -L libSwiftSyntax.dylib
libSwiftSyntax.dylib:
@executable_path/../Frameworks/libSwiftSyntax.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1560.12.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1560.12.0)
@rpath/lib_InternalSwiftSyntaxParser.dylib (compatibility version 1.0.0, current version 0.0.0)
@rpath/libswiftCore.dylib (compatibility version 1.0.0, current version 0.0.0)
@rpath/libswiftCoreFoundation.dylib (compatibility version 1.0.0, current version 0.0.0)
@rpath/libswiftCoreGraphics.dylib (compatibility version 1.0.0, current version 0.0.0)
@rpath/libswiftDarwin.dylib (compatibility version 1.0.0, current version 0.0.0)
@rpath/libswiftDispatch.dylib (compatibility version 1.0.0, current version 0.0.0)
@rpath/libswiftFoundation.dylib (compatibility version 1.0.0, current version 0.0.0)
@rpath/libswiftIOKit.dylib (compatibility version 1.0.0, current version 0.0.0)
@rpath/libswiftObjectiveC.dylib (compatibility version 1.0.0, current version 0.0.0)
Runtime loads from toolchain: usr/lib/swift/macosx/libSwiftSyntax.dylib
dyld: Symbol not found: _$s11SwiftSyntax0B6ParserO5parse6source0D10Transition22filenameForDiagnostics16diagnosticEngineAA010SourceFileB0VSS_AA016IncrementalParseF0CSgSSAA010DiagnosticK0CSgtKFZ
Referenced from: /Users/marcinkrzyzanowski/Devel/SwiftStudio/DerivedData/SwiftStudio/Build/Products/Debug/SwiftStudio.app/Contents/MacOS/SwiftStudio
Expected in: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2019-03-04-a.xctoolchain/usr/lib/swift/macosx/libSwiftSyntax.dylib
Workaround:
If I delete /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2019-03-04-a.xctoolchain/usr/lib/swift/macosx/libSwiftSyntax.dylib then it links as expected.
@krzyzanowskim
Copy link
Author

krzyzanowskim commented Mar 9, 2019

Ld command

Ld /Users/marcinkrzyzanowski/Devel/SwiftStudio/DerivedData/SwiftStudio/Build/Products/Debug/SwiftStudio.app/Contents/MacOS/SwiftStudio normal x86_64 (in target: SwiftStudio)
    cd /Users/marcinkrzyzanowski/Devel/SwiftStudio
    export MACOSX_DEPLOYMENT_TARGET=10.13
    /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2019-03-04-a.xctoolchain/usr/bin/clang \
    -arch x86_64 \
    -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk \
    -L/Users/marcinkrzyzanowski/Devel/SwiftStudio/DerivedData/SwiftStudio/Build/Products/Debug \
    -L/Users/marcinkrzyzanowski/Devel/SwiftStudio/Vendors/SwiftSyntax \
    -L/Users/marcinkrzyzanowski/Devel/SwiftStudio/Vendors/SwiftPM \
    -L/Users/marcinkrzyzanowski/Devel/SwiftStudio/Vendors/SwiftSyntax \
    -F/Users/marcinkrzyzanowski/Devel/SwiftStudio/DerivedData/SwiftStudio/Build/Products/Debug \
    -filelist /Users/marcinkrzyzanowski/Devel/SwiftStudio/DerivedData/SwiftStudio/Build/Intermediates.noindex/SwiftStudio.build/Debug/SwiftStudio.build/Objects-normal/x86_64/SwiftStudio.LinkFileList \
    -Xlinker -rpath -Xlinker /usr/lib/swift \
    -Xlinker -rpath -Xlinker @executable_path/../Frameworks \
    -mmacosx-version-min=10.13 \
    -Xlinker -object_path_lto -Xlinker /Users/marcinkrzyzanowski/Devel/SwiftStudio/DerivedData/SwiftStudio/Build/Intermediates.noindex/SwiftStudio.build/Debug/SwiftStudio.build/Objects-normal-ubsan/x86_64/SwiftStudio_lto.o \
    -Xlinker -export_dynamic \
    -Xlinker -no_deduplicate \
    -Xlinker -debug_variant \
    -fobjc-link-runtime \
    -L/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2019-03-04-a.xctoolchain/usr/lib/swift/macosx \
    -Xlinker -add_ast_path -Xlinker /Users/marcinkrzyzanowski/Devel/SwiftStudio/DerivedData/SwiftStudio/Build/Intermediates.noindex/SwiftStudio.build/Debug/SwiftStudio.build/Objects-normal-ubsan/x86_64/SwiftStudio.swiftmodule \
    -lSwiftSyntax \
    /Users/marcinkrzyzanowski/Devel/SwiftStudio/DerivedData/SwiftStudio/Build/Products/Debug/ULDocument\ OS\ X.dylib \
    -lSwiftPM \
    /Users/marcinkrzyzanowski/Devel/SwiftStudio/DerivedData/SwiftStudio/Build/Products/Debug/Utils.framework/Utils \
    /Users/marcinkrzyzanowski/Devel/SwiftStudio/DerivedData/SwiftStudio/Build/Products/Debug/KPCTabsControl.framework/KPCTabsControl \
    -framework LanguageProtocolClient \
    /Users/marcinkrzyzanowski/Devel/SwiftStudio/DerivedData/SwiftStudio/Build/Products/Debug/Stencil.framework/Stencil \
    -Xlinker -dependency_info -Xlinker /Users/marcinkrzyzanowski/Devel/SwiftStudio/DerivedData/SwiftStudio/Build/Intermediates.noindex/SwiftStudio.build/Debug/SwiftStudio.build/Objects-normal-ubsan/x86_64/SwiftStudio_dependency_info.dat \
    -o /Users/marcinkrzyzanowski/Devel/SwiftStudio/DerivedData/SwiftStudio/Build/Products/Debug/SwiftStudio.app/Contents/MacOS/SwiftStudio

The only reference to toolchain is -L/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2019-03-04-a.xctoolchain/usr/lib/swift/macosx. Even though, it loads a library with a different identification name than requested @rpath/libSwiftSyntax.dylib vs @executable_path/../Frameworks/libSwiftSyntax.dylib

@krzyzanowskim
Copy link
Author

Another workaround is to rename vendored library to libSwiftSyntax-custom.dylib obviously

@akyrtzi
Copy link

akyrtzi commented Mar 9, 2019

Use env DYLD_PRINT_RPATHS=1 to see how dyld does the lookups.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment