Skip to content

Fix #4395: Support for configurable C++ standard (e.g. C++17) when compiling C++ sources #4418

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

ekrich
Copy link
Member

@ekrich ekrich commented Jul 22, 2025

The intent here is to allow a default, and project specific settings.

This means that if someones project needs C++17 and there compiler is not new enough, things will fail. If it is the end users project wanting a newer version if should still work. We will test that out.

Comment on lines 22 to 27
/** The compiler C version -std=XXX */
def compileStdC: Option[String]

/** The compiler C++ version -std=XXX */
def compileStdCpp: Option[String]

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if maybe we should just follow the the Bazel convention here.
They're having 3 attributes (settings):
conlyopts - Add these options to the C compilation command.
copts - Add these options to the C/C++ compilation command.
cxxopts - Add these options to the C++ compilation command.

So copts is already covered by compileOptions, we could just add 2 new settings for the other two.
Searching for custom -std=X setting in LLVM is easy is relatively cheap, we can insert the defaults if there is no custom settings.
However, it would still not fix a big bigger issue - if parts of the (Scala Native C/C++) stdlib require some version od -std, let's say -std=c++14, but users code or it's dependency require newer standard it would still fail.

So maybe we can third alternative - let's define -std setting in the project descriptor so that we can always control our own sources - but allow users to use custom values for everything else. We can play with order or filtering of options coming from project descriptor over these defined by user.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking of allowing the the project descriptor so the internal libs or third party libs could select their minimum or required version.

I will have to look at the Bezel convention but Lee was making fun of cxx so maybe cpp :-) But why is copt for both C/C++? Maybe I am missing a key point here. I wanted to make it very specific so we can add other things if needed. I can work on naming etc. once I get it going.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was looking and indeed C++ has other flags specific to C++ so I understand what you were saying about finding the std flag. I will work towards that.

@ekrich ekrich force-pushed the feature/compile-std branch from e1adcc4 to d155931 Compare August 14, 2025 00:40
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.

2 participants