[!cgo] skip
+# Set CC explicitly to something that requires a PATH lookup.
+# Normally, the default is gcc or clang, but if CC was set during make.bash,
+# that becomes the default.
+[exec:clang] env CC=clang
+[exec:gcc] env CC=gcc
+[!exec:clang] [!exec:gcc] skip 'Unknown C compiler'
+
env GOCACHE=$WORK/gocache # Looking for compile flags, so need a clean cache.
[!windows] env PATH=.:$PATH
[!windows] chmod 0755 p/gcc p/clang
# Check that if the PATH directory containing the C compiler has a space,
# we can still use that compiler with cgo.
# Verifies #43808.
-
[!cgo] skip
-# Check if default CC was set by make.bash.
-# If it was, this test is not valid.
-go env CC
-stdout '^(clang|gcc)$'
+# Set CC explicitly to something that requires a PATH lookup.
+# Normally, the default is gcc or clang, but if CC was set during make.bash,
+# that becomes the default.
+[exec:clang] env CC=clang
+[exec:gcc] env CC=gcc
+[!exec:clang] [!exec:gcc] skip 'Unknown C compiler'
[!windows] chmod 0755 $WORK/'program files'/clang
[!windows] chmod 0755 $WORK/'program files'/gcc
[windows] exists -exec $WORK/'program files'/clang.bat
[windows] env PATH=$WORK\'program files';%PATH%
-! exists log.txt
+! exists $WORK/log.txt
? go build -x
-exists log.txt
-rm log.txt
+exists $WORK/log.txt
+rm $WORK/log.txt
# TODO(#41400, #43078): when CC is set explicitly, it should be allowed to
# contain spaces separating arguments, and it should be possible to quote
[!windows] env CC=$WORK/'program files'/gcc
[windows] env CC=$WORK\'program files'\gcc.bat
! go build -x
-! exists log.txt
+! exists $WORK/log.txt
-- go.mod --
module m
-- $WORK/program files/gcc --
#!/bin/sh
-echo ok >log.txt
+echo ok >$WORK/log.txt
-- $WORK/program files/clang --
#!/bin/sh
-echo ok >log.txt
+echo ok >$WORK/log.txt
-- $WORK/program files/gcc.bat --
-echo ok >log.txt
+echo ok >%WORK%\log.txt
-- $WORK/program files/clang.bat --
-echo ok >log.txt
+echo ok >%WORK%\log.txt