Skip to content

[cmake] drop CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES injection on device sources#547

Merged
evaleev merged 1 commit into
masterfrom
evaleev/fix/no-implicit-include-injection
May 13, 2026
Merged

[cmake] drop CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES injection on device sources#547
evaleev merged 1 commit into
masterfrom
evaleev/fix/no-implicit-include-injection

Conversation

@evaleev
Copy link
Copy Markdown
Member

@evaleev evaleev commented May 13, 2026

Summary

Drop the per-device-source INCLUDE_DIRECTORIES = ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES} injection added in commit 68b87342c (Aug 2023) as a Cray-wrapper workaround.

Forwarding the host compiler's implicit include directories as per-source INCLUDE_DIRECTORIES causes CMake to emit them as -I flags, which:

  • duplicates paths the host compiler discovers implicitly (no benefit);
  • on btas_um_tensor.cpp (a CPU .cpp that ends up in the device list) re-passes /usr/include/c++/13 etc. as user-include paths, which breaks libstdc++'s #include_next <stdlib.h> from <cstdlib> under gcc-13: the search never reaches the system /usr/include because it's been shadowed by the user-include re-entries.

nvcc with `-ccbin=g++-N` already picks up host paths via the host driver, so the injection is unnecessary on modern toolchains.

Failure observed in CI (MPQC) with gcc-13 + CUDA 12.x:

```
/usr/include/c++/13/cstdlib:79:15: fatal error: stdlib.h: No such file or directory
79 | #include_next <stdlib.h>
```

Test plan

  • Local non-CUDA build still compiles
  • MPQC GitLab CI with gcc-13 + CUDA passes the previously-failing TUs (`btas_um_tensor.cpp.o`, `cpu_cuda_vector.cu.o`)

…ce sources

Forwarding the host compiler's implicit include directories as
per-source `INCLUDE_DIRECTORIES` causes CMake to emit them as `-I`
flags, which:

- duplicates paths the host compiler discovers implicitly (no benefit);
- on `btas_um_tensor.cpp` (a CPU .cpp that ends up in the device list)
  re-passes `/usr/include/c++/13` etc. as user-include paths, which
  breaks libstdc++'s `#include_next <stdlib.h>` from `<cstdlib>` under
  gcc-13: the search never reaches the system `/usr/include` because
  it's been shadowed by the user-include re-entries.

nvcc with `-ccbin=g++-N` already picks up host paths via the host
driver, so the injection is unnecessary on modern toolchains.

Failure observed in CI with gcc-13 + CUDA 12.x:
    /usr/include/c++/13/cstdlib:79:15: fatal error: stdlib.h: No such file or directory
@evaleev evaleev merged commit 03e1c9a into master May 13, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant