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" command duplicates error messages #1387

Open
Stiivi opened this issue Jun 16, 2023 · 8 comments
Open

"swift build" command duplicates error messages #1387

Stiivi opened this issue Jun 16, 2023 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@Stiivi
Copy link

Stiivi commented Jun 16, 2023

Description
swift build command prints the same error multiple times. Example output:

% swift build
Building for debugging...
error: emit-module command failed with exit code 1 (use -v to see invocation)
/home/stefan/Dupe/Sources/Dupe/Dupe.swift:4:9: error: consecutive statements on a line must be separated by ';'
let this is error
        ^
        ;
/home/stefan/Dupe/Sources/Dupe/Dupe.swift:4:10: error: expected expression
let this is error
         ^
/home/stefan/Dupe/Sources/Dupe/Dupe.swift:4:5: error: type annotation missing in pattern
let this is error
    ^
/home/stefan/Dupe/Sources/Dupe/Dupe.swift:4:9: error: consecutive statements on a line must be separated by ';'
let this is error
        ^
        ;
/home/stefan/Dupe/Sources/Dupe/Dupe.swift:4:10: error: expected expression
let this is error
         ^
/home/stefan/Dupe/Sources/Dupe/Dupe.swift:4:5: error: type annotation missing in pattern
let this is error
    ^
error: fatalError

EDIT: In one of my projects (can't share the source) the error has been duplicated 16 times.

Steps to reproduce

  1. Create a new package:
    • mkdir Dupe
    • cd Dupe
    • swift package init
  2. Create an erroneous source file:
    • echo "let this is error" > Sources/Dupe/Dupe.swift
  3. Run swift build

Expected behavior

Each error is displayed only once.

@Stiivi Stiivi added the bug Something isn't working label Jun 16, 2023
@AnthonyLatsis
Copy link

Shorter — swiftc -emit-module -enable-batch-mode Dupe.swift where Dupe.swift contains anything that must not parse, e.g. let. The culprit is -enable-batch-mode and the duplication does not reproduce with the old driver.

@hamishknight Please see to the transfer.

@hamishknight
Copy link
Contributor

Interesting, we appear to be creating two -emit-module jobs, one of them seems like an intermediate output that would have previously been used for merge-modules (or I guess maybe it's still required to ensure we type-check function bodies?):

❯ ./swiftc -emit-module -enable-batch-mode ~/src/swift-test-arena/swift-test-arena/main.swift -###
/Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/bin/swift-frontend -frontend -emit-module -primary-file /Users/hamish/src/swift-test-arena/swift-test-arena/main.swift -target x86_64-apple-macosx13.0 -warn-on-potentially-unavailable-enum-case -enable-objc-interop -color-diagnostics -new-driver-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/bin/swift-driver -empty-abi-descriptor -resource-dir /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/lib/swift -module-name main -plugin-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/lib/swift/host/plugins -plugin-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/local/lib/swift/host/plugins -o /var/folders/3m/l5fbv4dn6wz112cw2nhjq69h0000gn/T/TemporaryDirectory.jKvDlg/main-2.swiftmodule
/Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/bin/swift-frontend -frontend -emit-module -experimental-skip-non-inlinable-function-bodies-without-types /Users/hamish/src/swift-test-arena/swift-test-arena/main.swift -target x86_64-apple-macosx13.0 -warn-on-potentially-unavailable-enum-case -enable-objc-interop -color-diagnostics -new-driver-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/bin/swift-driver -empty-abi-descriptor -resource-dir /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/lib/swift -module-name main -plugin-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/lib/swift/host/plugins -plugin-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/local/lib/swift/host/plugins -emit-module-doc-path main.swiftdoc -emit-module-source-info-path main.swiftsourceinfo -o main.swiftmodule -emit-abi-descriptor-path main.abi.json
❯ ./swiftc -enable-batch-mode -emit-module ~/src/swift-test-arena/swift-test-arena/main.swift -v
Swift version 5.9-dev (LLVM dcb09f599ae5aa9, Swift edc003ac9278d7c)
Target: x86_64-apple-macosx13.0
/Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/bin/swift-frontend -frontend -emit-module -primary-file /Users/hamish/src/swift-test-arena/swift-test-arena/main.swift -target x86_64-apple-macosx13.0 -warn-on-potentially-unavailable-enum-case -enable-objc-interop -color-diagnostics -new-driver-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/bin/swift-driver -empty-abi-descriptor -resource-dir /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/lib/swift -module-name main -plugin-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/lib/swift/host/plugins -plugin-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/local/lib/swift/host/plugins -o /var/folders/3m/l5fbv4dn6wz112cw2nhjq69h0000gn/T/TemporaryDirectory.lfL6bi/main-2.swiftmodule
/Users/hamish/src/swift-test-arena/swift-test-arena/main.swift:2365:4: error: expected pattern
var
   ^
/Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/bin/swift-frontend -frontend -emit-module -experimental-skip-non-inlinable-function-bodies-without-types /Users/hamish/src/swift-test-arena/swift-test-arena/main.swift -target x86_64-apple-macosx13.0 -warn-on-potentially-unavailable-enum-case -enable-objc-interop -color-diagnostics -new-driver-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/bin/swift-driver -empty-abi-descriptor -resource-dir /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/lib/swift -module-name main -plugin-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/lib/swift/host/plugins -plugin-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/local/lib/swift/host/plugins -emit-module-doc-path main.swiftdoc -emit-module-source-info-path main.swiftsourceinfo -o main.swiftmodule -emit-abi-descriptor-path main.abi.json
error: emit-module command failed with exit code 1 (use -v to see invocation)
/Users/hamish/src/swift-test-arena/swift-test-arena/main.swift:2365:4: error: expected pattern
var
   ^
error: fatalError

Without -enable-batch-mode, we appear to do the same thing, but the jobs are the other way around, and we appear to bail after the first failure:

❯ ./swiftc -emit-module ~/src/swift-test-arena/swift-test-arena/main.swift -###
/Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/bin/swift-frontend -frontend -emit-module -experimental-skip-non-inlinable-function-bodies-without-types /Users/hamish/src/swift-test-arena/swift-test-arena/main.swift -target x86_64-apple-macosx13.0 -warn-on-potentially-unavailable-enum-case -enable-objc-interop -color-diagnostics -new-driver-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/bin/swift-driver -empty-abi-descriptor -resource-dir /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/lib/swift -module-name main -plugin-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/lib/swift/host/plugins -plugin-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/local/lib/swift/host/plugins -emit-module-doc-path main.swiftdoc -emit-module-source-info-path main.swiftsourceinfo -o main.swiftmodule -emit-abi-descriptor-path main.abi.json
/Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/bin/swift-frontend -frontend -emit-module -primary-file /Users/hamish/src/swift-test-arena/swift-test-arena/main.swift -target x86_64-apple-macosx13.0 -warn-on-potentially-unavailable-enum-case -enable-objc-interop -color-diagnostics -new-driver-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/bin/swift-driver -empty-abi-descriptor -resource-dir /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/lib/swift -module-name main -plugin-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/lib/swift/host/plugins -plugin-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/local/lib/swift/host/plugins -o /var/folders/3m/l5fbv4dn6wz112cw2nhjq69h0000gn/T/TemporaryDirectory.TqvOsn/main-1.swiftmodule
❯ ./swiftc -emit-module ~/src/swift-test-arena/swift-test-arena/main.swift -v
Swift version 5.9-dev (LLVM dcb09f599ae5aa9, Swift edc003ac9278d7c)
Target: x86_64-apple-macosx13.0
/Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/bin/swift-frontend -frontend -emit-module -experimental-skip-non-inlinable-function-bodies-without-types /Users/hamish/src/swift-test-arena/swift-test-arena/main.swift -target x86_64-apple-macosx13.0 -warn-on-potentially-unavailable-enum-case -enable-objc-interop -color-diagnostics -new-driver-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/bin/swift-driver -empty-abi-descriptor -resource-dir /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/lib/swift -module-name main -plugin-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/lib/swift/host/plugins -plugin-path /Users/hamish/src/swift-dev/build/Release/swift-macosx-x86_64/local/lib/swift/host/plugins -emit-module-doc-path main.swiftdoc -emit-module-source-info-path main.swiftsourceinfo -o main.swiftmodule -emit-abi-descriptor-path main.abi.json
error: emit-module command failed with exit code 1 (use -v to see invocation)
/Users/hamish/src/swift-test-arena/swift-test-arena/main.swift:2365:4: error: expected pattern
var
   ^
error: fatalError

@hamishknight hamishknight transferred this issue from swiftlang/swift Jun 26, 2023
@artemcm artemcm self-assigned this Jun 26, 2023
@artemcm
Copy link
Contributor

artemcm commented Jun 26, 2023

Ugh.
https://github.com/apple/swift-driver/blob/main/Sources/SwiftDriver/Jobs/Planning.swift#L456

@cpisciotta
Copy link

Hi @artemcm. I'm seeing a similar issue with xcodebuild and an Xcode project. Is this likely the same issue? Should I file a separate GitHub issue? I already filed a TSI and FB report with the logs for reference.

@artemcm
Copy link
Contributor

artemcm commented Jul 26, 2023

@cpisciotta could you please post the FB number here?

@cpisciotta
Copy link

@artemcm FB12568959

@cpisciotta
Copy link

Hey, @artemcm! Just checking in...

  • Should I assume the root cause of this issue is the same as the one I see with xcodebuild? If not, should I create a new GitHub issue?
  • Is there any additional context I can provide to help investigate a fix for this issue?

@cpisciotta
Copy link

Hey, @artemcm. Checking in on this again...

Is there any progress or update on this issue? It's causing some issues for my team when we use xcodebuild. It'd be helpful to set expectations about the priority and timeline for a possible fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants
@Stiivi @artemcm @hamishknight @AnthonyLatsis @cpisciotta and others