Skip to content

SR-12129: Diagnose lack of input files #72

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

Merged
merged 2 commits into from
Mar 3, 2020

Conversation

robinkunde
Copy link
Contributor

Work in progress. I'd just like to see if I'm going in the right direction.

Copy link
Contributor

@owenv owenv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach LGTM overall, just a few small comments. Thanks for fixing this!

case .invalidInput(let input):
return "invalid input: \(input)"
case .noJobsPassedToDriverFromEmptyInputFileList:
return "no input files were passed and no subsequent jobs were generated for the driver"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be best to truncate this to "no input files" for compatibility with the C++ driver

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do, but is there a way we can provide more informative error messages in the long term?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long term I think that's definitely a worthy goal. Right now, my concern is that we don't have a good way to catch regressions in the integration tests yet, and failures due to small differences like this can sometimes be hard to debug.

@@ -604,7 +621,12 @@ extension Driver {
try printVersion(outputStream: &stderrStream)
}

if jobs.isEmpty { return }
guard !jobs.isEmpty else {
guard !inputFiles.isEmpty else {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should check this before trying to plan a build. It can probably go into Planning.swift's Driver.planBuild(), so long as the driver isn't creating a REPL or immediate forwarding job (which don't require inputs).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, we'd have to move optionTable.printHelp() and printVersion() out of Driver.run() as well, correct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You would. Help is handled by this: #66

Version is a bit more interesting, there is technically 3 version flags. -v, --version, and -version. -version and --version are treated the same, they print the version information and ignore everything else (Actually help takes higher precedence over version in the c++ compiler, which isn't the case in #66 @owenv). Now -v prints the version information, but then continues on, with the only difference being that it suppresses the no input files error. You can see that here: https://github.com/apple/swift/blob/master/lib/Driver/Driver.cpp#L2157. We can mimic that logic by adding a shouldSuppressNoInputFilesError Bool that gets set to the value of parsedOptions.hasArgument(.v).

So currently --version and -version are handled in planBuild, so -v should be too, but it needs to be treated differently, not as a immediateForwardingJob.

Here are some examples from the c++ driver, that I think show all the cases I mentioned above.

colton-mac:~ colton$ swiftc -typecheck
<unknown>:0: error: no input files
colton-mac:~ colton$ swiftc --version
Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)
Target: x86_64-apple-darwin18.7.0
colton-mac:~ colton$ swiftc --version -typecheck
Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)
Target: x86_64-apple-darwin18.7.0
colton-mac:~ colton$ swiftc -v -typecheck
Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)
Target: x86_64-apple-darwin18.7.0
colton-mac:~ colton$ swiftc -v
Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)
Target: x86_64-apple-darwin18.7.0
colton-mac:~ colton$ swift -version
Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)
Target: x86_64-apple-darwin18.7.0
colton-mac:~ colton$ swift -v
Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)
Target: x86_64-apple-darwin18.7.0
/Applications/Xcode.app/Contents/Developer/usr/bin/lldb "--repl=-enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -color-diagnostics"
Welcome to Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15).
Type :help for assistance.
  1> :q
colton-mac:~ colton$ 

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, sorry for the confusion, I forgot we hadn't come up with a good solution for -v yet, this is fine to leave as-is.

@robinkunde
Copy link
Contributor Author

@cltnschlosser @owenv Hey folks, I was out sick last week and would like to move this forward now. Do I understand correctly that this is good to merge now, or should we merge #66 first and then I can make some changes to accommodate -v?

@owenv
Copy link
Contributor

owenv commented Feb 24, 2020

@robinkunde IMO this is good to merge, someone with write access will need to approve first though.

@robinkunde robinkunde changed the title WIP: SR-12129: Diagnose lack of input files SR-12129: Diagnose lack of input files Feb 25, 2020
@owenv
Copy link
Contributor

owenv commented Mar 3, 2020

@swift-ci test

1 similar comment
@owenv
Copy link
Contributor

owenv commented Mar 3, 2020

@swift-ci test

@owenv
Copy link
Contributor

owenv commented Mar 3, 2020

Thanks for fixing this @robinkunde , sorry for the delay in getting it merged!

@owenv owenv merged commit fc55317 into swiftlang:master Mar 3, 2020
fengjixuchui referenced this pull request in fengjixuchui/swift-driver Mar 4, 2020
Merge pull request apple#72 from robinkunde/rk/SR-12129
@robinkunde robinkunde deleted the rk/SR-12129 branch March 5, 2020 15:45
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

Successfully merging this pull request may close these issues.

3 participants