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

[SR-2400] Add a flag to the driver to continue compiling after errors #45007

Closed
belkadan opened this issue Aug 18, 2016 · 7 comments
Closed

[SR-2400] Add a flag to the driver to continue compiling after errors #45007

belkadan opened this issue Aug 18, 2016 · 7 comments
Assignees
Labels
compiler The Swift compiler in itself feature A feature request or implementation good first issue Good for newcomers legacy driver Area → compiler: the integrated C++ legacy driver. Succeeded by the swift-driver project

Comments

@belkadan
Copy link
Contributor

Previous ID SR-2400
Radar rdar://problem/16221468
Original Reporter @belkadan
Type New Feature
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels New Feature, Driver, StarterBug
Assignee @modocache
Priority Medium

md5: 946c885263e3b26d1a3de37f1e6144e8

Issue Description:

Currently the Swift driver stops invoking frontend commands as soon as one of them reports an error. This behavior should be controlled by a flag, so that users can choose whether to see all the errors at once or bail out early.

Xcode also has a preference for this, so once this feature is added the Apple folks can have Xcode pass the flag automatically.

@modocache
Copy link
Mannequin

modocache mannequin commented Aug 19, 2016

This sounds like a lot of fun, and I'd like to try my hand at implementing it. Feel free to steal the task away from me if I end up taking too long, though 🙂

@modocache
Copy link
Mannequin

modocache mannequin commented Aug 20, 2016

It looks like swift::Compilation::ContinueBuildingAfterErrors is currently used to control whether to continue building after errors. A straightforward way of implementing this feature would be to add a flag such as -continue-building-after-errors, which would call swift::Compilation::setContinueBuildingAfterErrors().

On the other hand, I think the Clang compiler uses the flag -ferror-limit=123; see: http://clang.llvm.org/docs/UsersManual.html#cmdoption-ferror-limit. That option isn't a simple boolean that indicates whether to continue, it's an upper limit on the number of errors the compiler needs to encounter before it stops.

I think the Swift compiler should have a similar flag: -error-limit=123. The default limit could even be -error-limit=1, which would preserve the current behavior. I'll look into how difficult this would be to implement, but let me know if that would be beyond the scope of this task.

@belkadan
Copy link
Contributor Author

IIUC -ferror-limit is a little different: that's how many errors have to be emitted in one file before it stops printing them. I think if you pass multiple files to Clang and they all have errors it will still display all of them.

@belkadan
Copy link
Contributor Author

I forgot it was already mostly there (for migrator reasons). It's mostly just a matter of hooking it all up, I guess!

@modocache
Copy link
Mannequin

modocache mannequin commented Aug 20, 2016

Hmm, ContinueBuildingAfterErrors may not be exactly what you want here.

I tried the following: https://gist.github.com/modocache/2146da57375d772a8ec772f524f0bccf

I would have expected the test to pass. That is, compilation would fail on the first file error.swift, but because -continue-building-after-errors was specified, the next file would be compiled as well. However, this doesn't appear to be the case. Using -continue-building-after-errors produces a greater number of errors in the first file, but never continues to the next.

Either ContinueBuildingAfterErrors doesn't do exactly what we need when dealing with multiple files, or I'm missing something here. I'll look into it more tomorrow.

@modocache
Copy link
Mannequin

modocache mannequin commented Aug 20, 2016

Hmm... I'm still a little confused as to when the Swift driver continues and when it bails out early – any additional info there would be great.

I tried a few test cases and noticed setting -continue-building-after-errors did emit more failure diagnostics in many cases, so I sent up the changes along with a test case in #4437

@modocache
Copy link
Mannequin

modocache mannequin commented Aug 23, 2016

Implemented in #4437 Please close this if you consider this done, @belkadan, or let me know if there's anything more to do here.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added feature A feature request or implementation and removed new feature labels Nov 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself feature A feature request or implementation good first issue Good for newcomers legacy driver Area → compiler: the integrated C++ legacy driver. Succeeded by the swift-driver project
Projects
None yet
Development

No branches or pull requests

2 participants