Skip to content
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

swift build release-mode rebuild using previously cached .build fails with error: undefined reference to 'xxx' #8260

Open
1 task done
MahdiBM opened this issue Jan 29, 2025 · 2 comments
Labels

Comments

@MahdiBM
Copy link

MahdiBM commented Jan 29, 2025

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

  • Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands, swift build, swift test, swift package etc.

Description

vapor/penny-bot CI (link, uploaded) is failing.

I think it's because the CI file (here) uses .build caching, and SwiftNIO has removed a (C?) symbol.
swift build -c release can no longer find the related code to that symbol, so it quits.

Seems to relate to this SwiftNIO PR.

Does not happen outside release builds.

This is one of the only reasons our .build caching results in failures in CI. It's almost always due to undefined symbol errors. I've seen it happen with other libraries as well, including Foundation.

Expected behavior

No build failures.

Actual behavior

build failures.

Steps to reproduce

Have not precisely tested this steps but I'm pretty sure this is what happened:

  1. swift build -c release a package depending on SwiftNIO 2.79.0.
  2. Update SwiftNIO to 2.80.0.
  3. Rebuild.

observe: error: undefined reference to '$s7NIOCore7sysFreeyySvXCvp'

Not sure if reproducible on macOS.

Swift Package Manager version/commit hash

6.0.3 RELEASE

Swift & OS version (output of swift --version ; uname -a)

6.0.3 RELEASE

@MahdiBM MahdiBM added the bug label Jan 29, 2025
@MahdiBM
Copy link
Author

MahdiBM commented Jan 30, 2025

easy reproduction:

docker run --rm -it swift:6.0.3-jammy bash -c 'git clone https://github.com/vapor/penny-bot.git && cd penny-bot && git checkout swiftpm-cache-bug-nio-2-79-0 && swift build -c release --product Penny && git checkout swiftpm-cache-bug-nio-2-80-0 && swift build -c release --product Penny'

Result:

Building for production...
error: link command failed with exit code 1 (use -v to see invocation)
//<compiler-generated>:0: error: undefined reference to '$s7NIOCore7sysFreeyySvXCvp'
//<compiler-generated>:0: error: undefined reference to '$s7NIOCore7sysFreeyySvXCvp'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[60/61] Linking Penny

@MahdiBM
Copy link
Author

MahdiBM commented Jan 30, 2025

not sure if this is actually SwiftPM related. Feel free to move to the Swift repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant