Skip to content

Conversation

cho-m
Copy link
Member

@cho-m cho-m commented Sep 23, 2025

  • Have you followed the guidelines for contributing?
  • Have you ensured that your commits follow the commit style guide?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>)? If this is a new formula, does it pass brew audit --new <formula>?

Will try working out issues with Swift build. macOS at least built locally. Cleaned up a few warnings.

Last local Linux run failed, so still experimenting with to fix linker problems.

Closes #244944

@cho-m cho-m added the CI-no-fail-fast Continue CI tests despite failing GitHub Actions matrix builds. label Sep 23, 2025
@github-actions github-actions bot added python Python use is a significant feature of the PR or issue long build Set a long timeout for formula testing labels Sep 23, 2025
@cho-m cho-m force-pushed the swift-6.2 branch 4 times, most recently from f4c9662 to 1631a38 Compare September 23, 2025 05:44
@cho-m

This comment was marked as resolved.

@cho-m
Copy link
Member Author

cho-m commented Sep 23, 2025

macOS (Sonoma) is still failing on audit which will prevent bottle upload:

==> FAILED
Full audit --formula swift --online --git --skip-style output
  Missing libraries:
    /usr/lib/swift/libswiftRuntime.dylib
  swift
    * swift has broken dynamic library links:

Not sure why yet.

EDIT: could be Sonoma specific? Tahoe looks okay (only the brew linkage warning which doesn't impact upload).

May need to check Sequoia run to see if we need a workaround to avoid resolving the library here given it should use the copy inside formula.

@cho-m cho-m added the brew Issue may be Homebrew/brew related label Sep 23, 2025
@Bo98
Copy link
Member

Bo98 commented Sep 23, 2025

xctoolchain/usr/libexec/swift/swift-backtrace links to /usr/lib/swift/libswiftRuntime.dylib. This was a rename of the old libswift_Backtracing.dylib in older OSes. It's intentional that swift executables link to /usr/lib/swift (we don't want external executables linking to the included stdlib), but this internal executable I guess is somewhat special.

Xcode doesn't seem to ship swift-backtrace - it'll just use the /usr/libexec/swift/swift-backtrace that ships with the OS. swift.org toolchain does ship it but also only links to the system library so would only work on macOS 26.

I guess we could either hack it for swift-backtrace or we could just skip on macOS <26 (--swift-enable-backtracing=0). I think it's more tied to the stdlib it's installed besides anyway, and the system version of that is always prioritised, so it probably makes sense to skip. When the older _Backtracing was first introduced, we also skipped shipping it for older OS.

Historically we'd skip the stdlib entirely but it's a bit more complicated nowadays to make that work. Apple probably do something special to get it to work in Xcode.app builds.

@cho-m cho-m removed the brew Issue may be Homebrew/brew related label Sep 23, 2025
@cho-m
Copy link
Member Author

cho-m commented Sep 23, 2025

With --swift-enable-backtracing=0:

FAILED: [code=1] lib/swift/macosx/arm64/libswiftRuntime.dylib 
: && /private/tmp/swift-20250923-10191-3adsrz/build/llvm-macosx-arm64/./bin/clang++ -Wno-unknown-warning-option -Werror=unguarded-availability-new -fno-stack-protector -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -O3 -DNDEBUG -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -dynamiclib -Wl,-headerpad_max_install_names -Xlinker -not_for_dyld_shared_cache -target arm64-apple-macosx14 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/../../../Developer/Library/Frameworks -Wl,-dead_strip -Wl,-sectcreate,__TEXT,__info_plist,/private/tmp/swift-20250923-10191-3adsrz/build/swift-macosx-arm64/stdlib/public/RuntimeModule/Info.plist -Wl,-application_extension -Xlinker -compatibility_version -Xlinker 1 -o lib/swift/macosx/arm64/libswiftRuntime.dylib -install_name /usr/lib/swift/libswiftRuntime.dylib stdlib/public/RuntimeModule/OSX/arm64/Runtime.o stdlib/public/RuntimeModule/CMakeFiles/swiftRuntime-macosx-arm64.dir/Win32Extras.cpp.o stdlib/public/RuntimeModule/CMakeFiles/swiftRuntime-macosx-arm64.dir/get-cpu-context.S.o -L/private/tmp/swift-20250923-10191-3adsrz/build/llvm-macosx-arm64/./lib   -L/private/tmp/swift-20250923-10191-3adsrz/build/swift-macosx-arm64/./lib/swift/macosx/arm64   -L/private/tmp/swift-20250923-10191-3adsrz/build/swift-macosx-arm64/./bin/../lib/swift/macosx/arm64   -L/private/tmp/swift-20250923-10191-3adsrz/build/swift-macosx-arm64/./bin/../lib/swift/macosx   -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/usr/lib/swift lib/swift/macosx/arm64/libswiftCxxStdlib.a  lib/swift/macosx/arm64/libswift_Concurrency.dylib  lib/swift/macosx/arm64/libswiftCxx.a  lib/swift/macosx/arm64/libswift_Builtin_float.dylib  lib/swift/macosx/arm64/libswiftCore.dylib && :
Undefined symbols for architecture arm64:
  "__swift_backtrace_demangle", referenced from:
      Runtime.SymbolicatedBacktrace.Symbol.name.getter : Swift.String in Runtime.o
  "__swift_backtrace_isThunkFunction", referenced from:
      Runtime.BacktraceFormatter.formatColumns(frame: Runtime.SymbolicatedBacktrace.Frame, index: Swift.Int?) -> [Swift.String] in Runtime.o
      Runtime.SymbolicatedBacktrace.Frame.isSwiftThunk.getter : Swift.Bool in Runtime.o
      Runtime.BacktraceFormatter.shouldSkip(Runtime.SymbolicatedBacktrace.Frame) -> Swift.Bool in Runtime.o
      generic specialization <[Runtime.SymbolicatedBacktrace.Frame]> of Runtime.BacktraceFormatter.format<A where A: Swift.Sequence, A.Element == Runtime.SymbolicatedBacktrace.Frame>(frames: A) -> Swift.String in Runtime.o
      Runtime.BacktraceFormatter.format<A where A: Swift.Sequence, A.Element == Runtime.SymbolicatedBacktrace.Frame>(frames: A) -> Swift.String in Runtime.o
      Runtime.BacktraceFormatter.format(backtrace: Runtime.SymbolicatedBacktrace) -> Swift.String in Runtime.o
      Runtime.SymbolicatedBacktrace.Frame.description.getter : Swift.String in Runtime.o
      ...
ld: symbol(s) not found for architecture arm64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

@Bo98
Copy link
Member

Bo98 commented Sep 23, 2025

Ah looks like that option is bugged in Swift 6.2 it seems. Easiest option then it just to let it build and remove the executable.

@cho-m cho-m added the CI-linux-self-hosted Build on Linux self-hosted runner label Sep 23, 2025
@cho-m
Copy link
Member Author

cho-m commented Sep 24, 2025

macOS is ready while Linux is getting closer. Seems to have gotten past where gold failed for me locally.

I think Linux may have previously worked from shim ld/ld.gold but we don't have one for lld (and it wouldn't pick it up due to PATH).

[131/142][ 92%][33.896s] : && /var/tmp/swift-20250923-13187-u897ab/build/llvm-linux-aarch64/bin/clang++ -O3 -DNDEBUG -Xlinker --dependency-file=products/llbuild/CMakeFiles/llbuild.dir/link.d products/llbuild/CMakeFiles/llbuild.dir/main.cpp.o -o bin/llbuild  -Wl,-rpath,/home/linuxbrew/.linuxbrew/lib  lib/libllbuildCommands.a  lib/libllbuildNinja.a  lib/libllbuildBuildSystem.a  lib/libllbuildCore.a  lib/libllbuildBasic.a  lib/libllvmSupport.a  /home/linuxbrew/.linuxbrew/lib/libsqlite3.so  -lcurses  lib/libllvmDemangle.a  -ldl  -lcurses && :
FAILED: [code=1] bin/llbuild 
: && /var/tmp/swift-20250923-13187-u897ab/build/llvm-linux-aarch64/bin/clang++ -O3 -DNDEBUG -Xlinker --dependency-file=products/llbuild/CMakeFiles/llbuild.dir/link.d products/llbuild/CMakeFiles/llbuild.dir/main.cpp.o -o bin/llbuild  -Wl,-rpath,/home/linuxbrew/.linuxbrew/lib  lib/libllbuildCommands.a  lib/libllbuildNinja.a  lib/libllbuildBuildSystem.a  lib/libllbuildCore.a  lib/libllbuildBasic.a  lib/libllvmSupport.a  /home/linuxbrew/.linuxbrew/lib/libsqlite3.so  -lcurses  lib/libllvmDemangle.a  -ldl  -lcurses && :
ld.lld: error: unable to find library -lcurses
ld.lld: error: unable to find library -lcurses

Maybe some -DCMAKE_*_LINKER_FLAGS could help.

@Bo98
Copy link
Member

Bo98 commented Sep 24, 2025

We apply a patch to get sqlite linking properly in llbuild. Looks like we'll need one for curses too Actually it seems to be the CMake build failing

@cho-m
Copy link
Member Author

cho-m commented Sep 25, 2025

Running with following patches. Will keep draft until can confirm everything works:

@Bo98
Copy link
Member

Bo98 commented Sep 25, 2025

Yeah the llbuild stuff is basically from them not using systemLibrary. It's the only place that it's like that and has been reported upstream before but still not fixed.

If I understand your issue correctly, the patch could be extended with:

#if os(Linux)
if let target = package.targets.first(where: { $0.name == "llvmSupport" }) {
    target.linkerSettings = [
        .linkedLibrary("ncurses"),
        .unsafeFlags(["-LHOMEBREW_PREFIX/opt/ncurses/lib"])
    ]
}
#endif

In a similar fashion to the sqlite3 patch, except there isn't an existing BSD block to hijack so would be an addition.

The generic solution here is actually just to make it use systemLibrary but I haven't looked into this properly or the reasons why it doesn't already.

@Bo98
Copy link
Member

Bo98 commented Sep 25, 2025

Ah posted that just as you linked that PR - looks like you had the same idea!

@cho-m
Copy link
Member Author

cho-m commented Sep 25, 2025

Just linkage failure on missing library left. Will need to check bottle where this is happening:

==> brew linkage --test swift
==> FAILED
Full linkage --test swift output
  Missing libraries:
    libswiftCore.so

@cho-m
Copy link
Member Author

cho-m commented Sep 25, 2025

Maybe:

objdump -p libexec/lib/swift/host/compiler/lib_InternalSwiftScan.so | rg libswiftCore.so
  NEEDED       libswiftCore.soobjdump -p libexec/lib/swift/host/compiler/lib_InternalSwiftScan.so | rg '\s*RPATH\s*(.*)' -r '$1' | tr ':' '\n' | rg ORIGIN
$ORIGIN
$ORIGIN/./swift/linux
$ORIGIN/../linux
$ORIGIN/swift/host/compiler
$ORIGIN/compilerfd libswiftCore.so
libexec/lib/swift/linux/libswiftCore.so

After library was moved in swiftlang/swift@7f67eb3

@Bo98
Copy link
Member

Bo98 commented Sep 25, 2025

Given the comment here says lib/swift/host still: https://github.com/swiftlang/swift/blob/8f7af45115e373e05d3419ab272f02700bd8a48c/lib/Tooling/libSwiftScan/CMakeLists.txt#L34-L45

It seems that's where it's outdated and should have ../../ instead of the single ../ - the commit you linked never updated it for the new directory.

Because of the symlink it's possible it may need both old (../) and new (../../) rpaths given the comment $ORIGIN can be the parent of the symbolic link inside swift/host on Linux

@cho-m cho-m added CI-no-fail-fast-deps Continue dependent tests despite failing GitHub Actions matrix tests. CI-linux-self-hosted Build on Linux self-hosted runner labels Sep 25, 2025
@cho-m
Copy link
Member Author

cho-m commented Sep 25, 2025

If builds pass but some dependents fail, may just go ahead with merge and fix those separately. Too slow to have to risk rebuilds of Swift (if bottle cache is invalidated).

Dependents are mainly on Linux where Swift formulae are less commonly installed.

Still waiting to see if x86_64 Linux is okay (previous run didn't have enough disk space). arm64 Linux was successful.


EDIT: Follow ups: https://github.com/Homebrew/homebrew-core/actions/runs/18007973778/job/51265002516?pr=245341#step:4:606

Error: 2 failed steps!
brew test --retry --verbose iblinter
brew test --retry --verbose sourcekitten

@cho-m cho-m added the ready to merge PR can be merged once CI is green label Sep 25, 2025
@cho-m cho-m requested review from a team and removed request for a team September 25, 2025 18:41
@cho-m cho-m removed the ready to merge PR can be merged once CI is green label Sep 25, 2025
@cho-m
Copy link
Member Author

cho-m commented Sep 25, 2025

I think SourceKitten doesn't like the exec scripts. When I rebuild, the current error goes away but it fails to get path to libsourcekitdInProc.so as it uses the resolved path of which swift:

https://github.com/jpsim/SourceKitten/blob/main/Source/SourceKittenFramework/library_wrapper.swift#L121-L122

I added them as Swift internally doesn't like our symlinks and complains:

warning: Unable to locate libSwiftScan. Fallback to `swift-frontend` dependency scanner invocation.

Though above at least falls back whereas SourceKitten has trouble. Since SourceKitten is a pretty common dependency, will likely need to use symlinks.


EDIT: still expected to fail until rebuild, but locally confirmed to work after rebuild when using symlinked swift.

@cho-m cho-m added the ready to merge PR can be merged once CI is green label Sep 25, 2025
@cho-m cho-m requested a review from a team September 26, 2025 01:04
Copy link
Contributor

:shipit: @cho-m has requested bottles to be published to this PR.

Caution

Please do not push to this PR branch before the bottle commits have been pushed, as this results in a state that is difficult to recover from. If you need to resolve a merge conflict, please use a merge commit. Do not force-push to this PR branch.

@github-actions github-actions bot added the CI-published-bottle-commits The commits for the built bottles have been pushed to the PR branch. label Sep 26, 2025
@BrewTestBot BrewTestBot added this pull request to the merge queue Sep 26, 2025
Merged via the queue into main with commit 4b2efa8 Sep 26, 2025
22 checks passed
@BrewTestBot BrewTestBot deleted the swift-6.2 branch September 26, 2025 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI-linux-self-hosted Build on Linux self-hosted runner CI-no-fail-fast Continue CI tests despite failing GitHub Actions matrix builds. CI-no-fail-fast-deps Continue dependent tests despite failing GitHub Actions matrix tests. CI-published-bottle-commits The commits for the built bottles have been pushed to the PR branch. long build Set a long timeout for formula testing python Python use is a significant feature of the PR or issue ready to merge PR can be merged once CI is green tahoe-bottling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants