ho_schi
41 minutes ago
Looking at the examples from using Clang (I use GCC btw.):
clang++ -std=c++20 Hello.cppm --precompile -o Hello.pcm
clang++ -std=c++20 use.cpp -fmodule-file=Hello=Hello.pcm Hello.pcm -o Hello.out
./Hello.out
Why is something which shall makes things easy and secure so complicated?I'm used to:
g++ -o hello hello.cpp
It can use headers. Or doesn't use headers. I doesn't matter. That's the decision of the source file. To be fair, the option -std=c++20 probably isn't necessary in future.I recommend skimming over this issue from Meson:
https://github.com/mesonbuild/meson/issues/5024
Reading the last few blog posts from a developer of Meson, providing some insights why Meson doesn't support modules until now:
delta_p_delta_x
28 minutes ago
> Why is something which shall makes things easy and secure so complicated? > I'm used to: > > g++ -o hello hello.cpp
That is simple, because C++ inherited C's simplistic, primitive, and unsafe compilation and abstraction model of brute-force textual inclusion. When you scale this to a large project with hundreds of thousands of translation units, every command-line invocation becomes a huge list of flag soup that plain Makefiles become intractable.
Almost all other reasonably-recent programming languages have all of the following:
- a strong coupling of dependency management, building, installation, and publishing tools
- some description of a directed acyclic graph of dependencies, whether it be requirements.txt, cargo.toml, Maven, dotnet and Nuget .csproj files, Go modules, OPAM, PowerShell gallery, and more
- some way to describe the dependencies within the source code itself
C++20 modules are a very good thing, and enforce a stronger coupling between compiler and build tool; it's no longer just some weekend project chucking flags at g++/clang++/cl.exe but analysing source code, realising it needs a, b, c, x, y, z modules, ensuring those modules are built and export the necessary symbols, and then compiling the source at hand correctly. That is what `clang-scan-deps` does: https://clang.llvm.org/docs/StandardCPlusPlusModules.html#di...
I concede there are two problems with C++20 modules: we didn't have a working and correct compiler implementation before the paper was accepted into C++20, and secondly, the built/binary module interface specification is not fixed, so BMIs aren't (yet) portable across compilers.
The Meson developer is notorious for stirring the pot with respect to both the build system competition, and C++20 modules. The Reddit thread on his latest blog post provides a searing criticism for why he is badly mistaken: https://www.reddit.com/r/cpp/comments/1n53mpl/we_need_to_ser...
bluGill
34 minutes ago
Because hello is so simple you don't need complicated. When you are doing something complicated though you have to accept that it is complicated. I could concatenate all 20 million lines of C++ (round number) I work with into one file and building would be as simple as your hello example - but that simple building comes at great cost (you try working with a 20 million line file, and then merging it with changes someone else made) and so I'm willing to accept more complex builds.