Skip to content

[build-script] Stop installing the llbuildSwift library that is no longer used #77647

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
Dec 6, 2024

Conversation

finagolfin
Copy link
Member

I'm cross-compiling the trunk Swift 6.1 toolchain for Android and was surprised to find that this library hasn't been used by the linux toolchain in years, as the following shows no other binary links to it:

> ag --search-binary libllbuildSwift swift-5.* swift-6.0.2-RELEASE-fedora39/ swift-DEVELOPMENT-SNAPSHOT-2024-11-09-a-ubi9/
Binary file swift-5.10.1-RELEASE-fedora39/usr/lib/swift/pm/llbuild/libllbuildSwift.so matches.
Binary file swift-5.8.1-RELEASE-ubi9/usr/lib/swift/pm/llbuild/libllbuildSwift.so matches.
Binary file swift-5.9.2-RELEASE-ubi9/usr/lib/swift/pm/llbuild/libllbuildSwift.so matches.
Binary file swift-6.0.2-RELEASE-fedora39/usr/lib/swift/pm/llbuild/libllbuildSwift.so matches.
Binary file swift-DEVELOPMENT-SNAPSHOT-2024-11-09-a-ubi9/usr/lib/swift/pm/llbuild/libllbuildSwift.so matches.

I tried building SwiftPM natively on Android as part of the toolchain with this change and had no problem. The CMake-built swift-bootstrap uses this library but directly from the build directory, not from the install directory, so this pull has no effect on that.

The Windows trunk build uses the new swift-toolchain-sqlite package from @jakepetroules and doesn't appear to install this library already.

I don't know if macOS still needs this library installed, as I don't use that OS, but I can limit this change to non-Darwin if needed.

Jake and @ahoppen, let me know what you think.

@compnerd
Copy link
Member

It is shipped on Windows: https://github.com/swiftlang/swift-installer-scripts/blob/main/platforms/Windows/cli/cli.wxs#L128-L132

@finagolfin
Copy link
Member Author

@compnerd, OK, but given it isn't actually used on Unix, are you using it on Windows either?

And does anyone know the situation on macOS?

@compnerd
Copy link
Member

compnerd commented Nov 15, 2024

> link -dump -imports SwiftDriverExecution.dll | findstr llbuildSwift
    llbuildSwift.dll
                           0 $s12llbuildSwift11BuildEngineC8delegateAcA0cD8Delegate_p_tcfc
                           0 $s12llbuildSwift11BuildEngineCMa
                           0 $s12llbuildSwift11BuildEngineCMn
                           0 $s12llbuildSwift15TaskBuildEngineMp
                           0 $s12llbuildSwift19BuildEngineDelegateMp
                           0 $s12llbuildSwift3KeyVyACSays5UInt8VGcfC
                           0 $s12llbuildSwift4RuleMp
                           0 $s12llbuildSwift4TaskMp
                           0 $s12llbuildSwift5ValueVyACSays5UInt8VGcfC

I would assume that other Unicies should have a similar dependency OR they might be statically linking.

@finagolfin
Copy link
Member Author

I downloaded and checked the latest OSS trunk Nov. 14 snapshot toolchain for macOS, looks like it currently ships two copies of this dylib:

> find . -name libllbuildSwift.dylib
./usr/lib/swift/pm/llbuild/libllbuildSwift.dylib
./usr/lib/swift/macosx/libllbuildSwift.dylib

Only one library uses it, just like on Windows, and it only appears to use the one in usr/lib/swift/macosx/:

> find . -name "*.dylib" | xargs llvm-objdump --dylibs-used --macho | ag "dylib:$|libllbuildSwift.dylib" |ag -B1 "llbuildSwift.dylib "
./usr/lib/swift/pm/llbuild/libllbuildSwift.dylib:
        @rpath/libllbuildSwift.dylib (compatibility version 0.0.0, current version 0.0.0)
./usr/lib/swift/macosx/libllbuildSwift.dylib:
        @rpath/libllbuildSwift.dylib (compatibility version 0.0.0, current version 0.0.0)
./usr/lib/swift/macosx/libSwiftDriverExecution.dylib:
        @rpath/libllbuildSwift.dylib (compatibility version 0.0.0, current version 0.0.0)

> llvm-objdump --rpaths --macho usr/lib/swift/macosx/libSwiftDriverExecution.dylib
usr/lib/swift/macosx/libSwiftDriverExecution.dylib:
/usr/lib/swift

> find . -name "*.dylib" | xargs llvm-objdump --dylibs-used --macho | ag "dylib:$|libSwiftDriverExecution.dylib" | ag -B1 "libSwiftDriverExecution.dylib "
./usr/lib/swift/macosx/libSwiftDriverExecution.dylib:
        @rpath/libSwiftDriverExecution.dylib (compatibility version 0.0.0, current version 0.0.0)

> find usr/bin -type f | xargs llvm-objdump --dylibs-used --macho | ag llbuildSwift.dylib

> find usr/bin -type f | xargs llvm-objdump --dylibs-used --macho | ag ":$|libSwiftDriverExecution.dylib" | ag -B1 "libSwiftDriverExecution.dylib "
usr/bin/swift-build-sdk-interfaces:
        @rpath/libSwiftDriverExecution.dylib (compatibility version 0.0.0, current version 0.0.0)
usr/bin/swift-driver:
        @rpath/libSwiftDriverExecution.dylib (compatibility version 0.0.0, current version 0.0.0)

> llvm-objdump --rpaths --macho usr/bin/swift-build-sdk-interfaces
usr/bin/swift-build-sdk-interfaces:
/usr/lib/swift
@executable_path/../lib/swift/macosx

> llvm-objdump --rpaths --macho usr/bin/swift-driver
usr/bin/swift-driver:
/usr/lib/swift
@executable_path/../lib/swift/macosx

Since the one in usr/lib/swift/pm/llbuild/ installed by this command is unused in both the linux and macOS toolchains, should be fine to remove it in this pull, as Windows doesn't use this build-script.

@marcprux, first time I'm looking at macOS dylib dependencies and rpaths, let me know if I missed anything.

@artemcm, I see you tried to statically link on macOS and remove the copy in usr/lib/swift/macosx/ also in swiftlang/swift-driver#965 a couple years ago, but ended up having to revert it: let me know what you think of this cleanup.

This is ready for a CI run, if someone would kick one off.

@finagolfin
Copy link
Member Author

@jakepetroules, would you kick off a CI run here?

@jakepetroules
Copy link
Contributor

@swift-ci please test

@finagolfin
Copy link
Member Author

Alright, passed CI, ready for review.

Since this was added for SwiftPM in #17829 six years ago by @hartbit, but is no longer used, perhaps you can review, @bnbarham?

@finagolfin
Copy link
Member Author

@swift-ci please test

@finagolfin
Copy link
Member Author

OK, passed CI again after break, @dschaefer2, perhaps you could review, because this was originally added for SwiftPM but is now unused?

@bnbarham
Copy link
Contributor

bnbarham commented Dec 4, 2024

@swift-ci please build toolchain

@bnbarham
Copy link
Contributor

bnbarham commented Dec 4, 2024

Let's make sure the toolchain jobs pass, but as far as I can see this is not used 🤔. There's a --llbuild-link-framework in swiftpm/Utilities/bootstrap but it isn't set from build-script at all (maybe we should remove it too?).

@finagolfin
Copy link
Member Author

There's a --llbuild-link-framework in swiftpm/Utilities/bootstrap but it isn't set from build-script at all (maybe we should remove it too?).

Looks like that was added a long time ago and build-script sets it to build against the fresh llbuild in the build_root, not this installed llbuild in the toolchain. It does however add a backup rpath to this directory on macOS, so those two lines can definitely be removed after this pull, even if you don't want to remove all the logic for that now seemingly unused --llbuild-link-framework flag.

@finagolfin
Copy link
Member Author

The CI broke early yesterday, #77955, I will rerun the toolchain builds once some of the compiler fixes for that like #77959 are merged.

@finagolfin
Copy link
Member Author

Alright, toolchain builds should work now.

@swift-ci please build toolchain

@finagolfin
Copy link
Member Author

Toolchains built fine, @bnbarham, ready for review and merge.

Copy link
Contributor

@bnbarham bnbarham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CC @dschaefer2 for your info. Seems fine to me though, it doesn't appear to be used and toolchain builds passed.

@bnbarham bnbarham merged commit 95c3011 into swiftlang:main Dec 6, 2024
8 checks passed
@finagolfin
Copy link
Member Author

Thanks, I'll submit for 6.1 next.

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