The libcxx-cxxflags file uses -cxx-isystem instead of -isystem for C++
include paths. Without handling this flag, the CPLUS_INCLUDE_PATH was
not being set correctly, causing clang-tidy to fail finding standard
library headers like <iostream> and <cstring>.
This commit was created by a combination of scripts and tools:
- an ast-grep script to prefix things in meta with `lib.`,
- a modified nixf-diagnose / nixf combination to remove unused `with
lib;`, and
- regular nixfmt.
Co-authored-by: Wolfgang Walther <walther@technowledgy.de>
- add patch from 2 upstream commits that were not backported to llvm_18
and llvm_19:
41eb186fbb
Fixes build failure with gcc15:
```
In file included from /build/mlir-src-18.1.8/mlir/lib/Dialect/Affine/IR/ValueBoundsOpInterfaceImpl.cpp:9:
/build/mlir-src-18.1.8/mlir/include/mlir/Dialect/Affine/IR/ValueBoundsOpInterfaceImpl.h:31:11:
error: 'int64_t' was not declared in this scope
31 | FailureOr<int64_t> fullyComposeAndComputeConstantDelta(Value value1,
| ^~~~~~~
/build/mlir-src-18.1.8/mlir/include/mlir/Dialect/Affine/IR/ValueBoundsOpInterfaceImpl.h:13:1:
note: 'int64_t' is defined in header '<cstdint>'; this is probably
fixable by adding '#include <cstdint>'
12 | #include "mlir/Support/LogicalResult.h"
+++ |+#include <cstdint>
13 |
```
101109fc54
Fixes failure with gcc15:
```
In file included from /build/mlir-src-19.1.7/mlir/lib/Target/SPIRV/Deserialization/Deserialization.cpp:9:
/build/mlir-src-19.1.7/mlir/include/mlir/Target/SPIRV/Deserialization.h:29:51:
error: 'uint32_t' was not declared in this scope
29 | OwningOpRef<spirv::ModuleOp> deserialize(ArrayRef<uint32_t> binary,
| ^~~~~~~~
/build/mlir-src-19.1.7/mlir/include/mlir/Target/SPIRV/Deserialization.h:18:1:
note: 'uint32_t' is defined in header '<cstdint>'; this is probably
fixable by adding '#include <cstdint>'
17 | #include "mlir/Support/LLVM.h"
+++ |+#include <cstdint>
18 |
```
First patch can be applied with `fetchpatch`, but only on llvm_19, because
of changed include line right above.
So use 2 versions of combined patches with 2 commits.
- add patch from upstream commit that was not backported to llvm_18:
bb59f04e7e
Fixes build failure with gcc15:
```
In file included from /build/lldb-src-18.1.8/lldb/source/Utility/AddressableBits.cpp:9:
/build/lldb-src-18.1.8/lldb/include/lldb/Utility/AddressableBits.h:25:27:
error: 'uint32_t' has not been declared
25 | void SetAddressableBits(uint32_t addressing_bits);
| ^~~~~~~~
/build/lldb-src-18.1.8/lldb/include/lldb/Utility/AddressableBits.h:13:1:
note: 'uint32_t' is defined in header '<cstdint>'; this is probably
fixable by adding '#include <cstdint>'
12 | #include "lldb/lldb-forward.h"
+++ |+#include <cstdint>
13 |
```
Cannot use `fetchpatch` because patch does not apply on llvm_18
(no `#include "lldb/lldb-public.h"` line on llvm_18).
- add combined patch from 2 upstream commits that were not backported
to llvm_18:
8f39502b85
Fixes build failure with gcc15:
```
In file included from /build/llvm-src-18.1.8/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.cpp:14:
/build/llvm-src-18.1.8/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.h:44:43:
error: 'uint8_t' has not been declared
44 | createAMDGPUELFObjectWriter(bool Is64Bit, uint8_t OSABI,
| ^~~~~~~
/build/llvm-src-18.1.8/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.h:19:1:
note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
18 | #include <memory>
+++ |+#include <cstdint>
19 |
```
7abf44069a
Fixes build failure with gcc15:
```
In file included from /build/llvm-src-18.1.8/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h:19,
from /build/llvm-src-18.1.8/llvm/lib/Target/X86/MCTargetDesc/X86EncodingOptimization.cpp:14:
/build/llvm-src-18.1.8/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h:86:50:
error: 'uint64_t' has not been declared
86 | int MemoryOperand, uint64_t TSFlags);
| ^~~~~~~~
/build/llvm-src-18.1.8/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h:18:1:
note: 'uint64_t' is defined in header '<cstdint>'; this is probably
fixable by adding '#include <cstdint>'
17 | #include <string>
+++ |+#include <cstdint>
18 |
```
Cannot use `fetchpatch` because second patch does not apply on llvm_18,
no `#include "llvm/ADT/SmallVector.h"` line present on llvm_18.
So vendor combined patch from 2 commits.
This is necessary after https://github.com/NixOS/nixpkgs/pull/445095,
which moved libc++ to -cxx-isystem to improve compatibility with build
systems that invoke `clang` to compile C++ code.
This was used in 4b07aeae16 to get
what was actually a *host* LLVM in practice, when the `buildHost`
LLVM package set was included in the `callPackage` scope used for
libraries. It should no longer be necessary and is now quite confusing.