From 37654be2052613166026ab9be63d51708b279f35 Mon Sep 17 00:00:00 2001 From: Jacob Lambert Date: Thu, 7 May 2026 14:27:46 -0700 Subject: [PATCH 1/3] [Comgr][test] Add -nostdinc++ to compile_hip_with_libcxx_test 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 to the system header, which transitively pulls in from cxxabi_init_exception.h. That stddef.h resolves to clang's libc++ stddef.h, which does #include_next . 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 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 --- amd/comgr/test/compile_hip_with_libcxx_test.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/amd/comgr/test/compile_hip_with_libcxx_test.c b/amd/comgr/test/compile_hip_with_libcxx_test.c index e4c0af73c3ed8..eb5f2f41f48fd 100644 --- a/amd/comgr/test/compile_hip_with_libcxx_test.c +++ b/amd/comgr/test/compile_hip_with_libcxx_test.c @@ -84,10 +84,18 @@ int main(int Argc, char *Argv[]) { // Compile options: embedded libc++ headers are mapped to clang's default // include locations via VFS and injected as a fallback (-idirafter). - // No explicit -I flags needed. + // -nostdinc++ disables system C++ header lookup so the embedded headers + // are the only ones found -- without it, on systems with system libstdc++ + // installed at clang's default search path (e.g., manylinux/RHEL with + // gcc-toolset), clang resolves to the system header, which then + // transitively pulls in and fails to resolve under HIP + // --offload-device-only mode (clang's libc++ stddef.h does + // #include_next with no next stddef.h available on the device + // include path). const char *CompileOptions[] = { "-std=c++17", - "-nogpuinc" // Don't use GPU-specific includes + "-nogpuinc", // Don't use GPU-specific includes + "-nostdinc++" // Use only the embedded libc++ headers }; size_t CompileOptionsCount = sizeof(CompileOptions) / sizeof(CompileOptions[0]); From ca8e7bf263db92210e375694725779f7dfbcbafa Mon Sep 17 00:00:00 2001 From: Jacob Lambert Date: Thu, 7 May 2026 15:01:14 -0700 Subject: [PATCH 2/3] Shorten comment The full root-cause chain lives in issue #2445; the test only needs to explain why -nostdinc++ is here. Co-Authored-By: Claude --- amd/comgr/test/compile_hip_with_libcxx_test.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/amd/comgr/test/compile_hip_with_libcxx_test.c b/amd/comgr/test/compile_hip_with_libcxx_test.c index eb5f2f41f48fd..d1d99c40c46bc 100644 --- a/amd/comgr/test/compile_hip_with_libcxx_test.c +++ b/amd/comgr/test/compile_hip_with_libcxx_test.c @@ -82,16 +82,10 @@ int main(int Argc, char *Argv[]) { amd_comgr_action_info_t ActionInfo; amd_comgr_status_t Status; - // Compile options: embedded libc++ headers are mapped to clang's default - // include locations via VFS and injected as a fallback (-idirafter). - // -nostdinc++ disables system C++ header lookup so the embedded headers - // are the only ones found -- without it, on systems with system libstdc++ - // installed at clang's default search path (e.g., manylinux/RHEL with - // gcc-toolset), clang resolves to the system header, which then - // transitively pulls in and fails to resolve under HIP - // --offload-device-only mode (clang's libc++ stddef.h does - // #include_next with no next stddef.h available on the device - // include path). + // Embedded libc++ headers are VFS-mapped to clang's default include + // locations and injected at -idirafter priority. -nostdinc++ disables + // system C++ header lookup so the embedded headers are exercised + // (otherwise system libstdc++, when present, wins). const char *CompileOptions[] = { "-std=c++17", "-nogpuinc", // Don't use GPU-specific includes From f4003519e2c9a3eca8926b163b308498846dc48e Mon Sep 17 00:00:00 2001 From: Jacob Lambert Date: Thu, 7 May 2026 15:12:28 -0700 Subject: [PATCH 3/3] [Comgr][test] Re-enable compile_hip_with_libcxx_test Reverts the disable from #2447 now that the underlying issue (the test not passing -nostdinc++) is fixed by this PR. Co-Authored-By: Claude --- amd/comgr/test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/amd/comgr/test/CMakeLists.txt b/amd/comgr/test/CMakeLists.txt index 9a8dc9669f434..8ba3d5e7aa898 100644 --- a/amd/comgr/test/CMakeLists.txt +++ b/amd/comgr/test/CMakeLists.txt @@ -246,6 +246,6 @@ add_comgr_test(compile_source_to_executable c) add_comgr_test(name_expression_map_test c) add_comgr_test(compile_hip_test c) add_comgr_test(compile_hip_to_relocatable c) -#add_comgr_test(compile_hip_with_libcxx_test c) +add_comgr_test(compile_hip_with_libcxx_test c) add_comgr_test(mangled_names_hip_test c) #add_comgr_test(unbundle_hip_test c)