llvmPackages.clang-tools: add support for -cxx-isystem#462747
llvmPackages.clang-tools: add support for -cxx-isystem#462747reckenrode merged 1 commit intoNixOS:stagingfrom
Conversation
This is necessary after NixOS#445095, which moved libc++ to -cxx-isystem to improve compatibility with build systems that invoke `clang` to compile C++ code.
3cd4168 to
d46fa26
Compare
|
Targeting to staging due to the number of rebuilds. |
|
I think something about this may have broken my environment. I actually do not use |
|
What branch are you using? This fix won’t land in master until after the next staging cycle. If you’re using the release-25.11 branch, it won’t land until after the next staging-25.11 cycle. From what I understand, a (likely final) staging-25.05 cycle is planned next, so it may take a little bit for the backported fix to hand in 25.11. |
|
@reckenrode On EDIT: you're right @reckenrode don't have it yet. Hopefully this PR fixes my issue. Will keep my eyes peeled. |
|
I use official |
|
Does this PR Does this PR need to land on master? |
|
It’s currently going through staging-next. |
|
Since this is a crucial component to have |
|
It has to go through staging due to the number of rebuilds it would cause. If you really need the fix, you can try using the staging-next branch. Note that some of the packages you use may not have been built yet. |
|
I just want to second that this has made |
|
for my personal projects, I created an overlay, putting that in a file in with content # Locally applying PR 462747, which modifies the wrapper, that ends up named
# clangd in the final package. So patch that `clangd` script with that change.
# The patch contains a path to the wrapper, but we apply it directly to the
# clangd script where it ends up in.
##
# Define a transformation, then apply it to all llvm versions of interest.
final: prev:
let
# Transformations for each version
patchClangTools = llvmPkgSet: llvmPkgSet.overrideScope (lfinal: lprev: {
clang-tools = lprev.clang-tools.overrideAttrs (oldAttrs: {
postInstall = (oldAttrs.postInstall or "") + ''
echo "Applying PR 462747 patch to the generated clangd wrapper..."
patch -i ${prev.fetchpatch {
url = "https://github.com/NixOS/nixpkgs/pull/462747.diff";
hash = "sha256-WDP/WJAflkYw8YQDgXK3q9G7/Z6BXTu7QpNGAKjO3co=";
}} $out/bin/clangd
'';
});
});
# ... all the llvm version we'd like to apply this to
llvm_versions = [ "17" "18" "19" "20" "21" ];
in
prev.lib.genAttrs (map (v: "llvmPackages_${v}") llvm_versions) (name:
patchClangTools prev.${name}
)
So using clang-tools now |
This makes `clangd` work again, thanks to NixOS/nixpkgs#462747 • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/c6245e83d836d0433170a16eb185cefe0572f8b8' (2025-12-18) → 'https://releases.nixos.org/nixos/25.11/nixos-25.11.2222.b3aad468604d/nixexprs.tar.xz?lastModified=1766201043&narHash=sha256-v9nbQe0BgwBx%2BKcxRf6i2kbS8EwKjBFRjAawA91B/OE%3D&rev=b3aad468604d3e488d627c0b43984eb60e75e782' (2025-12-20) Signed-off-by: Seth Flynn <getchoo@tuta.io>
This makes `clangd` work again, thanks to NixOS/nixpkgs#462747 • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/c6245e83d836d0433170a16eb185cefe0572f8b8' (2025-12-18) → 'https://releases.nixos.org/nixos/25.11/nixos-25.11.2222.b3aad468604d/nixexprs.tar.xz?lastModified=1766201043&narHash=sha256-v9nbQe0BgwBx%2BKcxRf6i2kbS8EwKjBFRjAawA91B/OE%3D&rev=b3aad468604d3e488d627c0b43984eb60e75e782' (2025-12-20) Signed-off-by: Seth Flynn <getchoo@tuta.io> (cherry picked from commit 5ee3381)
|
Also now added in master #475078 |
|
A backport to 25.11 would be very appreciated since clangd is unusable for cpp on 25.11 otherwise |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
|
The backport PR was #462884. The fix should already be in release-25.11. |
Without this change, building with -DMP_ENABLE_IWYU=ON and newer versions of nixpkgs (after 2025-11-12) fails with mysterious errors that look like: make[2]: *** [CMakeFiles/mputil.dir/build.make:79: CMakeFiles/mputil.dir/src/mp/util.cpp.o] Error 1 with no other error messages. The are no messages because cmake -E __run_co_compile hides the output from IWYU and does not display anything itself. The actual problem is missing include directories on the compiler command line, and the fix here is to extend a workaround previously added for clang-tidy to be used for IWYU as well. Breakage seems to have been caused by NixOS/nixpkgs@76a8ffa from NixOS/nixpkgs#445095, which I found by bisecting with --first-parent to a change between the following merge commit: https://github.com/NixOS/nixpkgs/commits/de21549a840be528ef4763dd7dca2006caf9c11f (bad) https://github.com/NixOS/nixpkgs/commits/c4d1151093af5d483d1900d9214a65e68bc21560 (good) If you check out the bad commit above (or any later commit) and revert NixOS/nixpkgs@76a8ffa the problem disappears. I suspect the problem happens because cmake is not handling -cxx-isystem properly, but did not debug further. The later change NixOS/nixpkgs#462747 which followed up on NixOS/nixpkgs#445095 did not seem to have any effect on this issue in my testing.
This is necessary after #445095, which moved libc++ to -cxx-isystem to improve compatibility with build systems that invoke
clangto compile C++ code.Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.Add a 👍 reaction to pull requests you find important.