Hi Nathan,
> 1) 'save' -- does it *cause* the bmi to be saved, or is that actually
> controlled
by other options? (I suspect the latter)
Yes, it causes the bmi to be saved. In fact, when we add `-save-temps` option
in clang and we compile a module unit, we'll see the preprocessed output, the
bmi, the LLVM IR and the assembly code. So the semantics of the option
`-fsave-std-cxx-module-file=` is to save the bmi to the specified output.
> 2) 'std' -- why is this there. There's only one C++ std, with different
variants thereof being temporally selectable.
Since in clang we have clang c++ modules extension. It is not std one. And we
have objective C modules in clang too. So we said `std-cxx`.
> 3) 'cxx' -- why not 'c++'? Let's not let this transliteration of + to x get
into the options -- it hasn't in '-std=c++20' for example.
`c++` should be good advice.
> Might I suggest something more like '-fmodule-output='? That collates nicely
> with other -fmodule-$FOO options, and the 'output' part is similar to the
> mnemonic '-o' for the regular output file naming.
My previous concern was there were tons of `-fmodule-*` options in clang, which
are not standard c++ modules. So I was afraid the name `-fmodule-output` may be
confusing.
So I proposed `-fsave-std-cxx-module-file=`. But I didn't recognize we need to
keep the option consistency between gcc and clang until Iain mentioned it.
It is obviously redundant for gcc to keep the `-std-cxx` prefix in the name.
Personally, I feel the clearity of the option name is more important than the
length.
Since I think such flags will be mainly used by build systems/build scripts so
such flags wouldn't be typed frequently.
But command line interface consistency is very important too. I know tools
writer will hate to write tons of codes like:
```
if compiler == gcc
...
elif compiler == clang
...
```
So I think the conclusion may be:
(1) If gcc can tolerate the lengthy `-fsave-std-c++-module-file=` name, it
would be best for clang.
(2) If (1) is not acceptable and we love to keep the command line consistency,
I think clang can use '-fmodule-output=' as long as we make it clear in the
document. It will be confusing but it may be the cost clang need to pay for the
extension (so I'll vote against strongly if someone want to add some other
extensions)
> (Incidentally, as clang
treats the BMI as a step in the compilation pipeline, what do you do if you
just
want compilation to produce the BMI and no assembly artifact? Does '-o' name
the BMI in that case?)
In this case, we can use `--precompile` option in the command line. For
example, we can compile HelloWorld in clang in the following command lines now:
```
$ clang++ -std=c++20 Hello.cppm --precompile -o Hello.pcm
$ clang++ -std=c++20 -fprebuilt-module-path=. Hello.pcm -c -o Hello.o
```
If you are interested, you can take a look at:
https://clang.llvm.org/docs/StandardCPlusPlusModules.html#quick-start
Thanks,
Chuanqi
------------------------------------------------------------------
From:Nathan Sidwell <nat...@acm.org>
Send Time:2022年12月7日(星期三) 08:35
To:David Blaikie <dblai...@gmail.com>; gcc Mailing List <gcc@gcc.gnu.org>; Iain
Sandoe <i...@sandoe.co.uk>; chuanqi.xcq <yedeng...@linux.alibaba.com>
Subject:Re: Naming flag for specifying the output file name for Binary Module
Interface files
On 12/6/22 16:03, David Blaikie wrote:
> Over in https://reviews.llvm.org/D137059 we're discussing the naming
> of a clang flag - would be good to have it be consistent with GCC.
>
> The functionality is to name the BMI (.pcm in Clang's parlance) output
> file when compiling a C++20 module.
>
> Current proposal is to use `-fsave-std-cxx-module-file=` which is
> certainly precise, but maybe a bit verbose. Clang has some other flags
> related to modules that skip the std/cxx parts, and are just
> `-fmodule-*` or `-fmodules-*`, so there's some precedent for that too.
>
> Do GCC folks have any veto votes (is the currently proposed name
> especially objectionable/wouldn't be acceptable in GCC) or preferences
> (suggestions to add to the pool)?
I think the suggested option name is problematic for a number of additional
reasons:
1) 'save' -- does it *cause* the bmi to be saved, or is that actually
controlled
by other options? (I suspect the latter)
2) 'std' -- why is this there. There's only one C++ std, with different
variants thereof being temporally selectable.
3) 'cxx' -- why not 'c++'? Let's not let this transliteration of + to x get
into the options -- it hasn't in '-std=c++20' for example.
Might I suggest something more like '-fmodule-output='? That collates nicely
with other -fmodule-$FOO options, and the 'output' part is similar to the
mnemonic '-o' for the regular output file naming. (Incidentally, as clang
treats the BMI as a step in the compilation pipeline, what do you do if you
just
want compilation to produce the BMI and no assembly artifact? Does '-o' name
the BMI in that case?)
nathan
--
Nathan Sidwell