Skip to content

[Comgr][test] Add -nostdinc++ to compile_hip_with_libcxx_test#2444

Open
lamb-j wants to merge 3 commits into
amd-stagingfrom
users/lambj/comgr-libcxx-test-nostdinc
Open

[Comgr][test] Add -nostdinc++ to compile_hip_with_libcxx_test#2444
lamb-j wants to merge 3 commits into
amd-stagingfrom
users/lambj/comgr-libcxx-test-nostdinc

Conversation

@lamb-j
Copy link
Copy Markdown
Collaborator

@lamb-j lamb-j commented May 7, 2026

Summary

compile_hip_with_libcxx_test claims to verify that embedded libc++ headers work with HIP compilation, but only passes -nogpuinc -- which disables GPU-specific includes but leaves system C++ header lookup enabled. On systems with system libstdc++ installed at clang's default search path (manylinux / RHEL with gcc-toolset), the test silently exercises system libstdc++, not the embedded headers.

Worse, on RHEL/manylinux specifically, the test fails at amd_comgr_do_action():

In file included from /tmp/.../test_libcxx.hip:8:
In file included from /bin/../lib/gcc/x86_64-redhat-linux/8/.../include/c++/8/tuple:39:
In file included from .../include/c++/8/array:39:
In file included from .../include/c++/8/stdexcept:38:
In file included from .../include/c++/8/exception:143:
In file included from .../include/c++/8/bits/exception_ptr.h:38:
In file included from .../include/c++/8/bits/cxxabi_init_exception.h:38:
include/c++/v1/stddef.h:39:15: fatal error: 'stddef.h' file not found
   39 | #include_next <stddef.h>
1 error generated when compiling for gfx906.

Root cause

  1. Test #include <tuple>.
  2. Clang resolves <tuple> to system gcc-8 libstdc++ (/usr/lib/gcc/.../include/c++/8/tuple) because the embedded libc++ is injected at -idirafter priority (comgr-compiler.cpp:1211-1216).
  3. gcc's tuple transitively pulls in <exception_ptr.h> -> <cxxabi_init_exception.h> -> <stddef.h>.
  4. That stddef.h resolves to libc++'s include/c++/v1/stddef.h (VFS-mapped to clang's resource dir).
  5. libc++'s stddef.h does #include_next <stddef.h> -- but under HIP --offload-device-only with -nogpuinc, no further stddef.h is available on the device include path. Chain breaks.

Fix

Add -nostdinc++ to the test's compile options so clang only finds the embedded headers, which is what the test name and comments claim to verify. Tested in the manylinux container -- test now passes.

This was caught by the new SPIRV CI workflow on ROCm/SPIRV-LLVM-Translator PR #178, which builds Comgr inside the manylinux container that other compiler-stack workflows use.

Follow-up

Filed a separate issue tracking the broader design question (whether comgr should auto-inject -nostdinc++ with -nogpuinc, or promote the embedded libc++ from -idirafter to -isystem so users don't have to opt in explicitly).

@z1-cciauto
Copy link
Copy Markdown
Collaborator

@z1-cciauto
Copy link
Copy Markdown
Collaborator

lamb-j added a commit that referenced this pull request May 7, 2026
## Summary

Disable `compile_hip_with_libcxx_test` -- it currently fails on systems
with system libstdc++ at clang's default search path (manylinux/RHEL
with gcc-toolset). Root cause and proper fix tracked in #2444 and #2445;
will be re-enabled by #2444 once that lands.

Co-authored-by: Claude <noreply@anthropic.com>
lamb-j and others added 3 commits May 7, 2026 15:10
The test claims to verify that embedded libc++ headers work with HIP
compilation, but only passes -nogpuinc -- which disables GPU-specific
includes but leaves system C++ header lookup enabled.

On systems with system libstdc++ installed at clang's default search
path (manylinux/RHEL with gcc-toolset), clang resolves <tuple> to the
system header, which transitively pulls in <stddef.h> from
cxxabi_init_exception.h. That stddef.h resolves to clang's libc++
stddef.h, which does #include_next <stddef.h>. Under HIP
--offload-device-only mode there is no next stddef.h on the device
include path, so the chain breaks:

  In file included from .../cxxabi_init_exception.h:38:
  include/c++/v1/stddef.h:39:15: fatal error: 'stddef.h' file not found
     39 | #include_next <stddef.h>

This is a real coverage gap in the test (it isn't actually verifying
the embedded headers in environments that have system libstdc++) and a
silent failure mode of the underlying COMPILE_SOURCE_WITH_DEVICE_LIBS_TO_BC
action (the embedded-fallback design at comgr-compiler.cpp:1211-1216
assumes any present system libstdc++ works on its own; under HIP device
mode that assumption is broken on RHEL/manylinux).

Add -nostdinc++ to the test so it actually isolates the embedded
headers, which is what the test name and comments claim.

A separate issue tracks the broader design question of whether comgr
should auto-inject -nostdinc++ with -nogpuinc, or promote the embedded
libc++ from -idirafter to -isystem.

Co-Authored-By: Claude <noreply@anthropic.com>
The full root-cause chain lives in issue #2445; the test only needs to
explain why -nostdinc++ is here.

Co-Authored-By: Claude <noreply@anthropic.com>
Reverts the disable from #2447 now that the underlying issue (the test
not passing -nostdinc++) is fixed by this PR.

Co-Authored-By: Claude <noreply@anthropic.com>
@lamb-j lamb-j force-pushed the users/lambj/comgr-libcxx-test-nostdinc branch from e98d745 to f400351 Compare May 7, 2026 22:12
@z1-cciauto
Copy link
Copy Markdown
Collaborator

@chinmaydd chinmaydd added the comgr Related to Code Object Manager label May 7, 2026
@lamb-j
Copy link
Copy Markdown
Collaborator Author

lamb-j commented May 8, 2026

!PSDB

@z1-cciauto
Copy link
Copy Markdown
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comgr Related to Code Object Manager

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants