-
Notifications
You must be signed in to change notification settings - Fork 196
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
Ensure supplementary output file maps associate Swift Source inputs with expected outputs in WMO #1459
Conversation
…ith expected outputs in WMO When handling invocations with many input kinds, it is important that the Swift compiler is passed a supplementary output filemap that maps the first `.swift` input to the expected outputs. It is already just a convention that we use the first input for a WMO compilation task. In cases where we use the first input which happens to not be a `.swift` input (e.g. a `.o` input), the Swift compiler fails to map it to expected output kinds of Swift compilation. Resolves rdar://115577783
@swift-ci test |
@swift-ci test |
@@ -686,7 +686,10 @@ extension Driver { | |||
if let input = input?.fileHandle, input != OutputFileMap.singleInputKey { | |||
entryInput = input | |||
} else { | |||
entryInput = inputFiles[0].fileHandle | |||
guard let firstSourceInputHandle = inputFiles.first(where:{ $0.type == .swift })?.fileHandle else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is more like an assert, right? The driver should never try to form a frontend invocation if there aren't swift files to compile, right? Do we have a test that tries passing -wmo
and doesn't pass any Swift source files? I seem to recall that crashing the driver for a while, so I hope so?
testWMOWithNonSourceInput
seems like it's trying, but isn't quite that:
func testWMOWithNonSourceInput() throws {
var driver1 = try Driver(args: [
"swiftc", "-whole-module-optimization", "danger.o", "foo.swift", "bar.swift", "wibble.swift", "-module-name", "Test",
"-driver-filelist-threshold=0"
])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testNoInputs
seems to cover this well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant more like swiftc -wmo danger.o
so there is an input. I just tried it with this change and it seems to work as expected.
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
When handling invocations with many input kinds, it is important that the Swift compiler is passed a supplementary output filemap that maps the first
.swift
input to the expected outputs. It is already just a convention that we use the first input for a WMO compilation task. In cases where we use the first input which happens to not be a.swift
input (e.g. a.o
input), the Swift compiler fails to map it to expected output kinds of Swift compilation.Resolves rdar://115577783