-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Plugin: Stop building with -enable-testing
even with release config
#8025
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
Plugin: Stop building with -enable-testing
even with release config
#8025
Conversation
@swift-ci test |
@swift-ci test |
I haven't dug in but I would suggest making sure the flag is still set when calling |
65bb939
to
9dbba7b
Compare
9dbba7b
to
eff0cbc
Compare
@grynspan That's a good point. I added a validation test for |
@swift-ci test |
@swift-ci test windows |
@plemarquand FYI |
Wouldn't changing flags with swift test, or --build-tests, trigger an expensive full rebuild? |
@dschaefer2 No full rebuilding triggered between |
The community is very sensitive to build times, especially when macros are involved as is the case with swift-testing. And the worst case is building SwiftSyntax in release mode which can take up to 5 minutes. |
@dschaefer2 First of all, this PR does not change the build behavior triggered by the CLI but changes the build behavior triggered through Package Plugin APIs to be aligned with today's CLI's behavior. Back to the build time tradeoff, I agree that today's CLI behavior is arguable. I think we have three options:
I think the current behavior is a good balance option given that most developers rarely use |
If we do continue with this change, let's make sure to run a full toolchain build against it. |
I verified this change doesn't work full toolchain build :) Since 1. this change does not change anything in CLI behavior but just for package plugin invocations (not related to macro plugins, to be clear), 2. also it just aligns with the current CLI behavior, and 3. we are suffering from a huge performance regression due to this issue, I'd like to proceed this change and discuss the incremental build topic as a separate issue (#8031) |
"Doesn't work" or "doesn't break"? 😬 |
"Doesn't break"😅 |
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.
LGTM, but I hope @xedin could have a look before this is merged
cc @rauhul who's building in release configuration for embedded |
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.
Makes sense to me for both to be consistent. Once it is decided what release
behavior in regards to testability should be (@rauhul has a thread about that on forums) we could change both places to reflect that.
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.
Agreed.
Motivation:
When building a SwiftPM target through PackagePlugin APIs and overall configuration is debug, they were built with
-enable-testing
even with plugins requests building with release configuration.This mis-configuration led performance and code size regression only when building through package plugins.
The root problem is that some of the properties under
BuildParameters
store values derived from other properties.buildParameters.testing.enableTestability
was one of them. It depends onconfiguration
but it's computed only inBuildParameters.Testing
initializer. Therefore the property was not updated afterPluginDelegate
modifiesconfiguration
for requested builds.swift-package-manager/Sources/Commands/Utilities/PluginDelegate.swift
Lines 118 to 127 in 23fa281
swift-package-manager/Sources/SPMBuildCore/BuildParameters/BuildParameters+Testing.swift
Line 107 in 23fa281
For those who want an immediate workaround: One of the workaround was to set the overall configuration as release, but it forces building plugins as release too.
Modifications:
This PR made those properties that depend on other stored properties as computed properties rather than stored ones.
There are still some properties having the same issue (
BuildParameters.Debugging
), so I'll fix them in a follow-up PR separately.Result:
Release builds requested through package plugins are truly built as release mode even if the overall configuration is debug.