Skip to content

Conversation

@artemcm
Copy link
Contributor

@artemcm artemcm commented Oct 6, 2023

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

…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
@artemcm
Copy link
Contributor Author

artemcm commented Oct 6, 2023

@swift-ci test

@artemcm artemcm requested a review from etcwilde November 2, 2023 17:30
@artemcm
Copy link
Contributor Author

artemcm commented Nov 2, 2023

@swift-ci test

entryInput = input
} else {
entryInput = inputFiles[0].fileHandle
guard let firstSourceInputHandle = inputFiles.first(where:{ $0.type == .swift })?.fileHandle else {
Copy link
Member

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"
    ])

Copy link
Contributor Author

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.

Copy link
Member

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.

@artemcm
Copy link
Contributor Author

artemcm commented Nov 2, 2023

@swift-ci test

Copy link
Member

@etcwilde etcwilde left a comment

Choose a reason for hiding this comment

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

🚀

@artemcm artemcm merged commit e0604b6 into main Nov 15, 2023
@artemcm artemcm deleted the FixModuleOutputOfMixedTypeInputs branch November 15, 2023 16:32
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.

2 participants