<div class="__aliyun_email_body_block"><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">I got it. The key point here is that since clang's module is already used in scale. So we couldn't change it arbitrarily before we get a clear solution.</span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;"><br ></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">Thanks,</span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">Chuanqi</span></div><blockquote  style="margin-right:0;margin-top:0;margin-bottom:0;"><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">------------------------------------------------------------------</span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">From:Nathan Sidwell <nathan@acm.org></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">Send Time:2021年10月26日(星期二) 18:48</span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">To:chuanqi.xcq <yedeng.yd@linux.alibaba.com>; Richard Smith <richard@metafoo.co.uk>; David Blaikie <dblaikie@gmail.com></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">Cc:cfe-dev <cfe-dev@lists.llvm.org></span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;">Subject:Re: [cfe-dev] Make command line support for C++20 module uniform with GCC</span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;color:#000000;"><br /></span></div>On 10/25/21 22:04, chuanqi.xcq via cfe-dev wrote:<br >> Hi Blaikie,<br >> <br >>>> This sort of interaction is probably not going to be how modules are generally built/supported<br >>>> as far as I understand it - it's opaque to the build system, so may make it more difficult for the<br >>>> build system to know when things need to be rebuilt, and also wouldn't support any kind of distributed<br >>>> build system.<br >>>> <br >>>> The specifics of how GCC, Clang, (& maybe other compilers) and various build systems may end up interacting<br >>>> on the command line and filesystem (module discovery outside the current build for system-installed library<br >>>> dependencies) is still being discussed and debated in places like C++'s SG15 tooling working group.<br >> ---<br >> Understood. My point is that we could make clang support for C++20 more <br >> friendly by adding extra default behavior.<br >> And your point is that it may not be true in distributed build system.<br >> <br >>>> The specifics of how GCC, Clang, (& maybe other compilers) and various <br >> build systems may end up interacting on<br >>>> the command line and filesystem (module discovery outside the current build for system-installed library dependencies)<br >>>> is still being discussed and debated in places like C++'s SG15 tooling <br >> working group.<br >> ---<br >> I have a basic question about the Clang/LLVM policy. I remember that one <br >> of the policy of Clang/LLVM's command line system<br >> is to be compatible with GCC. This is basically true so that we could <br >> transfer the compiler used in various projects.<br >> Is this policy not true now?<br ><br >GCC had the advantage of seeing clang's experiments.  The history is <br >different for the two compilers here -- clang developed 'implicit <br >modules', driven by a large build system.  with GCC I was very mindful <br >that 'hello world' should be simple to drive -- as you have found. <br >Clang has the tricky job of not breaking its existing interface.<br ><br >As David says, what the best way to drive module compilations is no yet <br >clear.<br ><br >nathan<br ><br >> <br >> Thanks,<br >> <br >> Chuanqi<br >> <br >> <br >> <br >>     ------------------------------------------------------------------<br >>     From:David Blaikie <dblaikie@gmail.com><br >>     Send Time:2021年10月26日(星期二) 00:36<br >>     To:chuanqi.xcq <yedeng.yd@linux.alibaba.com>; Nathan Sidwell<br >>     <nathan@acm.org>; Richard Smith <richard@metafoo.co.uk><br >>     Cc:cfe-dev <cfe-dev@lists.llvm.org><br >>     Subject:Re: [cfe-dev] Make command line support for C++20 module<br >>     uniform with GCC<br >> <br >>     +Nathan and Richard as folks with some context here.<br >> <br >>     On Mon, Oct 25, 2021 at 1:57 AM chuanqi.xcq via cfe-dev<br >>     <cfe-dev@lists.llvm.org <mailto:cfe-dev@lists.llvm.org>> wrote:<br >>     Hi all,<br >> <br >>         Recently I am playing with C++20 modules and I found that the<br >>     command line support of GCC<br >>     is much better than Clang. Here is an example:<br >> <br >>     ```C++<br >>     // say_hello.cpp<br >>     module;<br >>     #include <iostream><br >>     #include <string_view><br >>     export module Hello;<br >>     export void SayHello<br >>        (std::string_view const &name)<br >>     {<br >>        std::cout << "Hello " << name << "!\n";<br >>     }<br >>     // main.cpp<br >>     #include <string_view><br >>     import Hello;<br >>     int main() {<br >>        SayHello("world");<br >>        return 0;<br >>     }<br >>     ```<br >> <br >>     To compile the example, in gcc we need:<br >>     ```<br >>     g++ -std=c++20 -fmodules-ts say_hello.cpp main.cpp<br >>     ```<br >> <br >>     And in clang, we need:<br >>     ```<br >> <br >>     clang++ -std=c++20 -fmodules-ts -Xclang -emit-module-interface -c<br >>     say_hello.cpp -o Hello.pcm<br >> <br >>     clang++ -std=c++20 -fmodules-ts -fprebuilt-module-path=. main.cpp<br >>     say_hello.cpp<br >> <br >>     ```<br >> <br >>     Yeah, in clang we need to another line to emit module interface<br >>     explicitly and another option<br >>     to tell the prebuilt-module-path. And in GCC, this happens by<br >>     default, when GCC find it is compiling<br >>     a c++20 module, it would generate the module interface automatically<br >>     to the path:<br >>     ```<br >>     gcm.cache/filename.gcm<br >>     ```<br >>     It would create `gcm.cache` in case it doesn't exist.<br >> <br >>     And GCC would search prebuilt module interface in `gcm.cache`<br >>     automatically.<br >> <br >>     It looks much more friendly to me. The intention of this mail is to<br >>     ask if you think it is the right direction<br >>     to make the clang's command line support for c++20 module more like<br >>     GCC. The different I see now includes:<br >>     - Generate prebuilt module interface automatically. (And generate it<br >>     to a specific directory automatically)<br >>     - Have a default value for prebuilt module path.<br >> <br >>     This sort of interaction is probably not going to be how modules are<br >>     generally built/supported as far as I understand it - it's opaque to<br >>     the build system, so may make it more difficult for the build system<br >>     to know when things need to be rebuilt, and also wouldn't support<br >>     any kind of distributed build system.<br >> <br >>     The specifics of how GCC, Clang, (& maybe other compilers) and<br >>     various build systems may end up interacting on the command line and<br >>     filesystem (module discovery outside the current build for<br >>     system-installed library dependencies) is still being discussed and<br >>     debated in places like C++'s SG15 tooling working group.<br >> <br >>     That doesn't mean we can't experiment further with things like this,<br >>     but I'm not sure we will/should be supporting cross-compiler<br >>     interface compatibility until we are a bit more sure about what the<br >>     best thing to standardize no is.<br >>     I am wondering if any one more familiar with the clang's command<br >>     line and file system would love to<br >>     support this (I am not so familiar with it). Although It may take<br >>     more time, I would love to support if others are busy.<br >> <br >>     Thanks,<br >>     Chuanqi<br >>     _______________________________________________<br >>     cfe-dev mailing list<br >>     cfe-dev@lists.llvm.org <mailto:cfe-dev@lists.llvm.org><br >>     https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev<br >>     <https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev><br >> <br >> <br >> <br >> _______________________________________________<br >> cfe-dev mailing list<br >> cfe-dev@lists.llvm.org<br >> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev<br >> <br ><br ><br >-- <br >Nathan Sidwell</blockquote></div>