Skip to content

Driver: emit a diagnostic if clang++ is not found #25887

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 1 commit into from
Jul 2, 2019

Conversation

compnerd
Copy link
Member

Rather than aborting due to an assertion failure, emit a diagnostic.
This is much safer and generally easier to understand why the command
failed. It solves the problem of running swiftc from the build without
the path being set such that the clang++ driver is found by the swift
driver.

Replace this paragraph with a description of your changes and rationale. Provide links to external references/discussions if appropriate.

Resolves SR-NNNN.

@compnerd
Copy link
Member Author

@swift-ci please test

@compnerd
Copy link
Member Author

@swift-ci please test Windows platform

@compnerd
Copy link
Member Author

CC: @jrose-apple

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 25dfd00c6ec976e0c5a720381f12d9b73e9fbb15

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 25dfd00c6ec976e0c5a720381f12d9b73e9fbb15

@jrose-apple
Copy link
Contributor

Toolchains aren't supposed to diagnose during argument construction right now. I realize that's not enforced, but we've been doing that so far. All the other tools don't assert; they just build a command line with the missing command's name so that trying to execute them gives a "not found" error.

@compnerd
Copy link
Member Author

Alrighty, I'll just change the behavior of the toolchain here then, thanks @jrose-apple!

@compnerd compnerd force-pushed the tell-me-whats-wrong branch from 25dfd00 to a6c377a Compare July 1, 2019 01:47
@swift-ci
Copy link
Contributor

swift-ci commented Jul 1, 2019

Build failed
Swift Test Linux Platform
Git Sha - 25dfd00c6ec976e0c5a720381f12d9b73e9fbb15

@compnerd
Copy link
Member Author

compnerd commented Jul 1, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Jul 1, 2019

Build failed
Swift Test Linux Platform
Git Sha - a6c377a9c66a0b380357a90b043bda1b1f186930

@swift-ci
Copy link
Contributor

swift-ci commented Jul 1, 2019

Build failed
Swift Test OS X Platform
Git Sha - a6c377a9c66a0b380357a90b043bda1b1f186930

@compnerd
Copy link
Member Author

compnerd commented Jul 1, 2019

Apparently, setting PATH to empty is a bad idea ...

@compnerd compnerd force-pushed the tell-me-whats-wrong branch from a6c377a to 47eb0f1 Compare July 1, 2019 15:56
@compnerd
Copy link
Member Author

compnerd commented Jul 1, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Jul 1, 2019

Build failed
Swift Test Linux Platform
Git Sha - 47eb0f17b21615591a361bff4e9dce32beb8b8d0

@swift-ci
Copy link
Contributor

swift-ci commented Jul 1, 2019

Build failed
Swift Test OS X Platform
Git Sha - 47eb0f17b21615591a361bff4e9dce32beb8b8d0

@compnerd
Copy link
Member Author

compnerd commented Jul 1, 2019

@jrose-apple - sigh I don't really know how to test this. We need to ensure that SWIFT_BIN_INT_OUTDIR, /bin, and /usr/bin are not in PATH when the driver is run, and seems that emptying PATH is not exactly something which works well.

@jrose-apple
Copy link
Contributor

Well, it doesn't belong in "subcommands.swift". :-) That's things like swift build and swift package.

I don't know if I have a good answer here either. The best I can think of is setting up an artifical bin/ folder with the things you need to get to the point of generating jobs. The next best is adding a driver flag that lets you pretend all exec lookups fail or something.

@compnerd compnerd force-pushed the tell-me-whats-wrong branch from 47eb0f1 to 3a34b2a Compare July 1, 2019 18:02
@compnerd
Copy link
Member Author

compnerd commented Jul 1, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Jul 1, 2019

Build failed
Swift Test Linux Platform
Git Sha - 47eb0f17b21615591a361bff4e9dce32beb8b8d0

@swift-ci
Copy link
Contributor

swift-ci commented Jul 1, 2019

Build failed
Swift Test OS X Platform
Git Sha - 47eb0f17b21615591a361bff4e9dce32beb8b8d0

@compnerd
Copy link
Member Author

compnerd commented Jul 2, 2019

I just realized that this is easy to test - because we no longer do the search for clang++, as long as -tools-directory is not specified, then we should get an explicit "clang++" rather than /usr/bin/clang.

Rather than aborting due to an assertion failure, emit a diagnostic.
This is much safer and generally easier to understand why the command
failed.  It solves the problem of running swiftc from the build without
the path being set such that the clang++ driver is found by the swift
driver.
@compnerd compnerd force-pushed the tell-me-whats-wrong branch from 3a34b2a to 133e1f2 Compare July 2, 2019 17:21
@compnerd
Copy link
Member Author

compnerd commented Jul 2, 2019

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Jul 2, 2019

Build failed
Swift Test OS X Platform
Git Sha - 3a34b2a7bb8b3e1f4cf11d48a4cd0848c8fa3f7b

@swift-ci
Copy link
Contributor

swift-ci commented Jul 2, 2019

Build failed
Swift Test Linux Platform
Git Sha - 3a34b2a7bb8b3e1f4cf11d48a4cd0848c8fa3f7b

@compnerd
Copy link
Member Author

compnerd commented Jul 2, 2019

@swift-ci please test macOS platform

@compnerd compnerd merged commit c113db2 into swiftlang:master Jul 2, 2019
@compnerd compnerd deleted the tell-me-whats-wrong branch July 2, 2019 22:29
@davezarzycki
Copy link
Contributor

davezarzycki commented Jul 3, 2019

This broke unified builds on Linux (Fedora 30, x86-64). Was the following expected?

/home/dave/s/u/swift/test/Driver/windows-link-job.swift:2:11: error: CHECK: expected string not found in input
// CHECK: {{^}}clang++
          ^
<stdin>:1:1: note: scanning from here
/home/dave/b/u/t/bin/swift -frontend -c -primary-file SOURCE_DIR/test/Driver/windows-link-job.swift -target x86_64-unknown-windows-msvc -disable-objc-interop -autolink-library oldnames -autolink-library msvcrt -Xcc -D_MT -Xcc -D_DLL -parse-as-library -module-name link -o /tmp/lit_tmp_SROuQs/windows-link-job-138cf2.o
^
<stdin>:2:19: note: possible intended match here
/home/dave/b/u/t/bin/clang++ -shared -target x86_64-unknown-windows-msvc -nostartfiles -L /home/dave/b/u/t/lib/swift/windows/x86_64 /home/dave/b/u/t/lib/swift/windows/x86_64/swiftrt.obj /tmp/lit_tmp_SROuQs/windows-link-job-138cf2.o -o link.dll
                  ^

@davezarzycki
Copy link
Contributor

@compnerd – FYI: #25972

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.

4 participants