...
1# Regression test for https://go.dev/issue/47215 and https://go.dev/issue/50183:
2# A mismatched $GOROOT_FINAL or missing $CC caused the C dependencies of the net
3# package to appear stale, and it could not be rebuilt due to a missing $CC.
4
5[!cgo] skip
6
7# This test may start with the runtime/cgo package already stale.
8# Explicitly rebuild it to ensure that it is cached.
9# (See https://go.dev/issue/50892.)
10#
11# If running in non-short mode, explicitly vary CGO_CFLAGS
12# as a control case (to ensure that our regexps do catch rebuilds).
13
14[!short] env GOCACHE=$WORK/cache
15[!short] env CGO_CFLAGS=-DTestScript_cgo_stale_precompiled=true
16go build -x runtime/cgo
17[!short] stderr '[/\\]cgo'$GOEXE'["]? .* -importpath runtime/cgo'
18
19# https://go.dev/issue/50183: a mismatched GOROOT_FINAL caused net to be stale.
20env oldGOROOT_FINAL=$GOROOT_FINAL
21env GOROOT_FINAL=$WORK${/}goroot
22go build -x runtime/cgo
23! stderr '[/\\]cgo'$GOEXE'["]? .* -importpath runtime/cgo'
24
25env GOROOT_FINAL=$oldGOROOT_FINAL
26
27# https://go.dev/issue/47215: a missing $(go env CC) caused the precompiled net
28# to be stale. But as of https://go.dev/cl/452457 the precompiled libraries are
29# no longer installed anyway! Since we're requiring a C compiler in order to
30# build and use cgo libraries in the standard library, we should make sure it
31# matches what's in the cache.
32
33[abscc] stop
34
35env CGO_ENABLED=1
36env CC=''
37[!GOOS:plan9] env PATH='' # Guaranteed not to include $(go env CC)!
38[GOOS:plan9] env path=''
39! go build -x runtime/cgo
40stderr 'C compiler .* not found'
View as plain text