-
Notifications
You must be signed in to change notification settings - Fork 197
Add support for -disable-upcoming-feature
and -disable-experimental-feature
#1730
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,14 @@ extension Driver { | |
case computed | ||
} | ||
|
||
/// If the given option is specified but the frontend doesn't support it, throw an error. | ||
func verifyFrontendSupportsOptionIfNecessary(_ option: Option) throws { | ||
if parsedOptions.hasArgument(option) && !isFrontendArgSupported(option) { | ||
diagnosticEngine.emit(.error_unsupported_opt_for_frontend(option: option)) | ||
throw ErrorDiagnostics.emitted | ||
} | ||
} | ||
|
||
/// Add frontend options that are common to different frontend invocations. | ||
mutating func addCommonFrontendOptions( | ||
commandLine: inout [Job.ArgTemplate], | ||
|
@@ -154,6 +162,9 @@ extension Driver { | |
throw ErrorDiagnostics.emitted | ||
} | ||
|
||
try verifyFrontendSupportsOptionIfNecessary(.disableUpcomingFeature) | ||
try verifyFrontendSupportsOptionIfNecessary(.disableExperimentalFeature) | ||
|
||
// Handle the CPU and its preferences. | ||
try commandLine.appendLast(.targetCpu, from: &parsedOptions) | ||
|
||
|
@@ -275,14 +286,11 @@ extension Driver { | |
if isFrontendArgSupported(.compilerAssertions) { | ||
try commandLine.appendLast(.compilerAssertions, from: &parsedOptions) | ||
} | ||
if isFrontendArgSupported(.enableExperimentalFeature) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're alright dropping There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was my thinking since they've been around for multiple releases at this point. My impression was that we only check for a flag being supported for the interim period where it is conceivable that the a frontend and driver are slightly out of sync on support for a particular flag, and that supporting mixing and matching a new driver with a much older frontend is a non-goal. Optionally dropping feature flags doesn't really seem safe to me, as they have important semantic effects. |
||
try commandLine.appendAll( | ||
.enableExperimentalFeature, from: &parsedOptions) | ||
} | ||
if isFrontendArgSupported(.enableUpcomingFeature) { | ||
try commandLine.appendAll( | ||
.enableUpcomingFeature, from: &parsedOptions) | ||
} | ||
try commandLine.appendAll(.enableExperimentalFeature, | ||
.disableExperimentalFeature, | ||
.enableUpcomingFeature, | ||
.disableUpcomingFeature, | ||
from: &parsedOptions) | ||
try commandLine.appendAll(.moduleAlias, from: &parsedOptions) | ||
if isFrontendArgSupported(.enableBareSlashRegex) { | ||
try commandLine.appendLast(.enableBareSlashRegex, from: &parsedOptions) | ||
|
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.
Nit: This is a nice utility, but the name made me do a double-take once I realized it can fail the build.
Not sure I have a better suggestion other than to reference that in
Driver.swift
we have a couple of instances ofverify*Options
methods, but those do slightly different things than this.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 like
verify
as prefix here better, I'll switch to that.