17 Commits

Author SHA1 Message Date
RichardLuo
ed1273d4dd
[libc++] change the visibility of libc++ header to public in libcxx module (#91240)
This PR addresses a problem that headers may not be able to be found if
`#include` is used with std modules.

Consider the following file:

    #include <boost/json.hpp>
    import std;

    int main(int, const char **) { }


Boost will include something from libc++, but we are using -nostdinc++
at [1] so the compiler can not find any default std header. Therefore 
the locally built header needs to be public.

[1]: 15fdd47c4b/libcxx/modules/CMakeLists.txt.in (L52)
2024-06-25 09:57:53 -05:00
Eric
2c703ed728
Rework Modules CMake to be (more) idiomatic. (#84936)
- Fix bug in documentation regarding dependencies.
- Rework Modules CMake to be (more) idiomatic.
2024-03-15 08:23:07 -04:00
Mark de Wever
fc0e9c8315
[libc++][modules] Re-add build dir CMakeLists.txt. (#81370)
This CMakeLists.txt is used to build modules without build system
support. This was removed in d06ae33ec32122bb526fb35025c1f0cf979f1090.
This is used in the documentation how to use modules.

Made some minor changes to make it work with the std.compat module using
the std module.

Note the CMakeLists.txt in the build dir should be removed once build
system support is generally available.
2024-02-13 20:04:34 +01:00
Mark de Wever
1d6b6132ff [libc++] Reland CI module improvements.
Revert "Revert #76246 and #76083"

This reverts commit 5c150e7eeba9db13cc65b329b3c3537b613ae61d.

Adds a small fix that should properly disable the tests on Windows.
Unfortunately the original poster has not provided feedback and the
original patch did not fail in the LLVM CI infrastructure.

Modules are known to fail on Windows due to non compliance of the
C library. Currently not having this patch prevents testing on other
platforms.
2024-01-21 12:10:36 +01:00
Daniel Thornburgh
5c150e7eeb Revert #76246 and #76083
These cause test build failures on Windows.

This reverts the following commits:
  57ca74843586c9a93c425036c5538aae0a2cfa60
  d06ae33ec32122bb526fb35025c1f0cf979f1090
2024-01-18 15:07:33 -08:00
Mark de Wever
d06ae33ec3
[libc++][modules] Removes module testing. (#76083)
This removes the entire modules testing infrastructure.

The current infrastructure uses CMake to generate the std and std.compat
module. This requires quite a bit of plumbing and uses CMake. Since
CMake introduced module support in CMake 3.26, modules have a higher
CMake requirement than the rest of the LLVM project. (The LLVM project
requires 3.20.) The main motivation for this approach was how libc++
generated its modules. Every header had its own module partition. This
was changed to improve performance and now only two modules remain. The
code to build these can be manually crafted.

A followup patch will reenable testing modules, using a different
approach.
2024-01-17 08:11:25 +01:00
Mark de Wever
3b0705827d
[libc++][modules] Adds CMake 3.28 support. (#75700)
This is a preparation to start using CMake 3.28 in the CI.
2023-12-18 17:49:11 +01:00
Mark de Wever
600462a2db
[libc++][modules] Adds std.compat module. (#71438)
This adds the std.compat module. The patch contains a bit of refactoring
to avoid code duplication between the std and std.compat module.

Implements parts of
- P2465R3 Standard Library Modules std and std.compat
2023-12-09 13:51:50 +01:00
Mark de Wever
d015e481d7 [libc++][C++20 modules] Tests no experimental library build.
Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158936
2023-09-06 19:31:29 +02:00
Mark de Wever
6f8b17703d [libc++][C++20 modules] Tests no except build.
Depends on D158661

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158862
2023-09-05 18:29:27 +02:00
Mark de Wever
10343c910b
[libc++][C++20 modules] Fixes CMake include paths. (#65079)
When the modules are used in a bootstrap build the paths
${LIBCXX_GENERATED_INCLUDE_DIR} and
${LIBCXX_GENERATED_INCLUDE_TARGET_DIR} have a different value and both
are needed to build modules.

This issue has been reported on Slack.
2023-09-04 20:35:46 +02:00
Mark de Wever
cfab8686bf [libc++][C++20 modules] Tests no unicode build.
Depends on D158347

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158357
2023-08-22 20:17:37 +02:00
Mark de Wever
0e26efe3dc [libc++][C++20 modules] Tests no random device build.
Depends on D158337

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158347
2023-08-22 20:16:53 +02:00
Mark de Wever
c9c71a7e0b [libc++][C++20 modules] Tests no filesystem build.
Depends on D158331

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158337
2023-08-22 20:15:59 +02:00
Mark de Wever
ef3a39160d [libc++][C++20 modules] Tests no threading build.
Depends on D158330

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D158331
2023-08-22 20:15:16 +02:00
Mark de Wever
4d4c70c91c [libc++][modules] Removes the module partitions.
This patch is based on the suggestion by @ChuanqiXu on discourse
(https://discourse.llvm.org/t/alternatives-to-the-implementation-of-std-modules/71958)

Instead of making a module partition per header every header gets an inc
file which contains the exports per header. The std module then includes
all public headers and these inc files. The one file per header is
useful for testing purposes. The CI tests whether the exports of a
header's module partition matches the "public" named declarations in the
header. With one file per header this can still be done.

The patch improves compilation time of files using "import std;" and the
size of the std module.

A comparision of the compilation speed using a libc++ test
  build/bin/llvm-lit -a -Dstd=c++23 -Denable_modules=std libcxx/test/std/modules/std.pass.cpp

Which boils down to
  import std;

  int main(int, char**) {
    std::println("Hello modular world");
    return 0;
  }
and has -ftime-report enabled

Before
===-------------------------------------------------------------------------===
                          Clang front-end time report
===-------------------------------------------------------------------------===
  Total Execution Time: 8.6585 seconds (8.6619 wall clock)

   ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
   4.5041 ( 57.2%)   0.4264 ( 54.4%)   4.9305 ( 56.9%)   4.9331 ( 57.0%)  Clang front-end timer
   3.2037 ( 40.7%)   0.2408 ( 30.7%)   3.4445 ( 39.8%)   3.4452 ( 39.8%)  Reading modules
   0.1665 (  2.1%)   0.1170 ( 14.9%)   0.2835 (  3.3%)   0.2837 (  3.3%)  Loading .../build/test/__config_module__/CMakeFiles/std.dir/std.pcm
   7.8744 (100.0%)   0.7842 (100.0%)   8.6585 (100.0%)   8.6619 (100.0%)  Total

After
===-------------------------------------------------------------------------===
                          Clang front-end time report
===-------------------------------------------------------------------------===
  Total Execution Time: 1.2420 seconds (1.2423 wall clock)

   ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
   0.8892 ( 84.6%)   0.1698 ( 88.8%)   1.0590 ( 85.3%)   1.0590 ( 85.2%)  Clang front-end timer
   0.1533 ( 14.6%)   0.0168 (  8.8%)   0.1701 ( 13.7%)   0.1704 ( 13.7%)  Reading modules
   0.0082 (  0.8%)   0.0047 (  2.5%)   0.0129 (  1.0%)   0.0129 (  1.0%)  Loading .../build/test/__config_module__/CMakeFiles/std.dir/std.pcm
   1.0507 (100.0%)   0.1913 (100.0%)   1.2420 (100.0%)   1.2423 (100.0%)  Total

Using "include <print>" instead of "import module;"
===-------------------------------------------------------------------------===
                          Clang front-end time report
===-------------------------------------------------------------------------===
  Total Execution Time: 2.1507 seconds (2.1517 wall clock)

   ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
   1.9714 (100.0%)   0.1793 (100.0%)   2.1507 (100.0%)   2.1517 (100.0%)  Clang front-end timer
   1.9714 (100.0%)   0.1793 (100.0%)   2.1507 (100.0%)   2.1517 (100.0%)  Total

It's possible to use the std module in external projects
(https://libcxx.llvm.org/Modules.html#using-in-external-projects)

Tested this with a private project to validate the size of the generated files:

Before
$ du -sch std-*
448M	std-build
508K	std-src
120K	std-subbuild
449M	total

After
$ du -sch std-*
29M	std-build
1004K	std-src
132K	std-subbuild
30M	total

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D156907
2023-08-09 19:39:08 +02:00
Mark de Wever
9b08c8a225 [libc++][modules] Adds the C++23 std module.
The patch is based on D144994.

D151030 added the module definitions for the module std.
This patch wires in the module and enables the basic testing.

Some notable features are missing:
- There is no test that libc++ can be fully imported as a module.
- This lacks the parts for the std.compat module.
- The module is not shipped with libc++.

Implements parts of
- P2465R3 Standard Library Modules std and std.compat

Reviewed By: ldionne, aaronmondal, #libc

Differential Revision: https://reviews.llvm.org/D151814
2023-06-15 18:14:15 +02:00