gdb/testsuite: strip ANSI escapes before pruning omp-rocm ld.lld warning - #242
Conversation
The omp-rocm build path in gdb_compile prunes a benign ROCm device linker warning (ld.lld: warning: ... __keep_alive ... local memory global used by non-kernel function) so the OpenMP offload testcases are not wrongly marked UNTESTED. The prune is anchored on the literal "ld.lld: warning:". With newer toolchains (e.g. LLVM 23), ld.lld's --color-diagnostics defaults to "auto" and colorizes when spawned under a pty (as DejaGnu does), inserting ANSI escapes between "ld.lld:" and "warning:" that stop the anchored regexp from matching. The warning then survives, gdb_compile treats it as a build failure, and the testcase is skipped. Pass -Xoffload-linker --no-color-diagnostics on the link step so the device (offload) linker never colorizes its diagnostics. It is added only when linking, so the compile step does not warn about an unused argument; -Wl, would only reach the host linker, not the device ld.lld that emits this warning. Co-authored-by: Cursor <cursoragent@cursor.com>
ae933f6 to
2daadd7
Compare
|
Updated per review: switched from stripping the ANSI escapes to suppressing device-linker coloring at the source. The omp-rocm build now passes Adding it link-only avoids an unused-argument warning on the Fortran Verified with LLVM 22/23: C/C++/Fortran compile+link succeed and the warning is no longer colorized. |
|
Should we cherry-pick this to amd-staging-rocgdb-16? |
Most probably, yes. |
Done in #252. |
Summary
The OpenMP-offload ROCm tests (
gdb.rocm/omp-target-*.exp) compile device code withamdclang. The device linkerld.lldemits a benign warning:gdb_compiletreats leftover compiler/linker output as a build failure, so an existingregsubalready prunes this warning. That prune is anchored on the literalld.lld: warning:.With newer toolchains (LLVM 23),
ld.lldcolorizes its own diagnostics:--color-diagnosticsdefaults toautoand turns on whenever stderr is a tty, which is the case when the compiler is spawned under a pty (as DejaGnu does), regardless of clang's-fdiagnostics-color=never. The warning then carries ANSI SGR escapes (e.g.ESC[0;35m) betweenld.lld:andwarning:, defeating the anchored regexp. The warning survives, the build is treated as failed, and the testcase is skipped (UNSUPPORTED/UNTESTED).This strips ANSI SGR escapes from the captured compiler output before the existing
omp-rocmprunes run. Only escape bytes are removed (never diagnostic text), so genuineerror:diagnostics are still detected and real build failures still fail.JIRA
AIROCGDB-642