You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With adoption of Macros, one of the dependencies required to be added is swift-syntax, or other larger projects. Unfortunately this increases build time significantly and there is no simple way to distribute pre-built binaries of larger more complicated projects like swift-syntax.
The one way working way involves creating an xcodeproj using Swift 5.7 via swift package generate-xcodeproj (as it was removed in #5748) and from there the dynamic libraries linking is preserved if using xcodebuild properly (as was done here); but there is no native SwiftPM way of creating libraries/frameworks that achieves the correct dynamically linked libraries that I have found.
The generated xcodeproj preserves the dependencies and linking structure:
Currently there is a feature gap of creating and using pre-built binaries: #7035
Expected behavior
A dynamic library which depends on another library, which too is dynamic should link to it rather than fully embedding it.
otool -L InstantSyntax/509.1.1/SwiftSyntaxMacros.xcframework/macos-arm64_x86_64/SwiftSyntaxMacros.framework/SwiftSyntaxMacros
InstantSyntax/509.1.1/SwiftSyntaxMacros.xcframework/macos-arm64_x86_64/SwiftSyntaxMacros.framework/SwiftSyntaxMacros (architecture x86_64):
@rpath/SwiftSyntaxMacros.framework/Versions/A/SwiftSyntaxMacros (compatibility version 0.0.0, current version 0.0.0)
@rpath/SwiftSyntaxBuilder.framework/Versions/A/SwiftSyntaxBuilder (compatibility version 0.0.0, current version 0.0.0)
@rpath/SwiftParserDiagnostics.framework/Versions/A/SwiftParserDiagnostics (compatibility version 0.0.0, current version 0.0.0)
@rpath/SwiftBasicFormat.framework/Versions/A/SwiftBasicFormat (compatibility version 0.0.0, current version 0.0.0)
@rpath/SwiftParser.framework/Versions/A/SwiftParser (compatibility version 0.0.0, current version 0.0.0)
@rpath/SwiftDiagnostics.framework/Versions/A/SwiftDiagnostics (compatibility version 0.0.0, current version 0.0.0)
@rpath/SwiftSyntax.framework/Versions/A/SwiftSyntax (compatibility version 0.0.0, current version 0.0.0)
@rpath/SwiftSyntax509.framework/Versions/A/SwiftSyntax509 (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 1336.61.1)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1600.157.0)
/usr/lib/swift/libswiftCore.dylib (compatibility version 1.0.0, current version 5.9.2)
/usr/lib/swift/libswiftCoreFoundation.dylib (compatibility version 1.0.0, current version 120.100.0, weak)
/usr/lib/swift/libswiftDarwin.dylib (compatibility version 1.0.0, current version 0.0.0, weak)
/usr/lib/swift/libswiftDispatch.dylib (compatibility version 1.0.0, current version 34.0.2, weak)
/usr/lib/swift/libswiftIOKit.dylib (compatibility version 1.0.0, current version 1.0.0, weak)
/usr/lib/swift/libswiftOSLog.dylib (compatibility version 1.0.0, current version 4.0.0, weak)
/usr/lib/swift/libswiftObjectiveC.dylib (compatibility version 1.0.0, current version 8.0.0, weak)
/usr/lib/swift/libswiftXPC.dylib (compatibility version 1.0.0, current version 29.0.2, weak)
/usr/lib/swift/libswiftos.dylib (compatibility version 1.0.0, current version 1040.0.0, weak)
/usr/lib/swift/libswiftFoundation.dylib (compatibility version 1.0.0, current version 1.0.0, weak)
InstantSyntax/509.1.1/SwiftSyntaxMacros.xcframework/macos-arm64_x86_64/SwiftSyntaxMacros.framework/SwiftSyntaxMacros (architecture arm64):
@rpath/SwiftSyntaxMacros.framework/Versions/A/SwiftSyntaxMacros (compatibility version 0.0.0, current version 0.0.0)
@rpath/SwiftSyntaxBuilder.framework/Versions/A/SwiftSyntaxBuilder (compatibility version 0.0.0, current version 0.0.0)
@rpath/SwiftParserDiagnostics.framework/Versions/A/SwiftParserDiagnostics (compatibility version 0.0.0, current version 0.0.0)
@rpath/SwiftBasicFormat.framework/Versions/A/SwiftBasicFormat (compatibility version 0.0.0, current version 0.0.0)
@rpath/SwiftParser.framework/Versions/A/SwiftParser (compatibility version 0.0.0, current version 0.0.0)
@rpath/SwiftDiagnostics.framework/Versions/A/SwiftDiagnostics (compatibility version 0.0.0, current version 0.0.0)
@rpath/SwiftSyntax.framework/Versions/A/SwiftSyntax (compatibility version 0.0.0, current version 0.0.0)
@rpath/SwiftSyntax509.framework/Versions/A/SwiftSyntax509 (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 1336.61.1)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1600.157.0)
/usr/lib/swift/libswiftCore.dylib (compatibility version 1.0.0, current version 5.9.2)
/usr/lib/swift/libswiftCoreFoundation.dylib (compatibility version 1.0.0, current version 120.100.0, weak)
/usr/lib/swift/libswiftDarwin.dylib (compatibility version 1.0.0, current version 0.0.0, weak)
/usr/lib/swift/libswiftDispatch.dylib (compatibility version 1.0.0, current version 34.0.2, weak)
/usr/lib/swift/libswiftIOKit.dylib (compatibility version 1.0.0, current version 1.0.0, weak)
/usr/lib/swift/libswiftOSLog.dylib (compatibility version 1.0.0, current version 4.0.0, weak)
/usr/lib/swift/libswiftObjectiveC.dylib (compatibility version 1.0.0, current version 8.0.0, weak)
/usr/lib/swift/libswiftXPC.dylib (compatibility version 1.0.0, current version 29.0.2, weak)
/usr/lib/swift/libswiftos.dylib (compatibility version 1.0.0, current version 1040.0.0, weak)
/usr/lib/swift/libswiftFoundation.dylib (compatibility version 1.0.0, current version 1.0.0, weak)
Actual behavior
A dynamic library which has a dependency on dynamic library embeds all dependencies:
$ otool -L .build/debug/libSwiftSyntaxMacros.dylib
.build/debug/libSwiftSyntaxMacros.dylib:
@rpath/libSwiftSyntaxMacros.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1336.61.1)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1600.157.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/usr/lib/swift/libswiftCore.dylib (compatibility version 1.0.0, current version 5.9.2)
/usr/lib/swift/libswiftCoreFoundation.dylib (compatibility version 1.0.0, current version 120.100.0, weak)
/usr/lib/swift/libswiftDarwin.dylib (compatibility version 1.0.0, current version 0.0.0, weak)
/usr/lib/swift/libswiftDispatch.dylib (compatibility version 1.0.0, current version 34.0.2, weak)
/usr/lib/swift/libswiftIOKit.dylib (compatibility version 1.0.0, current version 1.0.0, weak)
/usr/lib/swift/libswiftOSLog.dylib (compatibility version 1.0.0, current version 4.0.0, weak)
/usr/lib/swift/libswiftObjectiveC.dylib (compatibility version 1.0.0, current version 8.0.0, weak)
/usr/lib/swift/libswiftXPC.dylib (compatibility version 1.0.0, current version 29.0.2, weak)
/usr/lib/swift/libswiftos.dylib (compatibility version 1.0.0, current version 1040.0.0)
/usr/lib/swift/libswiftFoundation.dylib (compatibility version 1.0.0, current version 1.0.0, weak)
This results in large binary size:
$ du -sh .build/release/libSwiftSyntaxMacros.dylib
18M .build/release/libSwiftSyntaxMacros.dylib
While xcodebuild dynamically linked results in:
$ du -sh InstantSyntax/509.1.1/SwiftSyntaxMacros.xcframework/macos-arm64_x86_64/SwiftSyntaxMacros.framework/Versions/A/SwiftSyntaxMacros
324K InstantSyntax/509.1.1/SwiftSyntaxMacros.xcframework/macos-arm64_x86_64/SwiftSyntaxMacros.framework/Versions/A/SwiftSyntaxMacros
$ otool -L .build/debug/libSwiftSyntaxMacros.dylib
.build/debug/libSwiftSyntaxMacros.dylib:
@rpath/libSwiftSyntaxMacros.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1336.61.1)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1600.157.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/usr/lib/swift/libswiftCore.dylib (compatibility version 1.0.0, current version 5.9.2)
/usr/lib/swift/libswiftCoreFoundation.dylib (compatibility version 1.0.0, current version 120.100.0, weak)
/usr/lib/swift/libswiftDarwin.dylib (compatibility version 1.0.0, current version 0.0.0, weak)
/usr/lib/swift/libswiftDispatch.dylib (compatibility version 1.0.0, current version 34.0.2, weak)
/usr/lib/swift/libswiftIOKit.dylib (compatibility version 1.0.0, current version 1.0.0, weak)
/usr/lib/swift/libswiftOSLog.dylib (compatibility version 1.0.0, current version 4.0.0, weak)
/usr/lib/swift/libswiftObjectiveC.dylib (compatibility version 1.0.0, current version 8.0.0, weak)
/usr/lib/swift/libswiftXPC.dylib (compatibility version 1.0.0, current version 29.0.2, weak)
/usr/lib/swift/libswiftos.dylib (compatibility version 1.0.0, current version 1040.0.0)
/usr/lib/swift/libswiftFoundation.dylib (compatibility version 1.0.0, current version 1.0.0, weak)
Additionally, when using xcodebuild archive to create the library/framework, the linking dependencies are lost too:
Description
With adoption of Macros, one of the dependencies required to be added is swift-syntax, or other larger projects. Unfortunately this increases build time significantly and there is no simple way to distribute pre-built binaries of larger more complicated projects like swift-syntax.
The one way working way involves creating an
xcodeproj
using Swift 5.7 viaswift package generate-xcodeproj
(as it was removed in #5748) and from there the dynamic libraries linking is preserved if using xcodebuild properly (as was done here); but there is no native SwiftPM way of creating libraries/frameworks that achieves the correct dynamically linked libraries that I have found.The generated xcodeproj preserves the dependencies and linking structure:
Currently there is a feature gap of creating and using pre-built binaries: #7035
Expected behavior
A dynamic library which depends on another library, which too is dynamic should link to it rather than fully embedding it.
The frameworks that are build by Xcode have the following linking between frameworks (from https://github.com/johnno1962/InstantSyntax):
Actual behavior
A dynamic library which has a dependency on dynamic library embeds all dependencies:
This results in large binary size:
While xcodebuild dynamically linked results in:
Steps to reproduce
Additionally, when using xcodebuild archive to create the library/framework, the linking dependencies are lost too:
This may be #4781 but it is not clear.
Swift Package Manager version/commit hash
5.9.0
Swift & OS version (output of
swift --version ; uname -a
)The text was updated successfully, but these errors were encountered: