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

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

bnbarham merged 1 commit into swiftlang:main from finagolfin:llbuildSwift
finagolfin
finagolfin254 days ago👍 2

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.

finagolfin [build-script] Stop installing the llbuildSwift library that is no lo…
85f38080
finagolfin
finagolfin254 days ago

@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
compnerd254 days ago (edited 254 days ago)
> 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
finagolfin253 days ago

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
finagolfin249 days ago👍 2

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

jakepetroules
jakepetroules249 days ago❤ 2

@swift-ci please test

finagolfin
finagolfin249 days ago

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
finagolfin235 days ago

@swift-ci please test

finagolfin
finagolfin235 days ago

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

bnbarham
bnbarham235 days ago

@swift-ci please build toolchain

bnbarham
bnbarham235 days ago (edited 235 days ago)

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
finagolfin235 days ago👍 1

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
finagolfin234 days ago

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
finagolfin233 days ago

Alright, toolchain builds should work now.

@swift-ci please build toolchain

finagolfin
finagolfin233 days ago

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

bnbarham
bnbarham approved these changes on 2024-12-06
bnbarham233 days ago

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

bnbarham bnbarham merged 95c30115 into main 233 days ago
finagolfin
finagolfin232 days ago

Thanks, I'll submit for 6.1 next.

finagolfin finagolfin deleted the llbuildSwift branch 232 days ago

Login to write a write a comment.

Login via GitHub

Reviewers
Assignees
No one assigned
Labels
Milestone