Skip to content

Build fails on Linux #150

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

Closed
Kolos65 opened this issue Feb 26, 2025 · 6 comments
Closed

Build fails on Linux #150

Kolos65 opened this issue Feb 26, 2025 · 6 comments

Comments

@Kolos65
Copy link

Kolos65 commented Feb 26, 2025

OS: Ubuntu 24.04.2 LTS
Swift version: 5.10.1
swift-issue-reporting version: xctest-dynamic-overlay resolved at 1.5.2

I use swift-issue-reporting in Mockable and my Linux jobs started failing recently with the following errors:

[48/121] Compiling SwiftSyntax AbsolutePosition.swift
/home/runner/work/Mockable/Mockable/.build/checkouts/xctest-dynamic-overlay/Sources/IssueReporting/ErrorReporting.swift:78:3: error: extraneous code at top level
  ) async -> R? {
  ^~~~~~~~~~~~~~~
/home/runner/work/Mockable/Mockable/.build/checkouts/xctest-dynamic-overlay/Sources/IssueReporting/ErrorReporting.swift:1:1: error: new Swift parser generated errors for code that C++ parser accepted
/// Evaluates a throwing closure and automatically catches and reports any error thrown.
^
[49/121] Compiling SwiftSyntax AbsoluteRawSyntax.swift
/home/runner/work/Mockable/Mockable/.build/checkouts/xctest-dynamic-overlay/Sources/IssueReporting/ErrorReporting.swift:78:3: error: extraneous code at top level
  ) async -> R? {
  ^~~~~~~~~~~~~~~
/home/runner/work/Mockable/Mockable/.build/checkouts/xctest-dynamic-overlay/Sources/IssueReporting/ErrorReporting.swift:1:1: error: new Swift parser generated errors for code that C++ parser accepted
/// Evaluates a throwing closure and automatically catches and reports any error thrown.
^
[50/121] Compiling SwiftSyntax AbsoluteSyntaxInfo.swift
/home/runner/work/Mockable/Mockable/.build/checkouts/xctest-dynamic-overlay/Sources/IssueReporting/ErrorReporting.swift:78:3: error: extraneous code at top level
  ) async -> R? {
  ^~~~~~~~~~~~~~~
/home/runner/work/Mockable/Mockable/.build/checkouts/xctest-dynamic-overlay/Sources/IssueReporting/ErrorReporting.swift:1:1: error: new Swift parser generated errors for code that C++ parser accepted
/// Evaluates a throwing closure and automatically catches and reports any error thrown.
^
[51/121] Compiling SwiftSyntax Assert.swift
/home/runner/work/Mockable/Mockable/.build/checkouts/xctest-dynamic-overlay/Sources/IssueReporting/ErrorReporting.swift:78:3: error: extraneous code at top level
  ) async -> R? {
  ^~~~~~~~~~~~~~~
/home/runner/work/Mockable/Mockable/.build/checkouts/xctest-dynamic-overlay/Sources/IssueReporting/ErrorReporting.swift:1:1: error: new Swift parser generated errors for code that C++ parser accepted
/// Evaluates a throwing closure and automatically catches and reports any error thrown.
^
[52/121] Compiling SwiftSyntax BumpPtrAllocator.swift
/home/runner/work/Mockable/Mockable/.build/checkouts/xctest-dynamic-overlay/Sources/IssueReporting/ErrorReporting.swift:78:3: error: extraneous code at top level
  ) async -> R? {
  ^~~~~~~~~~~~~~~
/home/runner/work/Mockable/Mockable/.build/checkouts/xctest-dynamic-overlay/Sources/IssueReporting/ErrorReporting.swift:1:1: error: new Swift parser generated errors for code that C++ parser accepted
/// Evaluates a throwing closure and automatically catches and reports any error thrown.
@stephencelis
Copy link
Member

@Kolos65 It seems to build just fine for me. CI against Swift 6 is passing just fine:

https://github.com/pointfreeco/swift-issue-reporting/actions/runs/13486643791/job/37678634661

And when I build against a Docker image of Swift 5.10 locally, it also succeeds:

$ docker run --rm -v "$(PWD):$(PWD)" -w "$(PWD)" swift:5.10-focal bash -c 'swift build'
Building for debugging...
[0/7] Write sources
[3/7] Write swift-version-24593BA9C3E375BF.txt
[5/30] Compiling IssueReporting Unimplemented.swift
[6/30] Compiling IssueReporting WithExpectedIssue.swift
/Users/stephen/Developer/pointfreeco/xctest-dynamic-overlay/Sources/IssueReporting/WithExpectedIssue.swift:111:3: warning: default will never be executed
  @unknown default: break
  ^
/Users/stephen/Developer/pointfreeco/xctest-dynamic-overlay/Sources/IssueReporting/WithExpectedIssue.swift:274:5: warning: default will never be executed
    @unknown default: break
    ^
[7/31] Compiling IssueReporting WithIssueContext.swift
[8/31] Emitting module IssueReportingTestSupport
[9/31] Compiling IssueReportingTestSupport SwiftTesting.swift
[10/31] Compiling IssueReportingTestSupport XCTest.swift
[11/31] Compiling IssueReporting Deprecations.swift
[12/31] Compiling IssueReporting FailureObserver.swift
[13/31] Compiling IssueReporting LockIsolated.swift
[14/31] Compiling IssueReporting Rethrows.swift
[15/31] Compiling IssueReporting IsTesting.swift
[16/31] Compiling IssueReporting IssueReporter.swift
[17/31] Compiling IssueReporting Warn.swift
/Users/stephen/Developer/pointfreeco/xctest-dynamic-overlay/Sources/IssueReporting/Internal/Warn.swift:2:19: remark: '@preconcurrency' attribute on module 'Foundation' is unused
  @preconcurrency import Foundation
  ~~~~~~~~~~~~~~~~^
  
[18/31] Compiling IssueReporting XCTest.swift
/Users/stephen/Developer/pointfreeco/xctest-dynamic-overlay/Sources/IssueReporting/Internal/Warn.swift:2:19: remark: '@preconcurrency' attribute on module 'Foundation' is unused
  @preconcurrency import Foundation
  ~~~~~~~~~~~~~~~~^
  
[19/31] Compiling IssueReporting TestContext.swift
[20/31] Compiling IssueReporting SwiftTesting.swift
[21/31] Compiling IssueReporting UncheckedSendable.swift
[22/31] Compiling IssueReporting BreakpointReporter.swift
[23/31] Compiling IssueReporting FatalErrorReporter.swift
[24/31] Compiling IssueReporting RuntimeWarningReporter.swift
/Users/stephen/Developer/pointfreeco/xctest-dynamic-overlay/Sources/IssueReporting/ReportIssue.swift:79:3: warning: default will never be executed
  @unknown default: break
  ^
/Users/stephen/Developer/pointfreeco/xctest-dynamic-overlay/Sources/IssueReporting/ReportIssue.swift:149:3: warning: default will never be executed
  @unknown default: break
  ^
[25/31] Compiling IssueReporting ReportIssue.swift
/Users/stephen/Developer/pointfreeco/xctest-dynamic-overlay/Sources/IssueReporting/ReportIssue.swift:79:3: warning: default will never be executed
  @unknown default: break
  ^
/Users/stephen/Developer/pointfreeco/xctest-dynamic-overlay/Sources/IssueReporting/ReportIssue.swift:149:3: warning: default will never be executed
  @unknown default: break
  ^
[26/31] Emitting module IssueReporting
/Users/stephen/Developer/pointfreeco/xctest-dynamic-overlay/Sources/IssueReporting/ReportIssue.swift:79:3: warning: default will never be executed
  @unknown default: break
  ^
/Users/stephen/Developer/pointfreeco/xctest-dynamic-overlay/Sources/IssueReporting/ReportIssue.swift:149:3: warning: default will never be executed
  @unknown default: break
  ^
/Users/stephen/Developer/pointfreeco/xctest-dynamic-overlay/Sources/IssueReporting/WithExpectedIssue.swift:111:3: warning: default will never be executed
  @unknown default: break
  ^
/Users/stephen/Developer/pointfreeco/xctest-dynamic-overlay/Sources/IssueReporting/WithExpectedIssue.swift:274:5: warning: default will never be executed
    @unknown default: break
    ^
[27/31] Compiling IssueReporting ErrorReporting.swift
[28/31] Compiling IssueReporting AppHostWarning.swift
[30/33] Wrapping AST for IssueReportingTestSupport for debugging
[31/33] Write Objects.LinkFileList
[33/36] Compiling XCTestDynamicOverlay Exports.swift
[33/36] Linking libIssueReportingTestSupport.so
[35/36] Emitting module XCTestDynamicOverlay
[36/36] Compiling XCTestDynamicOverlay Deprecations.swift
Build complete! (4.58s)

Can you share a repro of the issue using Docker instructions?

@gohanlon
Copy link

gohanlon commented Mar 5, 2025

I ran into this exact same Linux build issue on CI today. I don't think this is fixable in swift-issue-reporting, but I can't say so definitively.

My CI was using swift-actions/setup-swift@v2 like this:

  linux:
    name: Linux
    runs-on: ubuntu-latest
    steps:
      - name: Install Swift
        uses: swift-actions/setup-swift@v2
        with:
          swift-version: "5.10"
      - uses: actions/checkout@v4
      - name: Run tests
        run: swift test

I upped the Swift version to swift-version: "6.0.2", and that resolved the build errors. I'm not doing matrix testing across Swift versions on Linux, so I'm satisfied with this change.

I didn't manage to pin down the root cause, but the "error: new Swift parser generated errors for code that C++ parser accepted" appears to be from an assertion that was accidentally enabled in some release toolchain builds.

For reasons I don't understand, I too wasn't able to produce a failing build using Docker. Upping my CI to "5.10.1" from "5.10" didn't fix my CI build issue (which isn't surprising, considering that's the version @Kolos65 reported to be not working for them). I'm not sure why the Docker build works for 5.10/5.10.1* but using the 5.10.1 toolchain directly doesn't. The official Dockerfile simply copies in the toolchain release.

Note *
The "5.10" Docker tags point at "5.10.1" images. When swift-actions/setup-swift is given "5.10" it actually runs Swift 5.10, not 5.10.1. It doesn't use Docker builds, it downloads toolchains like this:

https://swift.org/builds/swift-5.10.1-release/ubuntu24.04/swift-5.10.1-RELEASE/swift-5.10.1-RELESASE-ubuntu24.04.tar.gz

which redirects to the same host used in the Dockerfile: https://download.swift.org/…

In case it's helpful, here's a failing Linux CI build: https://github.com/gohanlon/swift-memberwise-init-macro/actions/runs/13663459138/job/38199622506

gohanlon added a commit to gohanlon/swift-memberwise-init-macro that referenced this issue Mar 5, 2025
This works around an (erroneous) compiler build error on
swift-issue-reporting.

See: pointfreeco/swift-issue-reporting#150
@stephencelis
Copy link
Member

Sounds like a toolchain issue then! Going to close this out for now. Thanks for the sleuthing @gohanlon!

@gohanlon
Copy link

gohanlon commented Mar 5, 2025

@stephencelis In case you're interested in supporting 5.10 and 5.10.1 toolchain builds, I came across a reasonable (if somewhat unfortunate) looking workaround: https://github.com/swift-server/async-http-client/pull/810/files

If @Kolos65's and my CI build failures are representative, the fix would be to change the whitespace in ErrorReporting.swift around the two function declarations within the #if compiler(>=6) directive, and adding // swift-format-ignore to the file.

One more follow-up thought: The errantly included assertions compare some C++ parser's behavior to Swift's own C++ parsing. Because the Docker builds use the release toolchain, the most likely explanation is that the reference C++ parser dependency used in the Docker builds is different than the C++ parser available in the swift-actions/setup-swift build environment.

I don't know if there will be a 5.10.2 release that would fix this. I'd hope so, as I've read reports that even successful builds with 5.10 are slow, which would make sense if the compiler is unnecessarily parsing everything twice—once with Swift and once with a C++ parser. And, it feels surreal to be suggesting making whitespace changes to Swift code in order to fix parsing differences between C++ compilers.

gohanlon added a commit to gohanlon/swift-memberwise-init-macro that referenced this issue Mar 5, 2025
This works around an (erroneous) compiler build error on
swift-issue-reporting.

See: pointfreeco/swift-issue-reporting#150
@stephencelis
Copy link
Member

@gohanlon We'd be down for a fix if it's not too much trouble! Would you be up to PR?

@Kolos65
Copy link
Author

Kolos65 commented May 6, 2025

@stephencelis Created a PR for this and tested the workaround in Mockable.

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

No branches or pull requests

3 participants