I've committed a change to update libgo to the Go1.18beta2 release.
Bootstrapped and tested on x86_64-pc-linux-gnu.  As usual with these
release updates, the change is too large for this e-mail.  Please see
the git history or https://go.dev/cl/384695 for the exact changes.

Ian

gotools/:

* Makefile.am (go_cmd_cgo_files): Add ast_go118.go
(check-go-tool): Copy golang.org/x/tools directories.
* Makefile.in: Regenerate.
1829e768a958f9886085d3f7a03677b2f45ea422
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index 52f4b423f02..4e6bac7b7d5 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-b0dcd2d1e5e73952408b9f2d4d86ae12d102b20c
+47380f733ca932384e59492d2f04374edd8ec95e
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
diff --git a/gotools/Makefile.am b/gotools/Makefile.am
index 9e81024ea78..46481cb5173 100644
--- a/gotools/Makefile.am
+++ b/gotools/Makefile.am
@@ -62,6 +62,7 @@ go_cmd_gofmt_files = \
 
 go_cmd_cgo_files = \
        $(cmdsrcdir)/cgo/ast.go \
+       $(cmdsrcdir)/cgo/ast_go118.go \
        $(cmdsrcdir)/cgo/doc.go \
        $(cmdsrcdir)/cgo/gcc.go \
        $(cmdsrcdir)/cgo/godefs.go \
@@ -224,6 +225,7 @@ check-go-tool: go$(EXEEXT) $(noinst_PROGRAMS) check-head 
check-gccgo check-gcc
        cp -r $(libgosrcdir)/golang.org/x/mod 
check-go-dir/src/cmd/vendor/golang.org/x/
        cp -r $(libgosrcdir)/golang.org/x/crypto 
check-go-dir/src/cmd/vendor/golang.org/x/
        cp -r $(libgosrcdir)/golang.org/x/xerrors 
check-go-dir/src/cmd/vendor/golang.org/x/
+       cp -r $(libgosrcdir)/golang.org/x/tools 
check-go-dir/src/cmd/vendor/golang.org/x/
        cp $(libgodir)/objabi.go check-go-dir/src/cmd/internal/objabi/
        @abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \
        abs_checkdir=`cd check-go-dir && $(PWD_COMMAND)`; \
diff --git a/libgo/MERGE b/libgo/MERGE
index 4473f479d5f..662af9af882 100644
--- a/libgo/MERGE
+++ b/libgo/MERGE
@@ -1,4 +1,4 @@
-21a4e67ad58e3c4a7c5254f60cda5be5c3c450ff
+41f485b9a7d8fd647c415be1d11b612063dff21c
 
 The first line of this file holds the git revision number of the
 last merge done from the master library sources.
diff --git a/libgo/Makefile.am b/libgo/Makefile.am
index 5c377a30df9..be889f2a984 100644
--- a/libgo/Makefile.am
+++ b/libgo/Makefile.am
@@ -220,6 +220,7 @@ toolexeclibgodatabasesql_DATA = \
 toolexeclibgodebugdir = $(toolexeclibgodir)/debug
 
 toolexeclibgodebug_DATA = \
+       debug/buildinfo.gox \
        debug/dwarf.gox \
        debug/elf.gox \
        debug/gosym.gox \
@@ -325,6 +326,7 @@ toolexeclibgonetdir = $(toolexeclibgodir)/net
 toolexeclibgonet_DATA = \
        net/http.gox \
        net/mail.gox \
+       net/netip.gox \
        net/rpc.gox \
        net/smtp.gox \
        net/textproto.gox \
@@ -429,6 +431,7 @@ noinst_DATA = \
        internal/testenv.gox \
        internal/trace.gox \
        net/internal/socktest.gox \
+       os/exec/internal/fdtest.gox \
        os/signal/internal/pty.gox \
        reflect/internal/example1.gox \
        reflect/internal/example2.gox
@@ -483,53 +486,68 @@ version.go: s-version; @true
 s-version: Makefile
        rm -f version.go.tmp
        echo "package sys" > version.go.tmp
-       echo 'const GOARCH = "'$(GOARCH)'"' >> version.go.tmp
-       echo 'const GOOS = "'$(GOOS)'"' >> version.go.tmp
        echo 'const GccgoToolDir = "$(libexecsubdir)"' >> version.go.tmp
        echo 'const StackGuardMultiplierDefault = 1' >> version.go.tmp
-       echo >> version.go.tmp
-       echo "const (" >> version.go.tmp
-       echo "  UNKNOWN ArchFamilyType = iota" >> version.go.tmp
+       $(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go
+       $(STAMP) $@
+
+zgoarch.go: s-zgoarch; @true
+s-zgoarch: Makefile goarch.sh
+       rm -f zgoarch.go.tmp
+       echo "package goarch" > zgoarch.go.tmp
+       echo >> zgoarch.go.tmp
+       echo 'const GOARCH = "'$(GOARCH)'"' >> zgoarch.go.tmp
+       echo >> zgoarch.go.tmp
+       echo 'const (' >> zgoarch.go.tmp
+       echo "  _ArchFamily = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) family`" 
>> zgoarch.go.tmp
+       echo "  _BigEndian = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) 
bigendian`" >> zgoarch.go.tmp
+       echo "  _DefaultPhysPageSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) 
defaultphyspagesize`" >> zgoarch.go.tmp
+       echo "  _Int64Align = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) 
int64align`" >> zgoarch.go.tmp
+       echo "  _MinFrameSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) 
minframesize`" >> zgoarch.go.tmp
+       echo "  _PCQuantum = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) 
pcquantum`" >> zgoarch.go.tmp
+       echo "  _StackAlign = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) 
stackalign`" >> zgoarch.go.tmp
+       echo ")" >> zgoarch.go.tmp
+       echo >> zgoarch.go.tmp
+       echo "const (" >> zgoarch.go.tmp
+       echo "  UNKNOWN ArchFamilyType = iota" >> zgoarch.go.tmp
        for a in $(ALLGOARCHFAMILY); do \
-         echo "        $${a}" >> version.go.tmp; \
+         echo "        $${a}" >> zgoarch.go.tmp; \
        done
-       echo ")" >> version.go.tmp
-       echo >> version.go.tmp
+       echo ")" >> zgoarch.go.tmp
+       echo >> zgoarch.go.tmp
        for a in $(ALLGOARCH); do \
          f=`echo $${a} | sed -e 's/\(.\).*/\1/' -e 
'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`; \
          n="$${f}`echo $${a} | sed -e 's/.//'`"; \
          if test "$${a}" = "$(GOARCH)"; then \
-           echo "const Goarch$${n} = 1" >> version.go.tmp; \
+           echo "const Is$${n} = 1" >> zgoarch.go.tmp; \
          else \
-           echo "const Goarch$${n} = 0" >> version.go.tmp; \
+           echo "const Is$${n} = 0" >> zgoarch.go.tmp; \
          fi; \
        done
-       echo >> version.go.tmp
-       echo "const (" >> version.go.tmp
-       echo "  _ArchFamily = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) family`" 
>> version.go.tmp
-       echo "  _BigEndian = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) 
bigendian`" >> version.go.tmp
-       echo "  _DefaultPhysPageSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) 
defaultphyspagesize`" >> version.go.tmp
-       echo "  _Int64Align = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) 
int64align`" >> version.go.tmp
-       echo "  _MinFrameSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) 
minframesize`" >> version.go.tmp
-       echo "  _PCQuantum = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) 
pcquantum`" >> version.go.tmp
-       echo "  _StackAlign = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) 
stackalign`" >> version.go.tmp
-       echo ")" >> version.go.tmp
-       echo >> version.go.tmp
+       $(SHELL) $(srcdir)/mvifdiff.sh zgoarch.go.tmp zgoarch.go
+       $(STAMP) $@
+
+zgoos.go: s-zgoos; @true
+s-zgoos: Makefile
+       rm -f zgoos.go.tmp
+       echo "package goos" > zgoos.go.tmp
+       echo >> zgoos.go.tmp
+       echo 'const GOOS = "'$(GOOS)'"' >> zgoos.go.tmp
+       echo >> zgoos.go.tmp
        for a in $(ALLGOOS); do \
          f=`echo $${a} | sed -e 's/\(.\).*/\1/' -e 
'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`; \
          n="$${f}`echo $${a} | sed -e 's/.//'`"; \
          if test "$${a}" = "$(GOOS)"; then \
-           echo "const Goos$${n} = 1" >> version.go.tmp; \
+           echo "const Is$${n} = 1" >> zgoos.go.tmp; \
          else \
-           echo "const Goos$${n} = 0" >> version.go.tmp; \
+           echo "const Is$${n} = 0" >> zgoos.go.tmp; \
          fi; \
        done
-       echo >> version.go.tmp
-       $(SHELL) $(srcdir)/mvifdiff.sh version.go.tmp version.go
+       $(SHELL) $(srcdir)/mvifdiff.sh zgoos.go.tmp zgoos.go
        $(STAMP) $@
 
 cpugen.go: s-cpu; @true
-s-cpu: Makefile
+s-cpu: Makefile goarch.sh
        rm -f cpugen.go.tmp
        echo "package cpu" > cpugen.go.tmp
        echo "const CacheLinePadSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) 
cachelinesize`" >> cpugen.go.tmp
@@ -538,7 +556,7 @@ s-cpu: Makefile
        $(STAMP) $@
 
 gcpugen.go: s-gcpu; @true
-s-gcpu: Makefile
+s-gcpu: Makefile goarch.sh
        rm -f gcpugen.go.tmp
        echo "package cpu" > gcpugen.go.tmp
        echo "const cacheLineSize = `$(SHELL) $(srcdir)/goarch.sh $(GOARCH) 
cachelinesize`" >> gcpugen.go.tmp
@@ -560,6 +578,7 @@ s-buildcfg: Makefile
        echo "import \"runtime\"" >> buildcfg.go.tmp
        echo 'func defaultGOROOTValue() string { return `$(prefix)` }' >> 
buildcfg.go.tmp
        echo 'const defaultGO386 = `sse2`' >> buildcfg.go.tmp
+       echo 'const defaultGOAMD64 = `v1`' >> buildcfg.go.tmp
        echo 'const defaultGOARM = `5`' >> buildcfg.go.tmp
        echo 'const defaultGOMIPS = `hardfloat`' >> buildcfg.go.tmp
        echo 'const defaultGOMIPS64 = `hardfloat`' >> buildcfg.go.tmp
@@ -813,7 +832,8 @@ libgo_ldflags = \
 
 libgo_libadd = \
        $(libgo_go_objs) ../libbacktrace/libbacktrace.la \
-       $(LIBATOMIC) $(LIBFFI) $(PTHREAD_LIBS) $(MATH_LIBS) $(NET_LIBS)
+       $(LIBATOMIC) $(LIBFFI) $(PTHREAD_LIBS) $(MATH_LIBS) \
+       $(NET_LIBS) $(RT_LIBS)
 
 libgo_la_SOURCES = $(runtime_files)
 libgo_la_LDFLAGS = $(libgo_ldflags)
@@ -904,7 +924,7 @@ GOBENCH =
 CHECK = \
        GC="$(GOC) $(GOCFLAGS) $($(subst /,_,$@)_GOCFLAGS) -L `${PWD_COMMAND}` 
-L `${PWD_COMMAND}`/.libs"; \
        export GC; \
-       GOLIBS="$(extra_check_libs_$(subst .,_,$(subst /,_,$(@D)))) 
$(PTHREAD_LIBS) $(MATH_LIBS) $(NET_LIBS) $(LIBS)"; \
+       GOLIBS="$(extra_check_libs_$(subst .,_,$(subst /,_,$(@D)))) 
$(PTHREAD_LIBS) $(MATH_LIBS) $(NET_LIBS) $(RT_LIBS) $(LIBS)"; \
        export GOLIBS; \
        RUNTESTFLAGS="$(RUNTESTFLAGS)"; \
        export RUNTESTFLAGS; \
@@ -1065,6 +1085,12 @@ runtime/internal/sys.lo.dep: 
$(extra_go_files_runtime_internal_sys)
 extra_go_files_internal_cpu = cpugen.go
 internal/cpu.lo.dep: $(extra_go_files_internal_cpu)
 
+extra_go_files_internal_goarch = zgoarch.go
+internal/goarch.lo.dep: $(extra_go_files_internal_goarch)
+
+extra_go_files_internal_goos = zgoos.go
+internal/goos.lo.dep: $(extra_go_files_internal_goos)
+
 extra_go_files_golang_org_x_sys_cpu = gcpugen.go
 golang.org/x/sys/cpu.lo.dep: $(extra_go_files_golang_org_x_sys_cpu)
 
diff --git a/libgo/VERSION b/libgo/VERSION
index 844393b24b0..301234bc893 100644
--- a/libgo/VERSION
+++ b/libgo/VERSION
@@ -1 +1 @@
-go1.17.1
+go1.18beta2
diff --git a/libgo/check-packages.txt b/libgo/check-packages.txt
index dd8990f10e2..79f21689c52 100644
--- a/libgo/check-packages.txt
+++ b/libgo/check-packages.txt
@@ -19,13 +19,13 @@ cmd/go/internal/par
 cmd/go/internal/search
 cmd/go/internal/str
 cmd/go/internal/test
-cmd/go/internal/txtar
 cmd/go/internal/vcs
 cmd/go/internal/work
 cmd/internal/buildid
 cmd/internal/edit
 cmd/internal/objabi
 cmd/internal/pkgpath
+cmd/internal/quoted
 cmd/internal/test2json
 compress/bzip2
 compress/flate
@@ -46,7 +46,7 @@ crypto/ed25519
 crypto/ed25519/internal/edwards25519
 crypto/ed25519/internal/edwards25519/field
 crypto/elliptic
-crypto/elliptic/internal/fiat
+crypto/elliptic/internal/nistec
 crypto/hmac
 crypto/internal/subtle
 crypto/md5
@@ -61,6 +61,7 @@ crypto/tls
 crypto/x509
 database/sql
 database/sql/driver
+debug/buildinfo
 debug/dwarf
 debug/elf
 debug/macho
@@ -110,9 +111,13 @@ image/draw
 image/jpeg
 image/png
 index/suffixarray
+internal/buildcfg
 internal/cpu
 internal/execabs
 internal/fmtsort
+internal/fuzz
+internal/godebug
+internal/intern
 internal/itoa
 internal/poll
 internal/profile
@@ -147,6 +152,7 @@ net/http/internal/ascii
 net/http/pprof
 net/internal/socktest
 net/mail
+net/netip
 net/rpc
 net/rpc/jsonrpc
 net/smtp
diff --git a/libgo/configure.ac b/libgo/configure.ac
index 8691d5b0ac1..1b44b226f62 100644
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -10,7 +10,7 @@ AC_INIT(package-unused, version-unused,, libgo)
 AC_CONFIG_SRCDIR(Makefile.am)
 AC_CONFIG_HEADER(config.h)
 
-libtool_VERSION=20:0:0
+libtool_VERSION=21:0:0
 AC_SUBST(libtool_VERSION)
 
 AM_ENABLE_MULTILIB(, ..)
@@ -549,6 +549,12 @@ AC_CACHE_CHECK([for socket libraries], 
libgo_cv_lib_sockets,
 NET_LIBS="$libgo_cv_lib_sockets"
 AC_SUBST(NET_LIBS)
 
+RT_LIBS=
+case ${host} in
+  *-*-linux*) RT_LIBS=-lrt ;;
+esac
+AC_SUBST(RT_LIBS)
+
 dnl Test whether the compiler supports the -pthread option.
 AC_CACHE_CHECK([whether -pthread is supported],
 [libgo_cv_lib_pthread],
diff --git a/libgo/gotool-packages.txt b/libgo/gotool-packages.txt
index 15c928ff7fb..78ce9ba602a 100644
--- a/libgo/gotool-packages.txt
+++ b/libgo/gotool-packages.txt
@@ -32,14 +32,15 @@ cmd/go/internal/run
 cmd/go/internal/search
 cmd/go/internal/str
 cmd/go/internal/test
+cmd/go/internal/test/internal/genflags
 cmd/go/internal/tool
 cmd/go/internal/trace
-cmd/go/internal/txtar
 cmd/go/internal/vcs
 cmd/go/internal/version
 cmd/go/internal/vet
 cmd/go/internal/web
 cmd/go/internal/work
+cmd/go/internal/workcmd
 cmd/internal/browser
 cmd/internal/buildid
 cmd/internal/codesign
@@ -47,6 +48,7 @@ cmd/internal/diff
 cmd/internal/edit
 cmd/internal/objabi
 cmd/internal/pkgpath
+cmd/internal/quoted
 cmd/internal/sys
 cmd/internal/test2json
 cmd/internal/traceviewer
@@ -103,5 +105,7 @@ golang.org/x/tools/go/types/objectpath
 golang.org/x/tools/go/types/typeutil
 golang.org/x/tools/internal/analysisinternal
 golang.org/x/tools/internal/lsp/fuzzy
+golang.org/x/tools/internal/typeparams
+golang.org/x/tools/txtar
 golang.org/x/xerrors
 golang.org/x/xerrors/internal
diff --git a/libgo/libgo-packages.txt b/libgo/libgo-packages.txt
index f3097dc0a6a..d53c19576ac 100644
--- a/libgo/libgo-packages.txt
+++ b/libgo/libgo-packages.txt
@@ -22,6 +22,7 @@ crypto/ed25519/internal/edwards25519
 crypto/ed25519/internal/edwards25519/field
 crypto/elliptic
 crypto/elliptic/internal/fiat
+crypto/elliptic/internal/nistec
 crypto/hmac
 crypto/internal/randutil
 crypto/internal/subtle
@@ -38,6 +39,7 @@ crypto/x509
 crypto/x509/pkix
 database/sql
 database/sql/driver
+debug/buildinfo
 debug/dwarf
 debug/elf
 debug/gosym
@@ -82,7 +84,9 @@ golang.org/x/crypto/chacha20poly1305
 golang.org/x/crypto/cryptobyte
 golang.org/x/crypto/cryptobyte/asn1
 golang.org/x/crypto/curve25519
+golang.org/x/crypto/curve25519/internal/field
 golang.org/x/crypto/hkdf
+golang.org/x/crypto/internal/poly1305
 golang.org/x/crypto/internal/subtle
 golang.org/x/crypto/poly1305
 golang.org/x/net/dns/dnsmessage
@@ -91,6 +95,7 @@ golang.org/x/net/http/httpproxy
 golang.org/x/net/http2/hpack
 golang.org/x/net/idna
 golang.org/x/net/nettest
+golang.org/x/sync/semaphore
 golang.org/x/sys/cpu
 golang.org/x/text/secure/bidirule
 golang.org/x/text/transform
@@ -120,9 +125,14 @@ internal/cfg
 internal/cpu
 internal/execabs
 internal/fmtsort
+internal/fuzz
+internal/goarch
+internal/godebug
 internal/goexperiment
+internal/goos
 internal/goroot
 internal/goversion
+internal/intern
 internal/itoa
 internal/lazyregexp
 internal/lazytemplate
@@ -169,6 +179,7 @@ net/http/internal/testcert
 net/http/pprof
 net/internal/socktest
 net/mail
+net/netip
 net/rpc
 net/rpc/jsonrpc
 net/smtp
@@ -176,6 +187,7 @@ net/textproto
 net/url
 os
 os/exec
+os/exec/internal/fdtest
 os/signal
 os/signal/internal/pty
 os/user
diff --git a/libgo/match.sh b/libgo/match.sh
index bf4f141e04a..139d0cdbe64 100755
--- a/libgo/match.sh
+++ b/libgo/match.sh
@@ -98,6 +98,22 @@ if test "$gofiles" = ""; then
     exit 1
 fi
 
+gobuild() {
+    line=$(echo "$1" | sed -e 's|//go:build ||')
+    line=$(echo "$line" | sed -e 's/go1\.[0-9]\+/1/g' -e 
's/goexperiment\./goexperiment/')
+    line=" $line "
+    wrap='[ ()!&|]'
+    for ones in $goarch $goos $cgotag $cmdlinetag gccgo 
goexperimentfieldtrack; do
+       line=$(echo "$line" | sed -e 
"s/\\(${wrap}\\)${ones}\\(${wrap}\\)/"'\11\2/g')
+    done
+    # 386 is a special case since it looks like a number to the shell.
+    # We need it to be 0 if it's not $goarch.
+    if test "$goarch" != "386"; then
+       line=$(echo "$line" | sed -e "s/\\(${wrap}\\)386\\(${wrap}\\)/\10\2/g")
+    fi
+    (($line))
+}
+
 matched=
 for f in $gofiles; do
     tag1=`echo $f | sed -e 's/^.*_\([^_]*\).go$/\1/'`
@@ -138,62 +154,74 @@ for f in $gofiles; do
            ;;
     esac
 
-    if test x$tag1 != xnonmatchingtag -a x$tag2 != xnonmatchingtag; then
-       # Pipe through cat so that `set -e` doesn't affect fgrep.
-       tags=`sed '/^package /q' < $f | grep '^// *+build ' | cat`
-       omatch=true
-       first=true
-       match=false
-       for tag in $tags; do
-           case $tag in
-               "//")
-                   ;;
-               "+build" | "//+build")
-                   if test "$first" = "true"; then
-                       first=false
-                   elif test "$match" = "false"; then
-                       omatch=false
-                   fi
-                   match=false
-                   ;;
-               $goos | $goarch | $cgotag | $cmdlinetag | "gccgo" | 
"goexperiment.fieldtrack" | go1.[0-9] | go1.[0-9][0-9])
-                   match=true
-                   ;;
-               "!"$goos | "!"$goarch | "!"$cgotag | "!"$cmdlinetag | "!gccgo" 
| "!goexperiment.fieldtrack" | "!"go1.[0-9] | "!"go1.1[0-7])
-                   ;;
-               *,*)
-                   cmatch=true
-                   for ctag in `echo $tag | sed -e 's/,/ /g'`; do
-                       case $ctag in
-                           $goos | $goarch | $cgotag | $cmdlinetag | "gccgo" | 
"goexperiment.fieldtrack" | go1.[0-9] | go1.[0-9][0-9])
-                               ;;
-                           "!"$goos | "!"$goarch | "!"$cgotag | "!"$cmdlinetag 
| "!gccgo" | "!goexperiment.fieldtrack" | "!"go1.[0-9] | "!"go1.1[0-7])
-                               cmatch=false
-                               ;;
-                           "!"*)
-                               ;;
-                           *)
-                               cmatch=false
-                               ;;
-                       esac
-                   done
-                   if test "$cmatch" = "true"; then
-                       match=true
-                   fi
-                   ;;
-               "!"*)
-                   match=true
-                   ;;
-           esac
-       done
-
-       if test "$match" = "false" -a "$first" = "false"; then
-           omatch=false
-       fi
+    if test x$tag1 = xnonmatchingtag -o x$tag2 = xnonmatchingtag; then
+       continue
+    fi
 
-       if test "$omatch" = "true"; then
+    # Check for go:build line
+    build=$(sed '/^package /q' < $f | grep '^//go:build ' | cat)
+    if test -n "$build"; then
+       if $(gobuild "$build"); then
            matched="$matched $srcdir/$f"
        fi
+       continue
+    fi
+
+    # No go:build line, check for +build lines.
+    # Pipe through cat so that `set -e` doesn't affect fgrep.
+    tags=`sed '/^package /q' < $f | grep '^// *+build ' | cat`
+    omatch=true
+    first=true
+    match=false
+    for tag in $tags; do
+       case $tag in
+           "//")
+           ;;
+           "+build" | "//+build")
+               if test "$first" = "true"; then
+                   first=false
+               elif test "$match" = "false"; then
+                   omatch=false
+               fi
+               match=false
+               ;;
+           $goos | $goarch | $cgotag | $cmdlinetag | "gccgo" | 
"goexperiment.fieldtrack" | go1.[0-9] | go1.[0-9][0-9])
+               match=true
+               ;;
+           "!"$goos | "!"$goarch | "!"$cgotag | "!"$cmdlinetag | "!gccgo" | 
"!goexperiment.fieldtrack" | "!"go1.[0-9] | "!"go1.1[0-7])
+               ;;
+           *,*)
+               cmatch=true
+               for ctag in `echo $tag | sed -e 's/,/ /g'`; do
+                   case $ctag in
+                       $goos | $goarch | $cgotag | $cmdlinetag | "gccgo" | 
"goexperiment.fieldtrack" | go1.[0-9] | go1.[0-9][0-9])
+                       ;;
+                       "!"$goos | "!"$goarch | "!"$cgotag | "!"$cmdlinetag | 
"!gccgo" | "!goexperiment.fieldtrack" | "!"go1.[0-9] | "!"go1.1[0-7])
+                           cmatch=false
+                           ;;
+                       "!"*)
+                           ;;
+                       *)
+                           cmatch=false
+                           ;;
+                   esac
+               done
+               if test "$cmatch" = "true"; then
+                   match=true
+               fi
+               ;;
+           "!"*)
+               match=true
+               ;;
+       esac
+    done
+
+    if test "$match" = "false" -a "$first" = "false"; then
+       omatch=false
+    fi
+
+    if test "$omatch" = "true"; then
+       matched="$matched $srcdir/$f"
     fi
 done
 
diff --git a/libgo/merge.sh b/libgo/merge.sh
index 5bec1b93552..795028b8163 100755
--- a/libgo/merge.sh
+++ b/libgo/merge.sh
@@ -72,7 +72,6 @@ merge() {
     else
       echo "merge.sh: ${name}: REMOVED"
       rm -f ${libgo}
-      git rm ${libgo}
     fi
   elif test -f ${old}; then
     # The file exists in the old version.
@@ -124,7 +123,6 @@ merge() {
         mkdir -p ${dir}
       fi
       cp ${new} ${libgo}
-      git add ${libgo}
     fi
   fi
 }
@@ -134,7 +132,7 @@ echo ${rev} > VERSION
 (cd ${NEWDIR}/src && find . -name '*.go' -print) | while read f; do
   skip=false
   case "$f" in
-  ./cmd/buildid/* | ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | 
./cmd/test2json/* | ./cmd/vet/* | ./cmd/internal/browser/* | 
./cmd/internal/buildid/* | ./cmd/internal/codesign/* | ./cmd/internal/edit/* | 
./cmd/internal/objabi/* | ./cmd/internal/test2json/* | ./cmd/internal/sys/* | 
./cmd/internal/traceviewer/* | ./cmd/vendor/golang.org/x/tools/* | 
./cmd/vendor/golang.org/x/mod/* | ./cmd/vendor/golang.org/x/xerrors/* | 
./cmd/vendor/golang.org/x/crypto/ed25519)
+  ./cmd/buildid/* | ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | 
./cmd/test2json/* | ./cmd/vet/* | ./cmd/internal/browser/* | 
./cmd/internal/buildid/* | ./cmd/internal/codesign/* | ./cmd/internal/edit/* | 
./cmd/internal/objabi/* | ./cmd/internal/quoted/* | ./cmd/internal/test2json/* 
| ./cmd/internal/sys/* | ./cmd/internal/traceviewer/* | 
./cmd/vendor/golang.org/x/tools/* | ./cmd/vendor/golang.org/x/mod/* | 
./cmd/vendor/golang.org/x/xerrors/* | ./cmd/vendor/golang.org/x/crypto/ed25519 
| ./cmd/vendor/golang.org/x/sync/semaphore)
     ;;
   ./cmd/*)
     skip=true
@@ -191,7 +189,7 @@ done
     continue
   fi
   (cd ${oldtd} && git ls-files .) | while read f; do
-    if test "`basename $f`" = ".gitignore"; then
+    if test "`basename -- $f`" = ".gitignore"; then
       continue
     fi
     name=$d/$f
@@ -221,7 +219,6 @@ done
   fi
   echo "merge.sh: ${libgofile}: REMOVED"
   rm -f ${libgofile}
-  git rm ${libgofile}
 done
 
 (cd ${OLDDIR}/misc/cgo && find . -type f -print) | while read f; do
@@ -236,7 +233,6 @@ done
   fi
   echo "merge.sh: ${libgofile}: REMOVED"
   rm -f ${libgofile}
-  git rm ${libgofile}
 done
 
 (echo ${new_rev}; sed -ne '2,$p' MERGE) > MERGE.tmp
diff --git a/libgo/runtime/go-signal.c b/libgo/runtime/go-signal.c
index d30d1603adc..0cb90304730 100644
--- a/libgo/runtime/go-signal.c
+++ b/libgo/runtime/go-signal.c
@@ -62,6 +62,7 @@ sigtramp(int sig, siginfo_t *info, void *context)
        G *gp;
        void *stack_context[10];
        void *stack;
+       void *find_stack;
        size_t stack_size;
        void *next_segment;
        void *next_sp;
@@ -91,9 +92,15 @@ sigtramp(int sig, siginfo_t *info, void *context)
 
        __splitstack_getcontext(&stack_context[0]);
 
-       stack = 
__splitstack_find_context((void*)(&gp->m->gsignal->stackcontext[0]),
-                                         &stack_size, &next_segment,
-                                         &next_sp, &initial_sp);
+       find_stack = 
+         __splitstack_find_context((void*)(&gp->m->gsignal->stackcontext[0]),
+                                   &stack_size, &next_segment,
+                                   &next_sp, &initial_sp);
+       stack = find_stack;
+       if (stack == NULL) {
+               stack = gp->m->gsignalstack;
+               stack_size = gp->m->gsignalstacksize;
+       }
 
        // If some non-Go code called sigaltstack, adjust.
        sp = (uintptr)(&stack_size);
@@ -113,7 +120,7 @@ sigtramp(int sig, siginfo_t *info, void *context)
                // Unfortunately __splitstack_find_context will return NULL
                // when it is called on a context that has never been used.
                // There isn't much we can do but assume all is well.
-               if (stack != NULL) {
+               if (find_stack != NULL) {
                        // Here the gc runtime adjusts the gsignal
                        // stack guard to match the values returned by
                        // sigaltstack.  Unfortunately we have no way
diff --git a/libgo/testsuite/gotest b/libgo/testsuite/gotest
index e0dd16610db..04e4267fbba 100755
--- a/libgo/testsuite/gotest
+++ b/libgo/testsuite/gotest
@@ -289,6 +289,22 @@ x)
        ;;
 esac
 
+gobuild() {
+    line=$(echo "$1" | sed -e 's|//go:build ||')
+    line=$(echo "$line" | sed -e 's/go1\.[0-9]\+/1/g' -e 
's/goexperiment\./goexperiment/')
+    line=" $line "
+    wrap='[ ()!&|]'
+    for ones in $goarch $goos cgo gccgo goexperimentfieldtrack; do
+       line=$(echo "$line" | sed -e 
"s/\\(${wrap}\\)${ones}\\(${wrap}\\)/"'\11\2/g')
+    done
+    # 386 is a special case since it looks like a number to the shell.
+    # We need it to be 0 if it's not $goarch.
+    if test "$goarch" != "386"; then
+       line=$(echo "$line" | sed -e "s/\\(${wrap}\\)386\\(${wrap}\\)/\10\2/g")
+    fi
+    (($line))
+}
+
 case "x$gofiles" in
 x)
        for f in `ls *_test.go`; do
@@ -330,15 +346,28 @@ x)
                ;;
            esac
 
-           if test x$tag1 != xnonmatchingtag -a x$tag2 != xnonmatchingtag; then
-               tags=`sed '/^package /q' < $f | grep '^// *+build '`
-               omatch=true
-               first=true
-               match=false
-               for tag in $tags; do
-                   case $tag in
+           if test x$tag1 = xnonmatchingtag -o x$tag2 = xnonmatchingtag; then
+               continue
+           fi
+
+           # Check for go:build line
+           build=$(sed '/^package /q' < $f | grep '^//go:build ' | cat)
+           if test -n "$build"; then
+               if $(gobuild "$build"); then
+                   gofiles="$gofiles $f"
+               fi
+               continue
+           fi
+
+           # No go:build line, check for +build lines.
+           tags=`sed '/^package /q' < $f | grep '^// *+build '`
+           omatch=true
+           first=true
+           match=false
+           for tag in $tags; do
+               case $tag in
                    "//")
-                       ;;
+                   ;;
                    "+build" | "//+build")
                        if test "$first" = "true"; then
                            first=false
@@ -356,16 +385,16 @@ x)
                        cmatch=true
                        for ctag in `echo $tag | sed -e 's/,/ /g'`; do
                            case $ctag in
-                           $goos | $goarch | cgo | gccgo | 
goexperiment.fieldtrack | go1.[0-9] | go1.[0-9][0-9])
-                               ;;
-                           "!"$goos | "!"$goarch | "!cgo" | "!gccgo" | 
"!goexperiment.fieldtrack" | "!"go1.[0-9] | "!"go1.1[0-7])
-                               cmatch=false
-                               ;;
-                           "!"*)
-                               ;;
-                           *)
-                               cmatch=false
+                               $goos | $goarch | cgo | gccgo | 
goexperiment.fieldtrack | go1.[0-9] | go1.[0-9][0-9])
                                ;;
+                               "!"$goos | "!"$goarch | "!cgo" | "!gccgo" | 
"!goexperiment.fieldtrack" | "!"go1.[0-9] | "!"go1.1[0-7])
+                                   cmatch=false
+                                   ;;
+                               "!"*)
+                                   ;;
+                               *)
+                                   cmatch=false
+                                   ;;
                            esac
                        done
                        if test "$cmatch" = "true"; then
@@ -375,16 +404,15 @@ x)
                    "!"*)
                        match=true
                        ;;
-                   esac
-               done
+               esac
+           done
 
-               if test "$match" = "false" -a "$first" = "false"; then
-                   omatch=false
-               fi
+           if test "$match" = "false" -a "$first" = "false"; then
+               omatch=false
+           fi
 
-               if test "$omatch" = "true"; then
-                   gofiles="$gofiles $f"
-               fi
+           if test "$omatch" = "true"; then
+               gofiles="$gofiles $f"
            fi
        done
        ;;
@@ -546,6 +574,18 @@ symtogo() {
   done
 }
 
+# Find Go benchmark/fuzz/example functions.
+# The argument is the function name prefix.
+findfuncs() {
+       pattern='$1([^a-z].*)?'
+       syms=$($NM -p -v _gotest_.o | egrep " $text .*\."$pattern'$' | fgrep -v 
' __go_' | egrep -v '\.\.\w+$' | sed 's/.* //')
+       if $havex; then
+           xsyms=$($NM -p -v $xofile | egrep " $text .*\."$pattern'$' | fgrep 
-v ' __go_' | egrep -v '\.\.\w+$' | sed 's/.* //')
+           syms="$syms $xsyms"
+       fi
+        $(symtogo "$benchmarksyms")
+}
+
 # Takes an example name and puts any output into the file example.txt.
 # It strips comment markers but does not otherwise change the output.
 exampleoutput() {
@@ -589,23 +629,10 @@ exampleoutput() {
                echo 'gotest: warning: no tests matching '$pattern in 
_gotest_.o $xofile 1>&2
                exit 2
        fi
-       # benchmarks are named BenchmarkFoo.
-       pattern='Benchmark([^a-z].*)?'
-       benchmarksyms=$($NM -p -v _gotest_.o | egrep " $text .*\."$pattern'$' | 
fgrep -v ' __go_' | egrep -v '\.\.\w+$' | sed 's/.* //')
-       if $havex; then
-           benchmarkxsyms=$($NM -p -v $xofile | egrep " $text .*\."$pattern'$' 
| fgrep -v ' __go_' | egrep -v '\.\.\w+$' | sed 's/.* //')
-           benchmarksyms="$benchmarksyms $benchmarkxsyms"
-       fi
-        benchmarks=$(symtogo "$benchmarksyms")
 
-       # examples are named ExampleFoo
-       pattern='Example([^a-z].*)?'
-       examplesyms=$($NM -p -v _gotest_.o | egrep " $text .*\."$pattern'$' | 
fgrep -v ' __go_' | egrep -v '\.\.\w+$' | sed 's/.* //')
-       if $havex; then
-           examplexsyms=$($NM -p -v $xofile | egrep " $text .*\."$pattern'$' | 
fgrep -v ' __go_' | egrep -v '\.\.\w+$' | sed 's/.* //')
-           examplesyms="$examplesyms $examplexsyms"
-       fi
-       examples=$(symtogo "$examplesyms")
+       benchmarks=$(findfuncs Benchmark)
+       fuzztargets=$(findfuncs Fuzz)
+       examples=$(findfuncs Example)
 
        # package spec
        echo 'package main'
@@ -663,6 +690,15 @@ exampleoutput() {
        done
        echo '}'
 
+       # fuzz array
+       echo 'var fuzzTargets = []testing.InternalFuzzTarget{'
+       for i in $fuzztargets; do
+               n=$(testname $i)
+               j=$(localname $i)
+               echo '  {"'$n'", '$j'},'
+       done
+       echo '}'
+
        # examples array
        echo 'var examples = []testing.InternalExample{'
        for i in $examples; do
@@ -710,7 +746,7 @@ exampleoutput() {
        echo \
 '
 func main() {
-       m := testing.MainStart(testdeps.TestDeps{}, tests, benchmarks, examples)
+       m := testing.MainStart(testdeps.TestDeps{}, tests, benchmarks, 
fuzzTargets, examples)
 '
        if test -n "$testmain"; then
                echo "  ${testmain}(m)"

Reply via email to