[PATCH] D121141: [Clang] Add `-fexperimental-library` flag to enable unstable and experimental features: follow-up fixes
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 16 00:19:37 PDT 2022
MaskRay added inline comments.
================
Comment at: clang/include/clang/Driver/Options.td:1186
-defm unstable : BoolFOption<"unstable",
- LangOpts<"Unstable">, DefaultFalse,
- PosFlag<SetTrue, [CC1Option, CoreOption], "Enable unstable and experimental features">,
+defm experimental_library : BoolFOption<"experimental-library",
+ LangOpts<"ExperimentalLibrary">, DefaultFalse,
----------------
ldionne wrote:
> MaskRay wrote:
> > This can be simplified with `OptInCC1FFlag` (both driver/CC1 for the pos form, but driver-only for the neg form).
> > You'll need to set CoreOption to make the option available to clang-cl.
> I was looking for documentation on `OptInCC1FFlag`, and I found:
>
> ```
> // A boolean option which is opt-in in CC1. The positive option exists in CC1 and
> // Args.hasArg(OPT_ffoo) can be used to check that the flag is enabled.
> // This is useful if the option is usually disabled.
> // Use this only when the option cannot be declared via BoolFOption.
> multiclass OptInCC1FFlag<string name, string pos_prefix, string neg_prefix="",
> ```
>
> It says to use `BoolFOption` is we can. So should I stick with `BoolFOption`?
OK. Using `BoolFOption` is fine as we can express the `ExperimentalLibrary` logic in the tablegen file. I just feel that the boilerplate is a bit higher than `OptInCC1FFlag`.
================
Comment at: clang/lib/Driver/ToolChain.cpp:1016
CmdArgs.push_back("-lc++");
+ if (Args.hasArg(options::OPT_fexperimental_library))
+ CmdArgs.push_back("-lc++experimental");
----------------
ldionne wrote:
> MaskRay wrote:
> > There may be an archive ordering problem.
> I'm not sure I follow -- what problem are you concerned about?
https://lld.llvm.org/ELF/warn_backrefs.html
When these -l options are used to link archives (.a), they should be added in a dependency order.
-lc++experimental presumably uses symbols from -lc++abi and must precede -lc++abi.
-lc++abi uses symbols from -lunwind and must precede -lunwind.
For macOS and Windows, the order usually doesn't matter.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121141/new/
https://reviews.llvm.org/D121141
More information about the cfe-commits
mailing list