Skip to content

Add features file describing new available flags #34697

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

Merged
merged 1 commit into from
Nov 13, 2020

Conversation

bnbarham
Copy link
Contributor

@bnbarham bnbarham commented Nov 12, 2020

The only available method to check for features at the moment is through
version checks. This is errorprone and doesn't work well for OSS
toolchains or locally built compilers.

features.json is intended to communicate to build systems that a new
flag is available, in order to assist with a transitional period where
not all supported toolchains may have a particular flag. It is not
intended to be a comprehensive report of all flags available.

Note that the names are intended to be features, so while they may match
up to the corresponding flag name, this isn't necessarily the case.

@bnbarham bnbarham requested a review from akyrtzi November 12, 2020 01:13
The only available method to check for features at the moment is through
version checks. This is errorprone and doesn't work well for OSS
toolchains or locally built compilers.

features.json is intended to communicate to build systems that a new
flag is available, in order to assist with a transitional period where
not all supported toolchains may have a particular flag. It is *not*
intended to be a comprehensive report of all flags available.

Note that the names are intended to be features, so while they may match
up to the corresponding flag name, this isn't necessarily the case.
@akyrtzi
Copy link
Contributor

akyrtzi commented Nov 12, 2020

@nkcsgexi this is an approach that avoids the complexity of needing to run the just-built compiler.
It's not a comprehensive approach though, it is intended primarily to assist in a transitional period for adopting newly added flags, not to provide a complete overview of all the available options.

@bnbarham
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi
Copy link
Contributor

nkcsgexi commented Nov 12, 2020

@akyrtzi can we just run swift-front -emit-supported-features at compile time to generate the comprehensive list? Having the list pre-generated is nice to have.

@bnbarham
Copy link
Contributor Author

Yet another option would be to just run the preprocessor on a JSON file including Options.inc (like the -emit-supported-features option does, but at compile time). Or is that what you meant @nkcsgexi?

@nkcsgexi
Copy link
Contributor

Yeah, in general I'm not a big fan of maintaining this file manually. We could potentially generate this source using the preprocessor. A better option is to change the existing .td file to a python representation and use gyb to generate C++ source and feature.json at compile time like syntax nodes.

@akyrtzi
Copy link
Contributor

akyrtzi commented Nov 12, 2020

Yeah, in general I'm not a big fan of maintaining this file manually.

There's not much maintenance involved given this is for transition of new flags only. Once you add a new flag, intended to be used by a build system, you add a new entry. After about a year we can choose to prune out old entries, assuming all supported toolchains have the flag.

Not all frontend flags we add are intended to be used a build system, having a comprehensive list is nice but I don't see a critical use case and there is inherent complexity to set up.

At a minimum we could start with the manual list of new flags for now, since it is dead-simple, and make it comprehensive later.

@nkcsgexi
Copy link
Contributor

I’m not entirely confident that every new commit of adding a compiler flag will be accompanied with an update of this json file. How would we ensure people remember doing that? Also, we need to validate this is a valid json file, ideally not manually.

@akyrtzi
Copy link
Contributor

akyrtzi commented Nov 12, 2020

I’m not entirely confident that every new commit of adding a compiler flag will be accompanied with an update of this json file. How would we ensure people remember doing that?

It is not necessary that every new commit of adding a compiler flag is added to this file. It's only necessary if we intend for the build system to use it, and the fact the build system needs to check for a "feature" name being present in the file before using the new flag is what will force and ensure its presence in the file, even if the initial swift commit happens to forget to update the file.

@bnbarham
Copy link
Contributor Author

@swift-ci please build toolchain

@swift-ci
Copy link
Contributor

Linux Toolchain (Ubuntu 16.04)
Download Toolchain
Git Sha - d57d9fd

Install command
tar zxf swift-PR-34697-497-ubuntu16.04.tar.gz
More info

@swift-ci
Copy link
Contributor

macOS Toolchain
Download Toolchain
Git Sha - d57d9fd

Install command
tar -zxf swift-PR-34697-772-osx.tar.gz --directory ~/

@bnbarham
Copy link
Contributor Author

Linux:
usr/share/swift/features.json

OSX:
Library/Developer/Toolchains/swift-PR-34697-772.xctoolchain/usr/share/swift/features.json

Looks good!

@bnbarham bnbarham merged commit cafd293 into swiftlang:main Nov 13, 2020
@bnbarham bnbarham deleted the add-feature-file branch November 13, 2020 03:19
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.

4 participants