Skip to content

[Frontend] Add a way to print features supported by the compiler #80833

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Apr 15, 2025

  • Replace -emit-supported-features with -emit-supported-arguments mode because "features" part was never implemented.
  • Introduce -print-supported-features option that prints supported upcoming/experimental features and their metadata.

@xedin
Copy link
Contributor Author

xedin commented Apr 15, 2025

swiftlang/swift-driver#1875
@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Apr 15, 2025

@swift-ci please test

Comment on lines 54 to 70
out << " \"SupportedFeatures\": {\n";
out << " \"Upcoming\": [\n";
llvm::interleave(upcoming, printFeature, [&out] { out << ",\n"; });
out << "\n ],\n";

out << " \"Experimental\": [\n";
llvm::interleave(experimental, printFeature, [&out] { out << ",\n"; });
out << "\n ]\n";

out << " }\n";
out << "}\n";
Copy link
Collaborator

Choose a reason for hiding this comment

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

We are using both snake case and upper camel case for keys. Should we be consistent?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I was thinking maybe “feature_flags” maybe

Copy link
Collaborator

Choose a reason for hiding this comment

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

supported_features or even just features sounds fine to me too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's just go with "features".

out << ", \"adoptable\": true";
}
if (auto version = feature.getLanguageVersion()) {
out << ", \"introduced_in\": " << *version;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could be confused with when the feature was actually introduced. Maybe enabled_in?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used the phrasing from the Features.def but don’t have a strong preference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It wasn't in Features.def it's in Features.h for Feature::getLanguageVersion().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to enabled_in and adoptable -> migratable

Copy link
Collaborator

Choose a reason for hiding this comment

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

cc @hborla

Migratable was my suggestion.

@xedin
Copy link
Contributor Author

xedin commented Apr 16, 2025

I added a test for -print-supported-features but it got lost among trying to get -emit-supported-features work, will bring it back tomorrow.

@xedin xedin force-pushed the print-supported-features branch from 8649e82 to 91e20ab Compare April 16, 2025 18:20
@xedin
Copy link
Contributor Author

xedin commented Apr 16, 2025

@swift-ci please test

1 similar comment
@xedin
Copy link
Contributor Author

xedin commented Apr 16, 2025

@swift-ci please test

@xedin
Copy link
Contributor Author

xedin commented Apr 16, 2025

@swift-ci please test macOS platform

@xedin
Copy link
Contributor Author

xedin commented Apr 16, 2025

@swift-ci please test Linux platform

This is a replacement for `-emit-supported-features` that prints
all of the upcoming/experimental features supported by the compiler
with some additional meta information in JSON format to stdout.
@xedin xedin force-pushed the print-supported-features branch from 91e20ab to 62d4b00 Compare April 16, 2025 23:35
@xedin
Copy link
Contributor Author

xedin commented Apr 16, 2025

@swift-ci please clean test

@xedin
Copy link
Contributor Author

xedin commented Apr 17, 2025

@swift-ci please test Linux platform

1 similar comment
@xedin
Copy link
Contributor Author

xedin commented Apr 17, 2025

@swift-ci please test Linux platform

@xedin
Copy link
Contributor Author

xedin commented Apr 17, 2025

swiftlang/swift-driver#1875
@swift-ci please test

…ed-arguments`

The "featues" part was never actually implemented and Swift Driver
is replying on information about arguments, so instead of removing
this mode, let's scope it down to "arguments" to be deprecated in
the future.
@xedin xedin force-pushed the print-supported-features branch from 62d4b00 to 18703d6 Compare April 17, 2025 19:33
@xedin
Copy link
Contributor Author

xedin commented Apr 17, 2025

@swift-ci please test

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.

3 participants