[PATCH] D120160: [Clang] Add `-funstable` flag to enable unstable and experimental features

Louis Dionne via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 1 11:12:26 PST 2022


ldionne added subscribers: libc++, libc++ vendors, rsmith, CaseyCarter.
ldionne added a comment.

Oops, this seems to have happened while I was on vacation. I wanted to have a wider discussion here before shipping the patch. Let's have it now and we can make post-commit changes depending on where the discussion leads.

So, what we're trying to achieve here is to provide a user-controlled flag to enable things that are not "production ready". This includes:

- TSes (since we remove them after shipping the "real thing" for two releases)
- Standardized features that we implement only in part (for example `<ranges>`, where we don't yet have a fully coherent thing to ship, so we'd rather not pretend that we ship it in a stable way yet)
- Standardized features that we know for a fact are about to be broken by the Standard itself (this happened with `<ranges>` and `<format>` recently)

The problem this solves is that in the current state of things, we end up simply not shipping those features at all by fear that users are going to start depending on them, and then we'll break them. We want to be able to ship these features without actually committing to their stability.

We considered a few alternative directions for this patch, which we rejected:

- `-fexperimental`: We decided not to go with this because we wanted to convey the fact that said features were unstable, and hence dangerous to use in production code
- `-std=c++latest`: This would be close to what MSVC does. We decided not to go down this route because we felt like it didn't properly convey the notion of instability. Instead, we felt that `-std=c++latest` could/should be a simple alias for whatever the latest known standard is (which is not part of this patch).

Does anyone have thoughts?



================
Comment at: clang/include/clang/Basic/LangOptions.def:153
 LANGOPT(RelaxedTemplateTemplateArgs, 1, 0, "C++17 relaxed matching of template template arguments")
+LANGOPT(Unstable          , 1, 0, "Enable unstable and experimental features")
 
----------------
The documentation of this option should be way more beefy. Something like:

```
Enable unstable and experimental language and library features.

This option enables various language and library features that are either experimental (also known as TSes), or have been standardized but are not stable yet. This option should not be used in production code, since neither ABI nor API stability are guaranteed.
```

We should also provide documentation inside `clang/docs/ClangCommandLineReference.rst`.


================
Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5771
+      CmdArgs.push_back("-fcoroutines-ts");
+    CmdArgs.push_back("-fmodules-ts");
+  }
----------------
We should also be adding `-lc++experimental` if the standard library is libc++.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120160/new/

https://reviews.llvm.org/D120160



More information about the cfe-commits mailing list