[libcxx-commits] [libcxx] [libc++][doc] Use installed std modules in external projects. (PR #80601)
Runzhong Li via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Mar 3 09:15:48 PST 2024
================
@@ -105,36 +105,36 @@ Users need to be able to build their own BMI files.
system vendors, with the goal that building the BMI files is done by
the build system.
-Currently this requires a local build of libc++ with modules enabled. Since
-modules are not part of the installation yet, they are used from the build
-directory. First libc++ needs to be build with module support enabled.
+Currently this requires a local build of libc++ with modules installation enabled.
+Since modules are not installed by default. You can build and install the modules
+to ``<install_prefix>`` with the following commands.
.. code-block:: bash
- $ git clone https://github.com/llvm/llvm-project.git
+ $ git clone https://github.com/llvm/llvm-project.git --depth 1
$ cd llvm-project
$ mkdir build
- $ cmake -G Ninja -S runtimes -B build -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind"
- $ ninja -C build
-
-The above ``build`` directory will be referred to as ``<build>`` in the
-rest of these instructions.
+ $ cmake -G Ninja -S runtimes -B build -DCMAKE_C_COMPILER=<path-to-compiler> -DCMAKE_CXX_COMPILER=<path-to-compiler> -DLIBCXX_INSTALL_MODULES=ON -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind"
+ $ cmake --build build -- -j $(nproc)
+ $ cmake --install build --prefix <install_prefix>
This is a small sample program that uses the module ``std``. It consists of a
-``CMakeLists.txt`` and a ``main.cpp`` file.
+``CMakeLists.txt``, an ``std.cmake``, and a ``main.cpp`` file.
.. code-block:: cpp
+ // main.cpp
import std; // When importing std.compat it's not needed to import std.
import std.compat;
int main() {
- std::cout << "Hello modular world\n";
+ std::println("Hello modular world");
----------------
a858438680 wrote:
OK, will change it back
https://github.com/llvm/llvm-project/pull/80601
More information about the libcxx-commits
mailing list