testsuite: munge absolute paths like compiler do on Windows

Message ID 20260408114334.4165134-1-torbjorn.svensson@foss.st.com
State New
Headers
Series testsuite: munge absolute paths like compiler do on Windows |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gcc_build--master-arm success Build passed

Commit Message

Torbjorn SVENSSON April 8, 2026, 11:38 a.m. UTC
  Without this patch, I see errors like:

FAIL: g++.dg/modules/compile-std1.C module-cmi <bits/stdc++.h> (gcm.cache/,/T:/build/r16-8473-g5cc0ead3625fe6/arm-none-eabi/include/c++/16.0.1/arm-none-eabi/thumb/v6-m/nofp/bits/stdc++.h.gcm)

Obviously, the path is illegal on Windows since the colon is a reserved character.
With below patch, I instead get:

PASS: g++.dg/modules/compile-std1.C module-cmi <bits/stdc++.h> (gcm.cache/T-/build/r16-8473-g5cc0ead3625fe6/arm-none-eabi/include/c++/16.0.1/arm-none-eabi/thumb/v6-m/nofp/bits/stdc++.h.gcm)

There is no impact of this change on Linux when testing an arm-none-eabi toolchain.

Ok for trunk?

--

GCC munges absolute paths on Windows by replacing the colon with a dash.

gcc/testsuite/ChangeLog:

	* g++.dg/modules/modules.exp: Replace colon with dash on
	Windows.

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
---
 gcc/testsuite/g++.dg/modules/modules.exp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gcc/testsuite/g++.dg/modules/modules.exp b/gcc/testsuite/g++.dg/modules/modules.exp
index 2c7365db1cc..aa351b73e0e 100644
--- a/gcc/testsuite/g++.dg/modules/modules.exp
+++ b/gcc/testsuite/g++.dg/modules/modules.exp
@@ -83,7 +83,10 @@  proc host_header_path {hname} {
 
 # Return the pathname CMI munged like the compiler.
 proc munge_cmi {cmi} {
-    if { [string index $cmi 0] == "/" } {
+    if { [string index $cmi 1] == ":" && [info exists ::env(OS)] && [string match "Windows*" $::env(OS)] } {
+	# Windows paths like C:/some/path should be munged to C-/some/path
+	set cmi [string replace $cmi 1 1 "-"]
+    } elseif { [string index $cmi 0] == "/" } {
 	set cmi [string range $cmi 1 end]
     } else {
 	set cmi ",/$cmi"