[llvm-bugs] [Bug 52340] New: [C++20] [Module] Offer a strategy to produce .pcm and .o in a single compilation

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 28 22:17:27 PDT 2021


            Bug ID: 52340
           Summary: [C++20] [Module] Offer a strategy to produce .pcm and
                    .o in a single compilation
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: yedeng.yd at linux.alibaba.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

See the discussion in
https://lists.llvm.org/pipermail/cfe-dev/2021-October/069205.html for details.
Simply, for the hello world example:

// say_hello.cpp
#include <iostream>
#include <string_view>
export module Hello;
export void SayHello
  (std::string_view const &name)
  std::cout << "Hello " << name << "!\n";
// main.cpp
#include <string_view>
import Hello;
int main() {
  return 0;

We could compile the example in GCC as:
g++ -std=c++20 -fmodules-ts say_hello.cpp main.cpp 

And in Clang, we need:

clang++ -std=c++20 say_hello.cppm --precompile -o Hello.pcm
clang++ -std=c++20 -fprebuilt-module-path=. say_hello.pcm main.cpp

It requires another line and two additional options `precompile` and
`fprebuilt-module-path`. It would be more friendly to the users.

Note that we didn't ask for use the new strategy to replace the old one. We
want to keep the two strategies until we get clear solution that how module
should interact with build systems.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211029/8e6d66e4/attachment.html>

More information about the llvm-bugs mailing list