All the literature about modules is quite recently new, and I am struggling with one core concept thing.
When I make my own modules, after the linkage process, does exists a conventional or accepted way of package those modules to distribute them as a library?
CodePudding user response:
Perhaps you are confusing modules and packages. Modules is how the compiler sees code. Packages are how the result of compiled code are distributed. I do not think modules tackle the packaging problem at this point. There is a paper on the ISO committee but it is just a proposal at this point.
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2473r1.pdf
That said, it looks like all compilers are struggling to get modules up and running. It is a tough problem to solve. For example, macros are not possible to be exported with modules.
At this point only MSVC supports it fully. Gcc and Clang are partial only. STL modules are not supported by any compiler at this point.
https://en.cppreference.com/w/cpp/compiler_support
CodePudding user response:
Broadly speaking, the products of building a module's interface (as distinct from the linker-products of compilation, like a static/shared library) are not sharable between compilers. At least not the way that compiled libraries for the same OS/platform are. The module format used by compilers may not even be stable between compiler versions.
As such, if you want to ship a pre-compiled library that was build using modules, then just like non-module builds, you will need to ship textual files that are used to consume that module. Specifically, you need all of the interface units for any modules built into that library. Implementation units need not be give, as their products are all in the compiled form of the library.
Perhaps in the future, compilers for the same platform will standardize a compiled module format, or even across platforms. But until then, you're going to have to keep shipping text with your pre-compiled libraries.