Skip to content
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

[ESD-1931] Common compiler flags #74

Merged
merged 45 commits into from
Feb 7, 2021
Merged

Conversation

woodfell
Copy link
Contributor

@woodfell woodfell commented Feb 1, 2021

A long standing desire has been to have a common set of compiler flags for use with all Swift code. This has been tried several times in the past but never been finished, most recently by Rodrigo on whose work this PR is distantly based.

Rodrigo's work set compiler flags in the LanguageStandards module so that it would be automatically applied to everything that uses it. This is probably the way that it should be eventually, but to ease the transition I've broken it out to a separate module CompileOptions which can be applied to targets gradually until everything is up to date.

The set of compiler flags is taken from high level projects like starling and swiftlets. This means that low level libraries are now compiled with many more flags than they used to be (a good thing).

The exported function swift_set_compile_options can be called for any target. There are several options available for tailoring the set of options actually passed to the compiler, they should be fairly self explanatory.

All flags are verified against the compiler before actually being set. This is vital due to the massively diverse selection of compilers we have to cope with. Of particular note is a CI stage in (I think) libswiftnav which uses clang for C sources and gcc for c++.

So far I've tested and verified this module with every project up to and including starling and PFWP. As part of this work I've also been updating the .clang-tidy config for each project (many low level libraries didn't have one at all). This means that once this module is merged and all submodules updates Swift code will be in such a state that we no longer need to set internal projects as system includes. There aren't any compiler warnings or clang-tidy errors.

This will remain open until everything else has been proven, which hopefully won't be too long.

@woodfell woodfell changed the title Common compiler flags [ESD-1931] Common compiler flags Feb 1, 2021
Copy link
Contributor

@jbangelo jbangelo left a comment

Choose a reason for hiding this comment

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

Looks good to me. This will make things a lot more clean in our CMake files, and will help ensure we're more uniformly applying compiler options. Thanks for tackling this @woodfell !!

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