-
Notifications
You must be signed in to change notification settings - Fork 621
partial c++20 module support #2516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
8f46985 to
930732c
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2516 +/- ##
==========================================
+ Coverage 71.06% 71.19% +0.13%
==========================================
Files 64 64
Lines 35394 35687 +293
==========================================
+ Hits 25153 25408 +255
- Misses 10241 10279 +38 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mathstuf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks good to me. I'll probably try to test it some time next week.
I can help out with GCC module map file parsing too (it will need to actually be parsed due to the $root meta-descriptor). However, the output path is also given by it…that may prove more difficult to "know".
Thanks! It was my first time contributing to sccache so I'm not too familiar with the process. I will fix up the clippy issues + windows test issues :p |
489600b to
71e9190
Compare
|
It looks like BMI-only compilations are not properly considered: This is from running CMake's export SCCACHE_SERVER_PORT=23448 # unique to avoid ambient re-usage
export CXX="$(which sccache) $(which clang++)"
ctest -R CXXModules |
|
You can ignore the tests failing about JSON argument list mismatches; it is not robust against mutli-argument compilers like here. If you do the "symlink trick" ( |
|
Hmm, i think this is just me forgetting to change it somewhere. I will fix |
|
Okay so it seems i think we should always treat it as an object even if it really isnt... |
c0a57b6 to
8841d54
Compare
This comment was marked as outdated.
This comment was marked as outdated.
|
could you please add an integration test ? ie high level which integrates into cmake and uses C++ module. |
There are dozens of test cases within each CTest-level test. These are the relevant ones, thanks! Can you inspect the cache state ( |
Yes! |
This comment was marked as outdated.
This comment was marked as outdated.
|
https://github.com/mozilla/sccache/actions/runs/20413181927/job/58653103431 test results look good! |
|
are you sure ? |
|
That seems right no? the first time we invoke the compiler not cached yet then we invoke again and its cached. There are only 2 files to compile, so i expected it to be 4 requests 2 hit 2 misses. |
|
oh yeah, my bad, i thought we were doing a reset |
I just copied the other cmake test example, but I can reset the stats if that makes it easier to follow |
|
Gah, module compilation in the tests doesn't really happen without a setting. For
|
| } | ||
|
|
||
| if !module_only_flag { | ||
| if let Some(module_output_path) = module_output_path { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please move this into a function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can, however this function is ~550 lines, I think it would be better if in a followup PR we break up this function rather than doing a half job here by breaking up just this one conditional.
Ah, I see. Okay I will try again i think i need to setup my env to have support for import std. |
let
pkgs = import <nixpkgs> {
overlays = [
(final: prev: {
llvmPackages_21 = prev.llvmPackages_21 // {
libcxx = prev.llvmPackages_21.libcxx.overrideAttrs (old: {
postInstall = (old.postInstall or "") + ''
substituteInPlace $out/lib/libc++.modules.json \
--replace-fail '"../share' "\"$out/share"
'';
});
};
})
];
};
llvm = pkgs.llvmPackages_21;
wrappedClangScanDeps = pkgs.writeShellScriptBin "clang-scan-deps" ''
newargs=()
inject_next=false
for arg in "$@"; do
if $inject_next; then
newargs+=("$arg")
newargs+=("-isystem" "${llvm.libcxx.dev}/include/c++/v1")
inject_next=false
elif [[ "$arg" == "--" ]]; then
newargs+=("$arg")
inject_next=true
else
newargs+=("$arg")
fi
done
exec ${llvm.clang-tools}/bin/clang-scan-deps "''${newargs[@]}"
'';
sccache = "/home/troy/github/troy/sccache/result/bin/sccache";
clangWrapper = pkgs.writeShellScriptBin "clang" ''
exec ${sccache} "${llvm.libcxxClang}/bin/clang" "''${@}"
'';
clangxxWrapper = pkgs.writeShellScriptBin "clang++" ''
exec ${sccache} "${llvm.libcxxClang}/bin/clang++" "''${@}"
'';
in
pkgs.mkShell {
hardeningDisable = [ "all" ];
buildInputs = [
pkgs.cmake
pkgs.mold
pkgs.ninja
pkgs.openssl
llvm.libcxxClang
llvm.clang-tools
wrappedClangScanDeps
];
shellHook = ''
export CC="${clangWrapper}/bin/clang"
export CXX="${clangxxWrapper}/bin/clang++"
export LD_LIBRARY_PATH="${llvm.libcxx.out}/lib:${pkgs.openssl.out}/lib:''${LD_LIBRARY_PATH:-}"
export NIX_CFLAGS_COMPILE="-B${llvm.libcxx.out}/lib -isystem ${llvm.libcxx.dev}/include/c++/v1"
export PATH="${wrappedClangScanDeps}/bin:''${PATH:-}"
'';
}A huge pain... |
|
Freebsd test seems broken... Unrelated to this PR however. |
…m Avi Kivity Currently, we support ccache as the compiler cache. Since it is transparent, nothing much is needed to support it. This series adds support to sccache[1] and prefers it over ccache when it is installed. sccache brings the following benefits over ccache: 1. Integrated distributed build support similar to distcc, but with automatic toolchain packaging and a scheduler 2. Rust support 3. C++20 modules (upcoming[2]) It is the C++20 modules support that motivates the series. C++20 modules have the potential to reduce build times, but without a compiler cache and distributed build support, they come with too large a penalty. This removes the penalty. The series detects that sccache is installed, selects it if so (and if not overridden by a new option), enables it for C++ and Rust, and disables ccache transparent caching if sccache is selected. Note: this series doesn't add sccache to the frozen toolchain or add dbuild support. That is left for later. [1] https://github.com/mozilla/sccache [2] mozilla/sccache#2516 Toolchain improvement, won't be backported. Closes #27834 * github.com:scylladb/scylladb: build: apply sccache to rust builds too build: prevent double caching by compiler cache build: allow selecting compiler cache, including sccache
Adds partial support for c++20 modules when using clang.
Also detects when modules are used in MSVC / GCC and disable cache for those calls.
fixes #2216
partially addresses #2095
the clang c++20 module implementation (as well as msvc) is rather easy to parse and understand so adding support for it is fairly trivial. GCC however is a mess. An entirely different approach will be needed to get GCC module support which is far out side of the scope for this initial PR.
I will submit future PRs to get MSVC / GCC.
Test with nix