Skip to content

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented May 3, 2023

Previously, when the compiler fails to read the result from 'getCapability' IPC message, it used to just emit a fatalError and crashed. Instead, propagate the error status and diagnose it.

rdar://108022847

@rintaro
Copy link
Member Author

rintaro commented May 3, 2023

@swift-ci Please smoke test

@rintaro rintaro requested review from DougGregor and bnbarham May 3, 2023 22:56
try plugin.initialize()
return true
} catch {
// Diagnostics are emitted in the caller.
Copy link
Contributor

@bnbarham bnbarham May 3, 2023

Choose a reason for hiding this comment

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

If we're passing in cxxDiagnosticEngine now, couldn't we just emit it here rather than return bool?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can, but there's no context information such as macro name, plugin path, etc. So the diagnostics here would be less useful.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could pass that down 🤷. Seems like at some point we either need to pass down a string that we set here (for "what happened"), or pass down the path that we then use here to emit (or some description of the plugin).

Is passing the diagnostic engine left over?

Copy link
Member Author

Choose a reason for hiding this comment

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

It was intentional leftover. I can remove it if you prefer to do so.
Or, if we really want to diagnose it here, instead of passing it down, we probably should make a CompilerPlugin API to get it. But the information we have here is not really useful as well it's just "failed to receive the response".

Copy link
Contributor

Choose a reason for hiding this comment

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

Up to you, it doesn't seem super useful to me if we're not using it (we can always add it back later).

Copy link
Member Author

Choose a reason for hiding this comment

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

I went ahead and fixed the FIXME in this PR. Added CompilerPlugin.executableFilePath property.

Previously, the compiler fails to read the result from 'getCapability'
IPC message, it used to just emit a fatalError and crashed.
Instead, propagate the error status and diagnose it.

rdar://108022847
@rintaro rintaro force-pushed the macro-plugin-intiialize-rdar108022847 branch from aaa8b4a to e55a7e2 Compare May 4, 2023 17:32
@rintaro
Copy link
Member Author

rintaro commented May 4, 2023

@swift-ci Please smoke test

Comment on lines 20 to 21
case failedToSendMessage = "couldn't send request to plugin"
case failedToReceiveMessage = "couldn't receive result from plugin"
Copy link
Contributor

Choose a reason for hiding this comment

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

failed instead of couldn't sounds a little better to me, but otherwise looks good!

@rintaro rintaro force-pushed the macro-plugin-intiialize-rdar108022847 branch from e55a7e2 to e181a4d Compare May 4, 2023 21:40
@rintaro
Copy link
Member Author

rintaro commented May 4, 2023

@swift-ci Please smoke test

@rintaro
Copy link
Member Author

rintaro commented May 5, 2023

@swift-ci Please smoke test macOS

@rintaro rintaro merged commit 0a55811 into swiftlang:main May 5, 2023
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