I've committed a patch to update libgo to the Go 1.16beta1 release. This patch does not include support for the new //go:embed directive that will be available in Go 1.16.1 (https://golang.org/issue/41191) Support for that requires compiler changes, which will come later.
As usual with these big updates, I have not included the complete changes in this e-mail message, only changes that are gccgo-specific. Testing this requires some changes to gotools. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian * Makefile.am (check-runtime): Don't create check-runtime-dir. (mostlyclean-local): Don't remove check-runtime-dir. (check-go-tool, check-vet): Copy in go.mod and modules.txt. (check-cgo-test, check-carchive-test): Add go.mod file. * Makefile.in: Regenerate.
0c4cf80ab72765e5e1984f7d228822b945541915 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 1e461f06e95..fc5ef4498dd 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -d67579759e1769c08148304b2d378ec0b05637d6 +47bdc8bb36f16f9d1dec72df5dd6b45d7b0b0725 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 1b8702e98bb..3bbccb96c28 100644 --- a/gotools/Makefile.am +++ b/gotools/Makefile.am @@ -101,7 +101,7 @@ MOSTLYCLEANFILES = \ mostlyclean-local: if test -d check-go-dir; then chmod -R u+w check-go-dir; fi - rm -rf check-go-dir check-runtime-dir cgo-test-dir carchive-test-dir \ + rm -rf check-go-dir cgo-test-dir carchive-test-dir \ check-vet-dir gocache-test if NATIVE @@ -210,6 +210,11 @@ check-go-tool: go$(EXEEXT) $(noinst_PROGRAMS) check-head check-gccgo check-gcc if test -d check-go-dir; then chmod -R u+w check-go-dir; fi rm -rf check-go-dir cmd_go-testlog $(MKDIR_P) check-go-dir/src/cmd/go + cp $(libgosrcdir)/go.mod check-go-dir/src/ + cp $(cmdsrcdir)/go.mod check-go-dir/src/cmd/ + $(MKDIR_P) check-go-dir/src/vendor check-go-dir/src/cmd/vendor + cp $(libgosrcdir)/vendor/modules.txt check-go-dir/src/vendor/ + cp $(libgosrcdir)/cmd/vendor/modules.txt check-go-dir/src/cmd/vendor/ cp $(cmdsrcdir)/go/*.go check-go-dir/src/cmd/go/ cp -r $(cmdsrcdir)/go/internal check-go-dir/src/cmd/go/ cp $(libgodir)/zdefaultcc.go check-go-dir/src/cmd/go/internal/cfg/ @@ -234,8 +239,7 @@ check-go-tool: go$(EXEEXT) $(noinst_PROGRAMS) check-head check-gccgo check-gcc # but the runtime tests use the go tool heavily, so testing # here too will catch more problems. check-runtime: go$(EXEEXT) $(noinst_PROGRAMS) check-head check-gccgo check-gcc - rm -rf check-runtime-dir runtime-testlog - $(MKDIR_P) check-runtime-dir + rm -f runtime-testlog @abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \ LD_LIBRARY_PATH=`echo $${abs_libgodir}/.libs:$${LD_LIBRARY_PATH} | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; \ export LD_LIBRARY_PATH; \ @@ -256,6 +260,7 @@ check-runtime: go$(EXEEXT) $(noinst_PROGRAMS) check-head check-gccgo check-gcc check-cgo-test: go$(EXEEXT) $(noinst_PROGRAMS) check-head check-gccgo check-gcc rm -rf cgo-test-dir cgo-testlog $(MKDIR_P) cgo-test-dir/misc/cgo + echo 'module misc' > cgo-test-dir/misc/go.mod cp -r $(libgomiscdir)/cgo/test cgo-test-dir/misc/cgo/ @abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \ echo "cd cgo-test-dir/misc/cgo/test && $(ECHO_ENV) GOTRACEBACK=2 $(abs_builddir)/go$(EXEEXT) test -test.short -test.timeout=$(GOTOOLS_TEST_TIMEOUT)s -test.v" > cgo-testlog @@ -270,6 +275,7 @@ check-cgo-test: go$(EXEEXT) $(noinst_PROGRAMS) check-head check-gccgo check-gcc check-carchive-test: go$(EXEEXT) $(noinst_PROGRAMS) check-head check-gccgo check-gcc rm -rf carchive-test-dir carchive-testlog $(MKDIR_P) carchive-test-dir/misc/cgo + echo 'module misc' > carchive-test-dir/misc/go.mod cp -r $(libgomiscdir)/cgo/testcarchive carchive-test-dir/misc/cgo/ @abs_libgodir=`cd $(libgodir) && $(PWD_COMMAND)`; \ echo "cd carchive-test-dir/misc/cgo/testcarchive && $(ECHO_ENV) LIBRARY_PATH=`echo $${abs_libgodir}/.libs` $(abs_builddir)/go$(EXEEXT) test -test.timeout=$(GOTOOLS_TEST_TIMEOUT)s -test.v" > carchive-testlog @@ -283,6 +289,11 @@ check-carchive-test: go$(EXEEXT) $(noinst_PROGRAMS) check-head check-gccgo check check-vet: go$(EXEEXT) $(noinst_PROGRAMS) check-head check-gccgo check-gcc rm -rf check-vet-dir cmd_vet-testlog $(MKDIR_P) check-vet-dir/src/cmd/internal check-vet-dir/src/cmd/vendor/golang.org/x + cp $(libgosrcdir)/go.mod check-vet-dir/src/ + cp $(cmdsrcdir)/go.mod check-vet-dir/src/cmd/ + $(MKDIR_P) check-vet-dir/src/vendor check-vet-dir/src/cmd/vendor + cp $(libgosrcdir)/vendor/modules.txt check-vet-dir/src/vendor/ + cp $(libgosrcdir)/cmd/vendor/modules.txt check-vet-dir/src/cmd/vendor/ cp -r $(cmdsrcdir)/vet check-vet-dir/src/cmd/ cp -r $(cmdsrcdir)/internal/objabi check-vet-dir/src/cmd/internal cp $(libgodir)/objabi.go check-vet-dir/src/cmd/internal/objabi/ diff --git a/libgo/MERGE b/libgo/MERGE index e95c59a132d..c5546950b8b 100644 --- a/libgo/MERGE +++ b/libgo/MERGE @@ -1,4 +1,4 @@ -9b955d2d3fcff6a5bc8bce7bafdc4c634a28e95b +2ff33f5e443165e55a080f3a649e4c070c4096d1 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 4d3e54e9225..2e8c37e170d 100644 --- a/libgo/Makefile.am +++ b/libgo/Makefile.am @@ -775,6 +775,7 @@ libgo_go_objs = \ syscall/errno.lo \ syscall/signame.lo \ syscall/wait.lo \ + os/dir_gccgo_c.lo \ $(golangorg_x_net_lif_lo) \ $(golangorg_x_net_route_lo) \ log/syslog/syslog_c.lo \ @@ -1062,6 +1063,7 @@ extra_go_files_os_user = os_user_linknames.go os/user.lo.dep: $(extra_go_files_os_user) extra_check_libs_cmd_go_internal_cache = $(abs_builddir)/libgotool.a +extra_check_libs_cmd_go_internal_fsys = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_generate = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_get = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_load = $(abs_builddir)/libgotool.a @@ -1075,10 +1077,14 @@ extra_check_libs_cmd_go_internal_modload = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_module = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_mvs = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_search = $(abs_builddir)/libgotool.a +extra_check_libs_cmd_go_internal_str = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_test = $(abs_builddir)/libgotool.a +extra_check_libs_cmd_go_internal_vcs = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_web2 = $(abs_builddir)/libgotool.a extra_check_libs_cmd_go_internal_work = $(abs_builddir)/libgotool.a +extra_check_libs_cmd_internal_buildid = $(abs_builddir)/libgotool.a + extra_check_libs_cmd_vet_internal_cfg = $(abs_builddir)/libgotool.a # FIXME: The following C files may as well move to the runtime @@ -1122,6 +1128,11 @@ syscall/wait.lo: go/syscall/wait.c runtime.inc @$(MKDIR_P) syscall $(LTCOMPILE) -c -o $@ $(srcdir)/go/syscall/wait.c +# An os function is written in C. +os/dir_gccgo_c.lo: go/os/dir_gccgo_c.c runtime.inc + @$(MKDIR_P) os + $(LTCOMPILE) -c -o $@ $(srcdir)/go/os/dir_gccgo_c.c + # internal/cpu needs some C code. internal/cpu/cpu_gccgo.lo: go/internal/cpu/cpu_gccgo.c runtime.inc @$(MKDIR_P) internal/cpu diff --git a/libgo/VERSION b/libgo/VERSION index 7b6d7469626..257f7ce59ec 100644 --- a/libgo/VERSION +++ b/libgo/VERSION @@ -1 +1 @@ -go1.15.6 +go1.16beta1 diff --git a/libgo/check-packages.txt b/libgo/check-packages.txt index da77e84517e..a0148cfccc4 100644 --- a/libgo/check-packages.txt +++ b/libgo/check-packages.txt @@ -3,6 +3,7 @@ archive/zip bufio bytes cmd/go/internal/cache +cmd/go/internal/fsys cmd/go/internal/generate cmd/go/internal/get cmd/go/internal/imports @@ -16,8 +17,10 @@ cmd/go/internal/modload cmd/go/internal/mvs 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 @@ -113,6 +116,7 @@ internal/trace internal/unsafeheader internal/xcoff io +io/fs io/ioutil log log/syslog @@ -155,6 +159,7 @@ runtime/debug runtime/internal/atomic runtime/internal/math runtime/internal/sys +runtime/metrics runtime/pprof runtime/trace sort @@ -164,6 +169,7 @@ sync sync/atomic syscall testing +testing/fstest testing/iotest testing/quick text/scanner diff --git a/libgo/configure.ac b/libgo/configure.ac index 5013f4142a6..ebab9d9de3e 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=18:0:0 +libtool_VERSION=19:0:0 AC_SUBST(libtool_VERSION) AM_ENABLE_MULTILIB(, ..) @@ -167,7 +167,7 @@ AC_SUBST(go_include) # All known GOOS values. This is the union of all operating systems # supported by the gofrontend and all operating systems supported by # the gc toolchain. -ALLGOOS="aix android darwin dragonfly freebsd hurd illumos irix js linux netbsd openbsd plan9 rtems solaris windows" +ALLGOOS="aix android darwin dragonfly freebsd hurd illumos ios irix js linux netbsd openbsd plan9 rtems solaris windows zos" is_darwin=no is_freebsd=no @@ -598,6 +598,8 @@ AC_CHECK_FUNCS(strerror_r strsignal wait4 mincore setenv unsetenv dl_iterate_phd AM_CONDITIONAL(HAVE_STRERROR_R, test "$ac_cv_func_strerror_r" = yes) AM_CONDITIONAL(HAVE_WAIT4, test "$ac_cv_func_wait4" = yes) +AC_STRUCT_DIRENT_D_TYPE + AC_CHECK_FUNCS(accept4 dup3 epoll_create1 faccessat fallocate fchmodat fchownat futimesat getxattr inotify_add_watch inotify_init inotify_init1 inotify_rm_watch listxattr mkdirat mknodat open64 openat pipe2 removexattr renameat setxattr sync_file_range splice syscall tee unlinkat unshare utimensat) AC_TYPE_OFF_T AC_CHECK_TYPES([loff_t]) diff --git a/libgo/go/cmd/go.mod b/libgo/go/cmd/go.mod new file mode 100644 index 00000000000..031b8d4ab75 --- /dev/null +++ b/libgo/go/cmd/go.mod @@ -0,0 +1,12 @@ +module cmd + +go 1.16 + +require ( + github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2 + golang.org/x/arch v0.0.0-20201008161808-52c3e6f60cff + golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 + golang.org/x/mod v0.4.0 + golang.org/x/sys v0.0.0-20201204225414-ed752295db88 // indirect + golang.org/x/tools v0.0.0-20201211025543-abf6a1d87e11 +) diff --git a/libgo/go/go.mod b/libgo/go/go.mod new file mode 100644 index 00000000000..4ae14eea5cb --- /dev/null +++ b/libgo/go/go.mod @@ -0,0 +1,10 @@ +module std + +go 1.16 + +require ( + golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 + golang.org/x/net v0.0.0-20201209123823-ac852fbbde11 + golang.org/x/sys v0.0.0-20201204225414-ed752295db88 // indirect + golang.org/x/text v0.3.4 // indirect +) diff --git a/libgo/go/vendor/modules.txt b/libgo/go/vendor/modules.txt new file mode 100644 index 00000000000..04bb67e58d6 --- /dev/null +++ b/libgo/go/vendor/modules.txt @@ -0,0 +1,29 @@ +# golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 +## explicit +golang.org/x/crypto/chacha20 +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/hkdf +golang.org/x/crypto/internal/subtle +golang.org/x/crypto/poly1305 +# golang.org/x/net v0.0.0-20201209123823-ac852fbbde11 +## explicit +golang.org/x/net/dns/dnsmessage +golang.org/x/net/http/httpguts +golang.org/x/net/http/httpproxy +golang.org/x/net/http2/hpack +golang.org/x/net/idna +golang.org/x/net/lif +golang.org/x/net/nettest +golang.org/x/net/route +# golang.org/x/sys v0.0.0-20201204225414-ed752295db88 +## explicit +golang.org/x/sys/cpu +# golang.org/x/text v0.3.4 +## explicit +golang.org/x/text/secure/bidirule +golang.org/x/text/transform +golang.org/x/text/unicode/bidi +golang.org/x/text/unicode/norm diff --git a/libgo/gotool-packages.txt b/libgo/gotool-packages.txt index c11df029192..f28ad6977aa 100644 --- a/libgo/gotool-packages.txt +++ b/libgo/gotool-packages.txt @@ -9,6 +9,7 @@ cmd/go/internal/doc cmd/go/internal/envcmd cmd/go/internal/fix cmd/go/internal/fmtcmd +cmd/go/internal/fsys cmd/go/internal/generate cmd/go/internal/get cmd/go/internal/help @@ -33,19 +34,23 @@ cmd/go/internal/search cmd/go/internal/str cmd/go/internal/test 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/internal/browser cmd/internal/buildid +cmd/internal/codesign cmd/internal/diff cmd/internal/edit cmd/internal/objabi cmd/internal/pkgpath cmd/internal/sys cmd/internal/test2json +cmd/internal/traceviewer golang.org/x/crypto/ed25519 golang.org/x/crypto/ed25519/internal/edwards25519 golang.org/x/mod/internal/lazyregexp @@ -70,6 +75,7 @@ golang.org/x/tools/go/analysis/passes/composite golang.org/x/tools/go/analysis/passes/copylock golang.org/x/tools/go/analysis/passes/ctrlflow golang.org/x/tools/go/analysis/passes/errorsas +golang.org/x/tools/go/analysis/passes/framepointer golang.org/x/tools/go/analysis/passes/httpresponse golang.org/x/tools/go/analysis/passes/ifaceassert golang.org/x/tools/go/analysis/passes/inspect @@ -83,6 +89,7 @@ golang.org/x/tools/go/analysis/passes/shift golang.org/x/tools/go/analysis/passes/stdmethods golang.org/x/tools/go/analysis/passes/stringintconv golang.org/x/tools/go/analysis/passes/structtag +golang.org/x/tools/go/analysis/passes/testinggoroutine golang.org/x/tools/go/analysis/passes/tests golang.org/x/tools/go/analysis/passes/unmarshal golang.org/x/tools/go/analysis/passes/unreachable @@ -95,5 +102,6 @@ golang.org/x/tools/go/cfg 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/xerrors golang.org/x/xerrors/internal diff --git a/libgo/libgo-packages.txt b/libgo/libgo-packages.txt index 0b02988d11d..20083bf280d 100644 --- a/libgo/libgo-packages.txt +++ b/libgo/libgo-packages.txt @@ -42,6 +42,7 @@ debug/gosym debug/macho debug/pe debug/plan9obj +embed encoding encoding/ascii85 encoding/asn1 @@ -126,12 +127,14 @@ internal/reflectlite internal/singleflight internal/syscall/execenv internal/syscall/unix +internal/sysinfo internal/testenv internal/testlog internal/trace internal/unsafeheader internal/xcoff io +io/fs io/ioutil log log/syslog @@ -175,6 +178,7 @@ runtime/debug runtime/internal/atomic runtime/internal/math runtime/internal/sys +runtime/metrics runtime/pprof runtime/trace sort @@ -184,6 +188,7 @@ sync sync/atomic syscall testing +testing/fstest testing/internal/testdeps testing/iotest testing/quick diff --git a/libgo/match.sh b/libgo/match.sh index 04db8d2c0d2..cc15a12c674 100755 --- a/libgo/match.sh +++ b/libgo/match.sh @@ -113,7 +113,7 @@ for f in $gofiles; do "") ;; $goarch) ;; $goos) ;; - aix | android | darwin | dragonfly | freebsd | illumos | hurd | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows) + aix | android | darwin | dragonfly | freebsd | illumos | hurd | ios | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows | zos) tag1=nonmatchingtag ;; 386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm) @@ -125,7 +125,7 @@ for f in $gofiles; do "") ;; $goarch) ;; $goos) ;; - aix | android | darwin | dragonfly | freebsd | hurd | illumos | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows) + aix | android | darwin | dragonfly | freebsd | hurd | ios | illumos | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows | zos) tag2=nonmatchingtag ;; 386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm) @@ -154,7 +154,7 @@ for f in $gofiles; do $goos | $goarch | $cgotag | $cmdlinetag | "gccgo" | go1.[0-9] | go1.[0-9][0-9]) match=true ;; - "!"$goos | "!"$goarch | "!"$cgotag | "!"$cmdlinetag | "!gccgo" | "!"go1.[0-9] | "!"go1.[0-9][0-9]) + "!"$goos | "!"$goarch | "!"$cgotag | "!"$cmdlinetag | "!gccgo" | "!"go1.[0-9] | "!"go1.1[0-6]) ;; *,*) cmatch=true @@ -162,7 +162,7 @@ for f in $gofiles; do case $ctag in $goos | $goarch | $cgotag | $cmdlinetag | "gccgo" | go1.[0-9] | go1.[0-9][0-9]) ;; - "!"$goos | "!"$goarch | "!"$cgotag | "!"$cmdlinetag | "!gccgo" | "!"go1.[0-9] | "!"go1.[0-9][0-9]) + "!"$goos | "!"$goarch | "!"$cgotag | "!"$cmdlinetag | "!gccgo" | "!"go1.[0-9] | "!"go1.1[0-6]) cmatch=false ;; "!"*) diff --git a/libgo/merge.sh b/libgo/merge.sh index f8de950fe2e..b672543a246 100755 --- a/libgo/merge.sh +++ b/libgo/merge.sh @@ -54,7 +54,13 @@ merge() { old=$2 new=$3 libgo=$4 - if ! test -f ${new}; then + if test -d ${new}; then + if ! test -d ${old}; then + if test -f ${old}; then + echo 1>&2 "merge.sh: ${name}: FILE BECAME DIRECTORY" + fi + fi + elif ! test -f ${new}; then # The file does not exist in the new version. if ! test -f ${old}; then echo 1>&2 "merge.sh internal error no files $old $new" @@ -128,7 +134,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/edit/* | ./cmd/internal/objabi/* | ./cmd/internal/test2json/* | ./cmd/internal/sys/* | ./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/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/*) skip=true @@ -147,10 +153,24 @@ echo ${rev} > VERSION merge $f ${oldfile} ${newfile} ${libgofile} done +(cd ${NEWDIR}/src && find . -name 'go.mod' -print) | while read f; do + oldfile=${OLDDIR}/src/$f + newfile=${NEWDIR}/src/$f + libgofile=go/`echo $f | sed -e 's|cmd/vendor/|/|' | sed -e 's|/vendor/|/|'` + merge $f ${oldfile} ${newfile} ${libgofile} +done + +(cd ${NEWDIR}/src && find . -name 'modules.txt' -print) | while read f; do + oldfile=${OLDDIR}/src/$f + newfile=${NEWDIR}/src/$f + libgofile=go/`echo $f | sed -e 's|cmd/vendor/|/|' | sed -e 's|/vendor/|/|'` + merge $f ${oldfile} ${newfile} ${libgofile} +done + (cd ${NEWDIR}/src && find . -name testdata -print) | while read d; do skip=false case "$d" in - ./cmd/buildid/* | ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | ./cmd/test2json/* | ./cmd/vet/* | ./cmd/internal/browser/* | ./cmd/internal/buildid/* | ./cmd/internal/diff/* | ./cmd/internal/edit/* | ./cmd/internal/objabi/* | ./cmd/internal/test2json/* | ./cmd/internal/sys/* | ./cmd/vendor/golang.org/x/tools/*) + ./cmd/buildid/* | ./cmd/cgo/* | ./cmd/go/* | ./cmd/gofmt/* | ./cmd/test2json/* | ./cmd/vet/* | ./cmd/internal/browser/* | ./cmd/internal/buildid/* | ./cmd/internal/codesign/* | ./cmd/internal/diff/* | ./cmd/internal/edit/* | ./cmd/internal/objabi/* | ./cmd/internal/test2json/* | ./cmd/internal/sys/* | ./cmd/internal/traceviewer/* | ./cmd/vendor/golang.org/x/tools/*) ;; ./cmd/*) skip=true diff --git a/libgo/misc/cgo/test/callback.go b/libgo/misc/cgo/test/callback.go index e7496502931..814888e3ac5 100644 --- a/libgo/misc/cgo/test/callback.go +++ b/libgo/misc/cgo/test/callback.go @@ -181,7 +181,7 @@ func testCallbackCallers(t *testing.T) { name := []string{ "runtime.cgocallbackg1", "runtime.cgocallbackg", - "runtime.cgocallback_gofunc", + "runtime.cgocallback", "runtime.asmcgocall", "runtime.cgocall", "test._Cfunc_callback", diff --git a/libgo/mkruntimeinc.sh b/libgo/mkruntimeinc.sh index 24837389f4f..dbe44d99175 100755 --- a/libgo/mkruntimeinc.sh +++ b/libgo/mkruntimeinc.sh @@ -17,8 +17,9 @@ rm -f runtime.inc.tmp2 runtime.inc.tmp3 # some systems and need not be exported back to C. # sigset conflicts with system type sigset on AIX, so we need to rename it. # boundsError has a field name that is a C keyword, and we don't need it. +# mSpanInuse is both a constant and a field name, and we don't need it. -grep -v "#define _" ${IN} | grep -v "#define [cm][01234] " | grep -v "#define empty " | grep -v "#define \\$" > runtime.inc.tmp2 +grep -v "#define _" ${IN} | grep -v "#define [cm][01234] " | grep -v "#define empty " | grep -v "#define \\$" | grep -v "#define mSpanInUse " > runtime.inc.tmp2 for pattern in '_[GP][a-z]' _Max _Lock _Sig _Trace _MHeap _Num do grep "#define $pattern" ${IN} >> runtime.inc.tmp2 diff --git a/libgo/runtime/go-caller.c b/libgo/runtime/go-caller.c index a18787671d1..f1077df6b77 100644 --- a/libgo/runtime/go-caller.c +++ b/libgo/runtime/go-caller.c @@ -65,10 +65,9 @@ callback (void *data, uintptr_t pc __attribute__ ((unused)), if (c->index == 0) { - /* If there are more frames after the indexed one, and we should - skip this one, then skip it. */ - if (c->more - && c->fn.len > 0 + /* If we should skip the frame we have, then see if we can get + another one. */ + if (c->fn.len > 0 && runtime_skipInCallback((const char *) c->fn.str, NULL)) return 0; diff --git a/libgo/testsuite/gotest b/libgo/testsuite/gotest index 8c3c5ca1b32..9eda2ccc70d 100755 --- a/libgo/testsuite/gotest +++ b/libgo/testsuite/gotest @@ -305,7 +305,7 @@ x) "") ;; $goarch) ;; $goos) ;; - aix | android | darwin | dragonfly | freebsd | hurd | illumos | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows) + aix | android | darwin | dragonfly | freebsd | hurd | ios | illumos | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows | zos) tag1=nonmatchingtag ;; 386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm) @@ -317,7 +317,7 @@ x) "") ;; $goarch) ;; $goos) ;; - aix | android | darwin | dragonfly | freebsd | hurd | illumos | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows) + aix | android | darwin | dragonfly | freebsd | hurd | ios | illumos | js | linux | nacl | netbsd | openbsd | plan9 | solaris | windows | zos) tag2=nonmatchingtag ;; 386 | amd64 | amd64p32 | arm | armbe | arm64 | arm64be | alpha | ia64 | m68k | mips | mipsle | mips64 | mips64le | mips64p32 | mips64p32le | nios2 | ppc | ppc64 | ppc64le | riscv | riscv64 | s390 | s390x | sh | shbe | sparc | sparc64 | wasm) @@ -345,7 +345,7 @@ x) $goos | $goarch | cgo | gccgo | go1.[0-9] | go1.[0-9][0-9]) match=true ;; - "!"$goos | "!"$goarch | "!cgo" | "!gccgo" | "!"go1.[0-9] | "!"go1.[0-9][0-9]) + "!"$goos | "!"$goarch | "!cgo" | "!gccgo" | "!"go1.[0-9] | "!"go1.1[0-6]) ;; *,*) cmatch=true @@ -353,7 +353,7 @@ x) case $ctag in $goos | $goarch | cgo | gccgo | go1.[0-9] | go1.[0-9][0-9]) ;; - "!"$goos | "!"$goarch | "!cgo" | "!gccgo" | "!"go1.[0-9] | "!"go1.[0-9][0-9]) + "!"$goos | "!"$goarch | "!cgo" | "!gccgo" | "!"go1.[0-9] | "!"go1.1[0-6]) cmatch=false ;; "!"*) diff --git a/libgo/go/os/dir_gccgo_c.c b/libgo/go/os/dir_gccgo_c.c new file mode 100644 index 00000000000..66b9be1dfdc --- /dev/null +++ b/libgo/go/os/dir_gccgo_c.c @@ -0,0 +1,58 @@ +/* Copyright 2020 The Go Authors. All rights reserved. + Use of this source code is governed by a BSD-style + license that can be found in the LICENSE file. */ + +#include <dirent.h> + +#include "runtime.h" + +unsigned char direntType (struct dirent *) + __asm__ (GOSYM_PREFIX "os.direntType"); + +unsigned char +direntType (struct dirent *p __attribute__((unused))) +{ +#ifndef HAVE_STRUCT_DIRENT_D_TYPE + return 'U'; +#else + switch (p->d_type) + { +#ifdef DT_BLK + case DT_BLK: + return 'B'; +#endif +#ifdef DT_CHR + case DT_CHR: + return 'C'; +#endif +#ifdef DT_DBF + case DT_DBF: + // Database record file. + // Treat as regular file. + return 'R'; +#endif +#ifdef DT_DIR + case DT_DIR: + return 'D'; +#endif +#ifdef DT_FIFO + case DT_FIFO: + return 'F'; +#endif +#ifdef DT_LNK + case DT_LNK: + return 'L'; +#endif +#ifdef DT_REG + case DT_REG: + return 'R'; +#endif +#ifdef DT_SOCK + case DT_SOCK: + return 'S'; +#endif + default: + return 'U'; + } +#endif /* HAVE_DIRENT_D_TYPE */ +} diff --git a/libgo/go/os/dir_gccgo.go b/libgo/go/os/dir_gccgo.go index 171dde5097b..31ee2621e40 100644 --- a/libgo/go/os/dir_gccgo.go +++ b/libgo/go/os/dir_gccgo.go @@ -5,9 +5,8 @@ package os import ( + "internal/poll" "io" - "runtime" - "sync/atomic" "syscall" "unsafe" ) @@ -16,8 +15,7 @@ import ( //extern pathconf func libc_pathconf(*byte, int32) int -//extern dup -func libc_dup(int32) int32 +func direntType(*syscall.Dirent) byte func clen(n []byte) int { for i := 0; i < len(n); i++ { @@ -28,95 +26,118 @@ func clen(n []byte) int { return len(n) } -var nameMax int32 - -func (file *File) readdirnames(n int) (names []string, err error) { - if file.dirinfo == nil { - p, err := syscall.BytePtrFromString(file.name) +func (f *File) readdir(n int, mode readdirMode) (names []string, dirents []DirEntry, infos []FileInfo, err error) { + // If this file has no dirinfo, create one. + if f.dirinfo == nil { + fd, call, err := poll.DupCloseOnExec(int(f.pfd.Sysfd)) if err != nil { - return nil, err - } - - elen := int(atomic.LoadInt32(&nameMax)) - if elen == 0 { - syscall.Entersyscall() - plen := libc_pathconf(p, syscall.PC_NAME_MAX) - syscall.Exitsyscall() - if plen < 1024 { - plen = 1024 - } - var dummy syscall.Dirent - elen = int(unsafe.Offsetof(dummy.Name)) + plen + 1 - atomic.StoreInt32(&nameMax, int32(elen)) + return nil, nil, nil, NewSyscallError(call, err) } syscall.Entersyscall() - fd := libc_dup(int32(file.pfd.Sysfd)) + r := libc_fdopendir(int32(fd)) errno := syscall.GetErrno() syscall.Exitsyscall() - if fd < 0 { - return nil, &PathError{"dup", file.name, errno} - } - - syscall.Entersyscall() - r := libc_fdopendir(fd) - errno = syscall.GetErrno() - syscall.Exitsyscall() if r == nil { - return nil, &PathError{"fdopendir", file.name, errno} + return nil, nil, nil, &PathError{"fdopendir", f.name, errno} } - file.dirinfo = new(dirInfo) - file.dirinfo.buf = make([]byte, elen) - file.dirinfo.dir = r + f.dirinfo = &dirInfo{r} } - - entryDirent := (*syscall.Dirent)(unsafe.Pointer(&file.dirinfo.buf[0])) - - size := n - if size <= 0 { - size = 100 + dir := f.dirinfo.dir + + // Change the meaning of n for the implementation below. + // + // The n above was for the public interface of "if n <= 0, + // Readdir returns all the FileInfo from the directory in a + // single slice". + // + // But below, we use only negative to mean looping until the + // end and positive to mean bounded, with positive + // terminating at 0. + if n == 0 { n = -1 } - names = make([]string, 0, size) // Empty with room to grow. - for n != 0 { - var dirent *syscall.Dirent - pr := &dirent syscall.Entersyscall() - i := libc_readdir_r(file.dirinfo.dir, entryDirent, pr) + syscall.SetErrno(0) + dirent := libc_readdir(dir) + errno := syscall.GetErrno() syscall.Exitsyscall() - // On AIX when readdir_r hits EOF it sets dirent to nil and returns 9. - // https://www.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.basetrf2/readdir_r.htm - if runtime.GOOS == "aix" && i == 9 && dirent == nil { - break - } - if i != 0 { - return names, NewSyscallError("readdir_r", i) - } + if dirent == nil { + if errno != 0 { + return names, dirents, infos, &PathError{Op: "readdir", Path: f.name, Err: errno} + } break // EOF } - bytes := (*[10000]byte)(unsafe.Pointer(&dirent.Name[0])) - var name = string(bytes[0:clen(bytes[:])]) - if name == "." || name == ".." { // Useless names + + // In some cases the actual name can be longer than + // the Name field. + name := (*[1 << 16]byte)(unsafe.Pointer(&dirent.Name[0]))[:] + for i, c := range name { + if c == 0 { + name = name[:i] + break + } + } + // Check for useless names before allocating a string. + if (len(name) == 1 && name[0] == '.') || (len(name) == 2 && name[0] == '.' && name[1] == '.') { continue } - names = append(names, name) - n-- - } - if n >= 0 && len(names) == 0 { - return names, io.EOF + if n > 0 { // see 'n == 0' comment above + n-- + } + if mode == readdirName { + names = append(names, string(name)) + } else if mode == readdirDirEntry { + var typ FileMode + switch direntType(dirent) { + case 'B': + typ = ModeDevice + case 'C': + typ = ModeDevice | ModeCharDevice + case 'D': + typ = ModeDir + case 'F': + typ = ModeNamedPipe + case 'L': + typ = ModeSymlink + case 'R': + typ = 0 + case 'S': + typ = ModeSocket + case 'U': + typ = ^FileMode(0) + } + + de, err := newUnixDirent(f.name, string(name), typ) + if IsNotExist(err) { + // File disappeared between readdir and stat. + // Treat as if it didn't exist. + continue + } + if err != nil { + return nil, dirents, nil, err + } + dirents = append(dirents, de) + } else { + info, err := lstat(f.name + "/" + string(name)) + if IsNotExist(err) { + // File disappeared between readdir + stat. + // Treat as if it didn't exist. + continue + } + if err != nil { + return nil, nil, infos, err + } + infos = append(infos, info) + } } - return names, nil -} -func (f *File) seekInvalidate() { - if f.file.dirinfo != nil { - syscall.Entersyscall() - libc_closedir(f.file.dirinfo.dir) - syscall.Exitsyscall() - f.file.dirinfo = nil + if n > 0 && len(names)+len(dirents)+len(infos) == 0 { + return nil, nil, nil, io.EOF } + return names, dirents, infos, nil }