Commit Graph

1338 Commits

Author SHA1 Message Date
Ian Lance Taylor 2b6d99468d libgo: update to Go 1.14.4 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/241999
2020-07-10 11:30:23 -07:00
Tobias Klauser 882af4350b libgo: update x/sys/cpu to add all GOARCHes supported by gccgo
CL 237897 added additional GOARCHes supported by gccgo to x/sys/cpu.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/238038
2020-06-15 14:20:07 -07:00
Tobias Klauser 47ad09cb08 internal/syscall/unix: use getrandom_linux_generic.go on riscv
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/237899
2020-06-15 12:00:12 -07:00
Clément Chigot 75452d6867 runtime: fix arenaBaseOffset for aix/ppc
The arenaBaseOffset modifications was aimed only for aix/ppc64.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/237038
2020-06-12 16:30:53 -07:00
Clément Chigot adad99eb90 libgo: update x/sys/cpu after gccgo support added
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/234597
2020-05-25 13:43:44 -07:00
Ian Lance Taylor e478cacb62 libgo: only build syscall test with -static if it works
Test whether -static works, and use it if possible.

This time for sure.

For PR go/95061

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/234024
2020-05-15 15:33:20 -07:00
Ian Lance Taylor 3a36428b5f libgo: only build syscall test with -static on GNU/Linux
For PR go/95061

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/234019
2020-05-14 13:37:12 -07:00
Ian Lance Taylor 0d5d880994 libgo: build syscall test with -static
This avoids problems finding libgo.so when running the test as root,
which invokes the test as a child process in various limited environments.

Fixes PR go/95061

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/233897
2020-05-13 11:45:55 -07:00
eric fang 5ca5751823 runtime: fix TestCallersNilPointerPanic
The expected result of TestCallersNilPointerPanic has changed in
GoLLVM.  This CL makes some elements of the expected result optional
so that this test passes in both gccgo and GoLLVM.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/230138
2020-05-11 17:36:24 -07:00
Ian Lance Taylor 4f157ed774 syscall: append to environment in tests, don't clobber it
This is a partial backport of https://golang.org/cl/233318.
It's only a partial backport because part of the change was
already applied to libgo in CL 193497 as part of the update
to the Go 1.13beta1 release.

Fixes PR go/95061

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/233359
2020-05-11 17:27:46 -07:00
eric fang ef8dc9d240 gotest: increase the test timeout
The default test timeout duration of the gc compiler is 10 minutes,
and the current default timeout duration of gofrontend is 240 seconds,
which is not long enough for some big tests. This CL changes it to
600s, so that all tests have enough time to complete.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/229657
2020-04-23 20:16:32 -07:00
Benny Siegert 8e841bd419 gccgo: fix runtime compilation on NetBSD
si_code in siginfo_t is a macro on NetBSD, not a member of the
struct itself, so add a C trampoline for receiving its value.

Also replace references to mos.waitsemacount with the replacement and
add some helpers from os_netbsd.go in the GC repository.

Update golang/go#38538.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/228918
2020-04-20 21:20:53 -07:00
eric fang 677ead3b34 runtime: use 64 bits of hash seed on arm64
This is the same issue as #33960, but on gofrontend.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/220297
2020-04-15 14:24:33 -07:00
Ian Lance Taylor d79a22eddc libgo: update to final 1.14.2 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/227551
2020-04-09 20:14:25 -07:00
Ian Lance Taylor 52fa80f853 libgo: update to almost the 1.14.2 release
Update to edea4a79e8d7dea2456b688f492c8af33d381dc2 which is likely to
be approximately the 1.14.2 release.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/227377
2020-04-06 16:37:24 -07:00
eric fang 3f469f585e runtime: handle linux/arm64 signal register
Set sigpc and implement dumpregs for linux/arm64.
Without this change, cmd/vet tool test will fail randomly.

Updates golang/go#20931

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/220543
2020-02-28 12:24:21 -08:00
Ian Lance Taylor c5decc83e4 libgo: update to final Go1.14 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/221158
2020-02-26 12:19:13 -08:00
Ian Lance Taylor a4dbb9b25a internal/poll: add hurd build tag
Patch from Svante Signell.

Fixes GCC PR go/93900

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/220592
2020-02-24 09:29:51 -08:00
Ian Lance Taylor 027a3f1c38 internal/syscall/unix: add hurd build tag
Patch from Svante Signell.

Fixes GCC PR go/93900

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/220589
2020-02-24 06:42:05 -08:00
Ian Lance Taylor 855b4aaeab cmd/go: update -DGOPKGPATH to use current pkgpath encoding
This will need to be done in the gc version too, probably more cleverly.
This version will ensure that the next GCC release works correctly
when using the GCC version of the go tool.

Updates golang/go#37272

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/219817
2020-02-18 12:03:13 -08:00
Ian Lance Taylor 72700543b6 libgo: install internal/reflectlite.gox
This makes it possible to use gccgo to bootstrap Go 1.14.
If we don't install this, gccgo can't compile the sort package.

Fixes GCC PR go/93679

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/219617
2020-02-16 05:20:26 -08:00
Ian Lance Taylor 0b3c2eed35 libgo: update to Go1.14rc1 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/218017
2020-02-15 09:14:10 -08:00
Ian Lance Taylor 17edb3310d runtime: on 32-bit systems, limit default GOMAXPROCS to 32
Otherwise we can easily run out of stack space for threads.

The user can still override by setting GOMAXPROCS.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/219278
2020-02-15 09:12:18 -08:00
Ian Lance Taylor 79530f94e9 syscall: fix riscv64 GNU/Linux build
Make syscall_linux_riscv64.go, new in the 1.14beta1 release, look like
the other syscall_linux_GOARCH.go files.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/217577
2020-02-03 18:14:19 -08:00
Ian Lance Taylor 66af5a226a runtime, syscall: add a couple of hurd build tags
Patch by Svante Signell.

Updates PR go/93468

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/216959
2020-01-29 16:43:57 -08:00
Ian Lance Taylor 68f3759eff runtime: update netpoll_hurd.go for go1.14beta1 changes
Patch from Svante Signell.

Updates PR go/93468

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/216958
2020-01-29 16:40:19 -08:00
Ian Lance Taylor ba386bea11 libgo: handle --with-toolexeclibdir=.
Patch by Maciej W. Rozycki.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/216239
2020-01-24 06:33:46 -08:00
Ian Lance Taylor 1e156d9b21 internal/cpu: don't define CacheLinePadSize for riscv64
In libgo CacheLinePadSize is defined by the generated file cpugen.go.

Keep cpu_riscv64.go around, even though it is now empty, so that
we will pick up changes to it in future merges.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/216077
2020-01-23 16:05:47 -08:00
Ian Lance Taylor 92bea423c2 gotest: explicitly skip type descriptors
Type descriptors are normally weak and nm will report them as V,
so we will skip them when collecting the list of symbols.
But when not using GNU nm, they may be reported as D,
so also skip them in symstogo.

This fixes go/doc/check on Solaris.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/215900
2020-01-22 20:53:43 -08:00
Ian Lance Taylor 9e16359ce8 runtime: for Solaris, add osinit, and drop duplicate getncpu
Fixes a build breakage introduced in the 1.14beta1 upgrade.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/215857
2020-01-22 15:08:25 -08:00
Andrew Pinski 26afdf5070 internal/syscall/unix: use getrandom_linux_generic.go on arm64be
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/215342
2020-01-22 15:05:26 -08:00
Ian Lance Taylor 68cbbe7cdc runtime: call runtime_nanotime1, not runtime_nanotime
The function name was changed in 1.14beta1. Fix the non-x86, non-s390 code.

Fixes golang/go#36694

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/215724
2020-01-22 11:14:52 -08:00
Ian Lance Taylor 5a8ea16592 libgo: update to Go1.14beta1
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/214297
2020-01-21 23:53:22 -08:00
Ian Lance Taylor 3a33f87ffb gotest: don't use local
It's not part of the POSIX shell standard.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/214300

From-SVN: r280118
2020-01-10 15:28:20 +00:00
Ian Lance Taylor fcee603081 libgo: compile examples in _test packages
Previously if the only names defined by _test packages were examples,
    the gotest script would emit an incorrect _testmain.go file.
    I worked around that by marking the example_test.go files +build ignored.
    
    This CL changes the gotest script to handle this case correctly,
    and removes the now-unnecessary build tags.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/214039

From-SVN: r280085
2020-01-09 23:14:57 +00:00
Ian Lance Taylor 81f025b580 compiler, runtime: stop using __go_runtime_error
Use specific panic functions instead, which are mostly already in the
    runtime package.
    
    Also correct "defer nil" to panic when we execute the defer, rather
    than throw when we queue it.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/213642

From-SVN: r279979
2020-01-07 23:13:24 +00:00
Ian Lance Taylor 10172a64ce compiler, runtime, reflect: generate hash functions only for map keys
Right now we generate hash functions for all types, just in case they
    are used as map keys. That's a lot of wasted effort and binary size
    for types which will never be used as a map key. Instead, generate
    hash functions only for types that we know are map keys.
    
    Just doing that is a bit too simple, since maps with an interface type
    as a key might have to hash any concrete key type that implements that
    interface. So for that case, implement hashing of such types at
    runtime (instead of with generated code). It will be slower, but only
    for maps with interface types as keys, and maybe only a bit slower as
    the aeshash time probably dominates the dispatch time.
    
    Reorg where we keep the equals and hash functions. Move the hash function
    from the key type to the map type, saving a field in every non-map type.
    That leaves only one function in the alg structure, so get rid of that and
    just keep the equal function in the type descriptor itself.
    
    While we're here, reorganize the rtype struct to more closely match
    the gc version.
    
    This is the gofrontend version of https://golang.org/cl/191198.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/212843

From-SVN: r279848
2020-01-02 21:55:32 +00:00
Ian Lance Taylor f2a8799309 re PR go/93020 (Final patches to build gcc-10 on GNU/Hurd)
PR go/93020
    libgo: Hurd portability patches
    
    By Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/212409

From-SVN: r279724
2019-12-24 05:05:32 +00:00
Ian Lance Taylor 763c9f4a85 re PR go/92861 (Passes relative time to sem_timedwait on GNU/Hurd)
PR go/92861
    runtime: don't define CLOCK_REALTIME in os_hurd.go
    
    It's already defined in sysinfo.go.
    
    Patch by Samuel Thibault.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/210538

From-SVN: r279136
2019-12-09 18:03:53 +00:00
Ian Lance Taylor 9135a6ffc5 re PR go/92861 (Passes relative time to sem_timedwait on GNU/Hurd)
PR go/92861
    runtime: use absolute time for sem_timedwait
    
    Patch by Samuel Thibault.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/210457

From-SVN: r279106
2019-12-09 03:43:33 +00:00
Ian Lance Taylor eff6af8e0e re PR go/92820 (libgo.so.15 has executable stack)
PR go/92820
    runtime: only build go-context for x86 GNU/Linux
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/210258

From-SVN: r279063
2019-12-06 19:52:46 +00:00
Ian Lance Taylor 5ec7a413d1 re PR other/29842 ([meta-bug] outstanding patches / issues from STMicroelectronics)
PR go/29842
    runtime: update HURD support for mOS now being embedded
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/210285

From-SVN: r279062
2019-12-06 19:37:39 +00:00
Ian Lance Taylor 9961856c3a re PR go/92810 (Compiling GCC go for aarch64_be-marvell-linux-gnu fails)
PR go/92810
    libgo: recognize aarch64_be as arm64be
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/210038

From-SVN: r279032
2019-12-06 05:32:49 +00:00
Ian Lance Taylor 9bcee9c9a1 re PR go/92820 (libgo.so.15 has executable stack)
PR go/92820
    runtime: always mark assembly file as non-executable stack
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/210037

From-SVN: r279010
2019-12-05 17:51:10 +00:00
Ian Lance Taylor b4b7464b57 re PR go/92605 (r278509 causes/reveals issue in building go library)
PR go/92605
    runtime: declare runtime_usestackmaps in stack.c, not runtime.h
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/208161

From-SVN: r278540
2019-11-21 01:06:47 +00:00
Ian Lance Taylor 025f56b7d3 mksysinfo: use type aliases for time struct field types
Also fix a case where grep wasn't redirecting to /dev/null.
    
    Fixes golang/go#35713
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/208160

From-SVN: r278539
2019-11-21 01:03:55 +00:00
Ian Lance Taylor 0c6ce0ae55 libgo: better cmd/cgo handling for '.' in pkgpath
Updates cgo's gccgoPkgpathToSymbolNew() to bring it into
    conformance with the way that gccgo now handles package
    paths with embedded dots (see CL 200838). See also
    https://gcc.gnu.org/PR61880, a related bug. This CL is a
    copy of CL 207957 in the main Go repo.
    
    Updates golang/go#35623.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/207977

From-SVN: r278470
2019-11-19 23:04:08 +00:00
Ian Lance Taylor ae0b0fc6ae testmain.exp: link against GOLIBS
Patch by Maciej W. Rozycki.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/207458

From-SVN: r278316
2019-11-15 21:14:29 +00:00
Ian Lance Taylor b72813a68c libgo: fix DejaGNU testsuite compiler when using build sysroot
Patch by Maciej W. Rozycki.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/206577

From-SVN: r278070
2019-11-11 23:28:54 +00:00
Ian Lance Taylor 2dccdbcff6 runtime: correct facilities names in s390 CPU support
Patch from Andreas Krebbel.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/201038

From-SVN: r276964
2019-10-14 14:10:16 +00:00
Ian Lance Taylor d2317d50ae internal/cpu: define kdsaQuery for s390
Patch from Andreas Krebbel.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/201037

From-SVN: r276962
2019-10-14 14:01:15 +00:00
Ian Lance Taylor b7c4123032 runtime: mark go-context.S as no-executable-stack and split-stack supported
The .note.GNU-stack section tells the linker that this object does not
    require an executable stack.
    
    The .note.GNU-split-stack section tells the linker that functions in
    this object can be called directly by split-stack functions, without
    require a large stack.
    
    The .note.GNU-no-split-stack section tells the linker that functions
    in this object do not have a split-stack prologue.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/198440

From-SVN: r276488
2019-10-02 20:11:35 +00:00
Ian Lance Taylor ab2d47a87f libgo: support gollvm build on arm64 linux
This CL serves as part of an initial change for enabling gollvm
    building on arm64 linux, the rest of the change will be covered by
    another one to the gollvm repo.
    
    Incorporate type definition of 'uint128' to 'runtime' and 'syscall'
    packges, the change is not specific to arm64 linux but made available
    for all platforms.
    
    Verified by building and unit-testing gollvm on linux x86-64 and arm64.
    
    Verified by building and checking gccgo on linux x86-64 and arm64.
    
    Fixes golang/go#33711
    
    Change-Id: I4720c7d810cfd4ef720962fb4104c5641b2459c0

From-SVN: r275919
2019-09-19 00:03:25 +00:00
Ian Lance Taylor 7e6fecf500 runtime: for FFI, treat directIface types as pointers
This only matters on systems that pass a struct with a single pointer
    field differently than passing a single pointer.  I noticed it on
    32-bit PPC, where the reflect package TestDirectIfaceMethod failed.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/195878

From-SVN: r275814
2019-09-17 20:26:21 +00:00
Ian Lance Taylor 033425d0ed re PR go/91781 (r275691 breaks go test "reflect")
PR go/91781
    reflect: promote integer closure return to full word
    
    The libffi library expects an integer return type to be promoted to a
    full word.  Implement that when returning from a closure written in Go.
    This only matters on big-endian systems when returning an integer smaller
    than the pointer size, which is why we didn't notice it until now.
    
    Fixes https://gcc.gnu.org/PR91781.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/195858

From-SVN: r275813
2019-09-17 20:24:00 +00:00
Ian Lance Taylor 99a28ee8c1 reflect: unexport FFICallbackGo; use go:linkname instead
The function was always intended to be internal-only, but was exported
    so that C code could call it. Now that have go:linkname for that, use it.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/195857

From-SVN: r275809
2019-09-17 17:22:18 +00:00
Ian Lance Taylor 57cccc860e libgo: don't use \? in grep pattern
It's not supported by Solaris grep.  Just use * instead; it matches
    more but it shouldn't matter.
    
    Fixes https://gcc.gnu.org/PR91764
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/195238

From-SVN: r275700
2019-09-13 17:07:20 +00:00
Ian Lance Taylor 656297e1fe libgo: update to Go1.13
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194698

From-SVN: r275691
2019-09-12 23:22:53 +00:00
Ian Lance Taylor debae5232b golang.org/x/sys/cpu: define doinit when needed
Should fix the build on riscv64 and other systems.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194641

From-SVN: r275650
2019-09-11 14:06:05 +00:00
Ian Lance Taylor d694576e17 gotest: force test package to be imported first
When compiling the x_test package, force the test package to be
    imported first.  That ensures that we will see the types defined in
    the test package before the types defined in the non-test version of
    the package.  This matters if the types differ in some way, such as by
    adding a new method.
    
    This avoids a failure in internal/poll on Solaris, in which the test
    package adds a method to a type (FD.EOFError).  I think it was Solaris-
    specific because files are sorted in a different order by default.
    
    The go tool handles this kind of thing correctly, by rebuilding
    dependent packages.  This is just a hack sufficient to run the libgo
    testsuite without using the go tool.
    
    Fixes https://gcc.gnu.org/PR91712
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194637

From-SVN: r275648
2019-09-11 12:44:12 +00:00
Ian Lance Taylor efc864927f libgo: Solaris and x/sys/cpu compatibility fixes
Restore Solaris compatibility fixes lost when internal/x/net/lif moved
    to golang.org/x/net/lif.  Also fix the Makefile for x/net/lif and
    x/net/route.
    
    Change x/sys/cpu to get the cache line size from goarch.sh as the
    gofrontend version of internal/cpu does.
    
    Partially based on work by Rainer Orth.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194438

From-SVN: r275611
2019-09-10 20:41:04 +00:00
Ian Lance Taylor 4d7bfeec42 re PR go/91621 (libgo/mksysinfo.sh: please avoid test ==)
PR go/91621
    mksysinfo: change test == to test =
    
    Fixes https://gcc.gnu.org/PR91621
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194569

From-SVN: r275608
2019-09-10 20:32:20 +00:00
Ian Lance Taylor a1fc3891eb go/internal/gccgoimporter: support embedded field in pointer loop
Backport of https://golang.org/cl/194440.  Original description:
    
        If an embedded field refers to a type via a pointer, the parser needs
        to know the name of the embedded field. It is possible that the
        pointer type is not yet resolved. This CL fixes the parser to handle
        that case by setting the pointer element type to the unresolved named
        type while the pointer is being resolved.
    
    Updates golang/go#34182
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194562

From-SVN: r275606
2019-09-10 20:25:32 +00:00
Ian Lance Taylor c96fc08123 cmd/go: look for tool build ID before hashing entire file
Also fix the key used to store the ID.
    
    This is a significant speedup in cmd/go run time.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194257

From-SVN: r275559
2019-09-10 02:48:24 +00:00
Ian Lance Taylor 8bdcbd0135 misc/cgo/testcshared: restore gofrontend-local changes
They were lost when the files were moved in the update to Go1.13beta1.
    These changes should be made in the master repo for the 1.14 release,
    as riscv64 support is added there.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194343

From-SVN: r275551
2019-09-09 23:13:08 +00:00
Ian Lance Taylor de0f55dbb3 libgo: only build x/sys/cpu/cpu_gccgo.c on x86 systems
The C file has a build tag, but the procedure we use for building C
    files ignores build tags.
    
    This should fix the libgo build on non-x86 systems.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/194378

From-SVN: r275544
2019-09-09 20:08:32 +00:00
Ian Lance Taylor aa8901e9bb libgo: update to Go 1.13beta1 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/193497

From-SVN: r275473
2019-09-06 18:12:46 +00:00
Ian Lance Taylor c70ff9f9be compiler, runtime: support and use single argument go:linkname
The gc compiler has started permitting go:linkname comments with a
    single argument to mean that a function should be externally visible
    outside the package.  Implement this in the Go frontend.
    
    Change the libgo runtime package to use it, rather than repeating the
    name just to export a function.
    
    Remove a couple of unnecessary go:linkname comments on declarations.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/192197

From-SVN: r275239
2019-08-31 03:01:15 +00:00
Ian Lance Taylor d24c41ef1a runtime: always build panic32.go
Avoids problems with arm64 ILP32 mode.  We might want to handle that
    mode better in general, but always building panic32.go is simple and
    fixes the build.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/192723

From-SVN: r275237
2019-08-31 02:55:09 +00:00
Ian Lance Taylor 4a14082645 compile, runtime: permit anonymous and empty fields in C header
Permit putting structs with anonymous and empty fields in the C header
    file runtime.inc that is used to build the C runtime code.  This is
    required for upcoming 1.13 support, as the m struct has picked up an
    anonymous field.
    
    Doing this lets the C header contain all the type descriptor structs,
    so start using those in the C code.  This cuts the number of copies of
    type descriptor definitions from 3 to 2.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/192343

From-SVN: r275227
2019-08-30 21:49:49 +00:00
Ian Lance Taylor 32b1d51f16 runtime: move osinit to Go
This is a step toward updating libgo to 1.13.  This adds the 1.13
    version of the osinit function to Go code, and removes the
    corresponding code from the C runtime.  This should simplify future updates.
    Some additional 1.13 code was brought in to simplify this change.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/191717

From-SVN: r275010
2019-08-28 20:39:32 +00:00
Ian Lance Taylor fc4f90f0c8 compiler, runtime: provide index information on bounds check failure
This implements https://golang.org/cl/161477 in the gofrontend.
    
    Updates golang/go#30116
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/191881

From-SVN: r274998
2019-08-28 18:27:30 +00:00
Ian Lance Taylor 433f84bffa libgo: rebuild runtime.inc if mkruntimeinc.sh changes
The Makefile was missing a dependency.
    
    Also remove runtime.inc.raw in mostlyclean.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/191958

From-SVN: r274956
2019-08-27 14:25:04 +00:00
Ian Lance Taylor 6ae361ae45 compiler: record pointer var values to remove write barriers
Record when a local pointer variable is set to a value such that
    indirecting through the pointer does not require a write barrier.  Use
    that to eliminate write barriers when indirecting through that local
    pointer variable.  Only keep this information per-block, so it's not
    all that applicable.
    
    This reduces the number of write barriers generated when compiling the
    runtime package from 553 to 524.
    
    The point of this is to eliminate a bad write barrier in the bytes
    function in runtime/print.go.  Mark that function nowritebarrier so
    that the problem does not recur.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/191581

From-SVN: r274890
2019-08-23 22:38:58 +00:00
Ian Lance Taylor 43055d2379 compiler, runtime: implement shifts by signed amounts
Shifting by signed types is a new language feature in Go 1.13.
    
    This requires a patch to the testsuite.
    
    Updates golang/go#19113
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/190977

	* go.test/test/fixedbugs/bug073.go: Update for language changes.

From-SVN: r274755
2019-08-20 21:15:46 +00:00
Ian Lance Taylor 4f6bdb08ba runtime: be more strict in GC
With CL 190599, along with what we do in greyobject, we ensure
    that we only mark allocated heap objects. As a result we can be
    more strict in GC:
    
    - Enable "sweep increased allocation count" check, which checks
      that the number of mark bits set are no more than the number of
      allocation bits.
    
    - Enable invalid pointer check on heap scan. We only trace
      allocated heap objects, which should not contain invalid
      pointer.
    
    This also makes the libgo runtime more convergent with the gc
    runtime.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/190797

From-SVN: r274678
2019-08-19 19:09:50 +00:00
Ian Lance Taylor e68035acfd compiler, runtime: allocate defer records on the stack
When a defer is executed at most once in a function body,
    we can allocate the defer record for it on the stack instead
    of on the heap.
    
    This should make defers like this (which are very common) faster.
    
    This is a port of CL 171758 from the gc repo.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/190410

From-SVN: r274613
2019-08-17 23:43:08 +00:00
Ian Lance Taylor 777c028252 runtime: scan write barrier buffer conservatively
In gccgo, we insert the write barriers in the frontend, and so we
    cannot completely prevent write barriers on stack writes. So it
    is possible for a bad pointer appearing in the write barrier
    buffer. When flushing the write barrier, treat it the same as
    sacnning the stack. In particular, don't mark a pointer if it
    does not point to an allocated object. We already have similar
    logic in greyobject. With this, hopefully, we can prevent an
    unallocated object from being marked completely.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/190599

From-SVN: r274598
2019-08-17 04:35:37 +00:00
Ian Lance Taylor 4e62f891cd runtime: expose the g variable
Currently, getg is implemented in C, which loads the thread-local
    g variable. The g variable is declared static in C.
    
    This CL exposes the g variable, so it can be accessed from the Go
    side. This allows the Go compiler to inline getg calls to direct
    access of g.
    
    Currently, the actual inlining is only implemented in the gollvm
    compiler. The g variable is thread-local and the compiler backend
    may choose to cache the TLS address in a register or on stack. If
    a thread switch happens the cache may become invalid. I don't
    know how to disable the TLS address cache in gccgo, therefore
    the inlining of getg is not implemented. In the future gccgo may
    gain this if we know how to do it safely.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/186238

From-SVN: r273499
2019-07-15 21:17:16 +00:00
Ian Lance Taylor 0e68d70b7f compiler: optimize 0,1,2-case select statement
For a select statement with zero-, one-, or two-case with a
    default case, we can generate simpler code instead of calling the
    generic selectgo. A zero-case select is just blocking the
    execution. A one-case select is mostly just executing the case. A
    two-case select with a default case is a non-blocking send or
    receive. We add these special cases for lowering a select
    statement.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/184998

From-SVN: r273034
2019-07-04 02:20:37 +00:00
Ian Lance Taylor 07525dad06 libgo/testsuite: ignore symbols with a leading dot in symtogo
On AIX, a function has two symbols, a text symbol (with a leading dot)
    and a data one (without it).
    As the tests must be run only once, only the data symbol can be used to
    retrieve the final go symbol. Therefore, all symbols beginning with a dot
    are ignored by symtogo.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/177837

From-SVN: r272666
2019-06-26 00:17:32 +00:00
Ian Lance Taylor c31a34018a cmd/go: silence ar with D flag failures
The first call of ar must not show its output in order to avoid useless
    error messages about D flag.
    The corresponding Go toolchain patch is CL 182077.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/183817

From-SVN: r272661
2019-06-26 00:04:36 +00:00
Ian Lance Taylor 81fadf1c8d runtime: mark memequal and memclrNoHeapPointers nosplit
They are wrappers of libc functions that use no stack. Mark them
    nosplit so the linker won't patch it to call __morestack_non_split.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/183629

From-SVN: r272633
2019-06-25 06:16:21 +00:00
Ian Lance Taylor 609c7da9ab compiler: open code string equality
Open code string equality with builtin memcmp. This allows
    further optimizations in the backend.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/183538

From-SVN: r272624
2019-06-24 17:54:07 +00:00
Ian Lance Taylor 2b92d5c69b compiler: use builtin memcmp directly
Instead of going through a C function __go_memcmp, we can just
    use __builtin_memcmp directly. This allows more optimizations in
    the compiler backend.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/183537

From-SVN: r272620
2019-06-24 16:54:22 +00:00
Ian Lance Taylor f4e7200b1d runtime: inline and remove eqtype
Now that type equality is just a pointer equality, write it
    inlined and remove the eqtype function.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/182978

From-SVN: r272578
2019-06-21 22:21:40 +00:00
Ian Lance Taylor 0514cb3374 compiler: open code some type assertions
Now that type equality is just simple pointer equality, we can
    open code some type assertions instead of making runtime calls.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/182977

From-SVN: r272577
2019-06-21 22:00:57 +00:00
Ian Lance Taylor c9b236e5ca compiler: open code string slice expressions
Currently a string slice expression is implemented with a runtime
    call __go_string_slice. Change it to open code it, which is more
    efficient, and allows the backend to further optimize it.
    
    Also omit the write barrier for length-only update (i.e.
    s = s[:n]).
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/182540

From-SVN: r272549
2019-06-21 14:14:58 +00:00
Ian Lance Taylor 4349775a30 compiler: optimize string concatenations
runtime.concatstring{2,3,4,5} are just wrappers of concatstrings.
    These wrappers don't provide any benefit, at least in the C
    calling convention we use, where passing arrays by value isn't an
    efficient thing. Change it to always use concatstrings.
    
    Also, the cap field of the slice passed to concatstrings is not
    necessary. So change it to pass a pointer and a length directly,
    which is more efficient than passing a slice header by value.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/182539

From-SVN: r272476
2019-06-19 15:13:53 +00:00
Ian Lance Taylor ffaa3a1c74 go/internal/gccgoimporter: ignore unexported and imported names
Due to inlining, we can now see unexported functions and variables,
    and functions and variables imported from different packages.
    Ignore them rather than reporting them from this package.
    
    Handle $hash and $equal functions consistently, so that we discard the
    inline body if there is one.
    
    Ignore names created for result parameters for inlining purposes.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/180758

From-SVN: r272023
2019-06-07 00:07:50 +00:00
Ian Lance Taylor 269f05ff58 compiler: make use of specialized fast map routines
In the runtime there are specialized fast map routines for
    certain kep types. This CL lets the compiler make use of these
    functions, instead of always using the generic ones.
    
    As we now generate multiple versions of map delete calls, to make
    things easier we delay the expansion of the built-in delete
    function to flatten phase.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/180858

From-SVN: r271983
2019-06-06 00:44:01 +00:00
Ian Lance Taylor 5a9422664e compiler: inline call expressions and function references
Scan inlinable methods for references to global variables and
    functions (forgot to do that earlier).
    
    Track all packages mentioned by exports (that should have been done
    earlier too).
    
    Record assembler name in export data, so that we can inline calls to
    non-Go functions.  Modify gccgoimporter code to skip assembler name.
    
    This increases the number of inlinable functions in the standard
    library from 215 to 439.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/180677

From-SVN: r271976
2019-06-05 21:05:38 +00:00
Ian Lance Taylor 39c0aa5f74 compiler, runtime, reflect: generate unique type descriptors
Currently, the compiler already generates common symbols for type
    descriptors, so the type descriptors are unique. However, when a
    type is created through reflection, it is not deduplicated with
    compiler-generated types. As a consequence, we cannot assume type
    descriptors are unique, and cannot use pointer equality to
    compare them. Also, when constructing a reflect.Type, it has to
    go through a canonicalization map, which introduces overhead to
    reflect.TypeOf, and lock contentions in concurrent programs.
    
    In order for the reflect package to deduplicate types with
    compiler-created types, we register all the compiler-created type
    descriptors at startup time. The reflect package, when it needs
    to create a type, looks up the registry of compiler-created types
    before creates a new one. There is no lock contention since the
    registry is read-only after initialization.
    
    This lets us get rid of the canonicalization map, and also makes
    it possible to compare type descriptors with pointer equality.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/179598

From-SVN: r271894
2019-06-03 23:37:04 +00:00
Ian Lance Taylor c533ffe04d libgo: delay applying profile stack-frame skip until fixup
When the runtime collects a stack trace to associate it with some
    profiling event (mem alloc, mutex, etc) there is a skip count passed
    to runtime.Callers (or equivalent) to skip some known count of frames
    in order to get to the "interesting" frame corresponding to the
    profile event. Now that the profiling mechanism uses lazy fixup (when
    removing compiler artifacts like thunks, morestack calls etc), we also
    need to move the frame skipping logic after the fixup, so as to insure
    that the skip count isn't thrown off by these artifacts.
    
    Fixes golang/go#32290.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/179740

From-SVN: r271892
2019-06-03 23:07:54 +00:00
Ian Lance Taylor a920eb0cb0 runtime: remove unnecessary functions calling between C and Go
These functions were needed during the transition of the runtime from
    C to Go, but are no longer necessary.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/179879

From-SVN: r271890
2019-06-03 23:02:43 +00:00
Ian Lance Taylor fdb1849a6c runtime: fix assembly syntax
Some assembler doesn't accept ULL suffix. In fact the suffix
    is not really necessary. Drop it.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/180217

From-SVN: r271883
2019-06-03 20:06:50 +00:00
Ian Lance Taylor 2099d44658 runtime: drop unused C type reflection code
In particular, drop __go_type_descriptors_equal, which is no longer
    used, and will be made obsolete by CL 179598.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/179858

From-SVN: r271823
2019-05-31 21:32:47 +00:00
Ian Lance Taylor 6303331c33 compiler: optimize append of make
The gc compiler recognizes append(s, make([]T, n)...), and
    generates code to directly zero the tail instead of allocating a
    new slice and copying. This CL lets the Go frontend do basically
    the same.
    
    The difficulty is that at the point we handle append, there may
    already be temporaries introduced (e.g. in order_evaluations),
    which makes it hard to find the append-of-make pattern. The
    compiler could "see through" the value of a temporary, but it is
    only safe to do if the temporary is not assigned multiple times.
    For this, we add tracking of assignments and uses for temporaries.
    
    This also helps in optimizing non-escape slice make. We already
    optimize non-escape slice make with constant len/cap to stack
    allocation. But it failed to handle things like f(make([]T, n))
    (where the slice doesn't escape and n is constant), because of
    the temporary. With tracking of temporary assignments and uses,
    it can handle this now as well.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/179597

From-SVN: r271822
2019-05-31 21:18:39 +00:00
Ian Lance Taylor 4d12cf3cc3 runtime: implement cheaper context switch on Linux/AMD64
Currently, goroutine switches are implemented with libc
    getcontext/setcontext functions, which saves/restores the machine
    register states and also the signal context. This does more than
    what we need, and performs an expensive syscall.
    
    This CL implements a simplified version of getcontext/setcontext,
    in assembly, that only saves/restores the necessary part, i.e.
    the callee-save registers, and the PC, SP. A simplified version
    of makecontext, written in C, is also added. Currently this is
    only implemented on Linux/AMD64.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/178298

From-SVN: r271818
2019-05-31 17:56:36 +00:00
Ian Lance Taylor 8b9cfd766d re PR go/90635 (typo in libgo/configure.ac)
PR go/90635
    libgo: correct typo in USE_LIBFFI AM_CONDITIONAL
    
    Only affects the case of passing --without-libffi to configure.
    
    Fixes https://gcc.gnu.org/PR90635
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/178998

From-SVN: r271640
2019-05-27 00:14:02 +00:00
Ian Lance Taylor 8b33101442 re PR go/90614 (gcc-9.1.0/libgo/go/syscall/wait.c:54:22: error: unused parameter ‘w’ [-Werror=unused-parameter] Continued (uint32_t *w))
PR go/90614
    syscall: avoid unused parameter error if WIFCONTINUED not defined
    
    Fixes https://gcc.gnu.org/PR90614
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/178997

From-SVN: r271638
2019-05-27 00:10:34 +00:00
Ian Lance Taylor 1ac09ef2c6 libgo: reduce overhead for memory/block/mutex profiling
Revise the gccgo version of memory/block/mutex profiling to reduce
    runtime overhead. The main change is to collect raw stack traces while
    the profile is on line, then post-process the stacks just prior to the
    point where we are ready to use the final product. Memory profiling
    (at a very low sampling rate) is enabled by default, and the overhead
    of the symbolization / DWARF-reading from backtrace_full was slowing
    things down relative to the main Go runtime.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/171497

From-SVN: r271172
2019-05-14 14:59:42 +00:00
Ian Lance Taylor 93ee143d18 libgo: drop Solaris 10 support
Based on patch by Rainer Orth.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/176938

From-SVN: r271135
2019-05-13 20:26:24 +00:00
Ian Lance Taylor c130ab6aad runtime: set up g early
runtime.throw needs a g to work properly. Set up g early, to
    ensure that if something goes wrong in the runtime startup (e.g.
    runtime.check fails), the program terminates in a reasonable way.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/176657

From-SVN: r271088
2019-05-11 01:12:37 +00:00
Ian Lance Taylor 8238b660fb libgo: add Debugging section to README
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/176001

From-SVN: r271019
2019-05-08 22:07:40 +00:00
Cherry Zhang fbe4e644c0 runtime: use builtin memmove directly
We can use the intrinsic memmove directly, without going through
    C.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/170004

	* go-gcc.cc (Gcc_backend::Gcc_backend): Define memmove builtin.

From-SVN: r271016
2019-05-08 17:40:45 +00:00
Ian Lance Taylor b65b77cc80 reflect: correctly handle direct interface typed receiver in Value.call
A direct interface type's value method takes value receiver now.
    Don't pass pointer to the method function.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/175798

From-SVN: r271000
2019-05-08 04:39:19 +00:00
Ian Lance Taylor 08c8a26e9c compiler: recognize and optimize array range clear
Recognize
    
            for i := range a { a[i] = zero }
    
    for array or slice a, and rewrite it to call memclr, as the gc
    compiler does.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/169398

From-SVN: r270862
2019-05-03 21:45:35 +00:00
Ian Lance Taylor 16df703871 os/user: disable TestGroupIds for AIX
The corresponding Go Toolchain patch is CL 164039
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/175079

From-SVN: r270857
2019-05-03 17:15:54 +00:00
Ian Lance Taylor 58dbd45339 compiler: recognize and optimize map range clear
Recognize
    
            for k := range m { delete(m, k) }
    
    for map m, and rewrite it to runtime.mapclear, as the gc compiler
    does.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/169397

From-SVN: r270780
2019-05-01 21:37:00 +00:00
Ian Lance Taylor 5e87c2806f compiler,runtime: do more direct interfaces
A direct interface is an interface whose data word contains the
    actual data value, instead of a pointer to it. The gc toolchain
    creates a direct interface if the value is pointer shaped, that
    includes pointers (including unsafe.Pointer), functions, channels,
    maps, and structs and arrays containing a single pointer-shaped
    field. In gccgo, we only do this for pointers. This CL unifies
    direct interface types with gc. This reduces allocations when
    converting such types to interfaces.
    
    Our method functions used to always take pointer receivers, to
    make interface calls easy. Now for direct interface types, their
    value methods will take value receivers. For a pointer to those
    types, when converted to interface, the interface data contains
    the pointer. For that interface to call a value method, it will
    need a wrapper method that dereference the pointer and invokes
    the value method. The wrapper method, instead of the actual one,
    is put into the itable of the pointer type.
    
    In the runtime, adjust funcPC for the new layout of interfaces of
    functions.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/168409

From-SVN: r270779
2019-05-01 21:34:16 +00:00
Ian Lance Taylor 1da37f43b2 runtime: persistentalloc and cache itabs
Previously, each time we do an interface conversion for which the
    method table is not known at compile time, we allocate a new
    method table.
    
    This CL ports the mechanism of itab caching from the gc runtime,
    adapted to our itab representation and method finding mechanism.
    With the cache, we reuse the same itab for the same (interface,
    concrete) type pair. This reduces allocations in interface
    conversions.
    
    Unlike the gc runtime, we don't prepopulate the cache with
    statically allocated itabs, as currently we don't have a way to
    find them. This means we don't deduplicate run-time allocated
    itabs with compile-time allocated ones. But that is not too bad
    -- it is just a cache anyway.
    
    As now itabs are never freed, it is also possible to drop the
    write barrier for writing the first word of an interface header.
    I'll leave this optimization for the future.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/171617

From-SVN: r270778
2019-05-01 20:27:36 +00:00
Ian Lance Taylor 8d266165b9 runtime: fix TestPhysPageSize on AIX
AIX doesn't allow to mmap an address range which is already mmap.
    Therefore, once the region has been allocated, it must munmap before
    being able to play with it.
    The corresponding Go Toolchain patch is CL 174059.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/174138

From-SVN: r270615
2019-04-26 17:20:55 +00:00
Ian Lance Taylor 972206e0c2 re PR target/89093 (C++ exception handling clobbers d8 VFP register)
PR target/89093
    runtime: mark unwind functions general-regs-only on ARM
    
    For https://gcc.gnu.org/PR89093.
    
    Change-Id: Ic426b43d633c77104bda01d4e7835bc9ab4695ef
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/173657
    Reviewed-by: Ian Lance Taylor <iant@golang.org>

From-SVN: r270542
2019-04-24 12:45:45 +00:00
Ian Lance Taylor f4488799b2 libgo/go/syscall: add SockAddrDatalink on AIX
This patch is required in order to build golang.org/x/net. The
    corresponding Go Toolchain patch is CL 170537.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/172898

From-SVN: r270458
2019-04-19 14:20:16 +00:00
Ian Lance Taylor 04862afe9f libgo: update to Go 1.12.2
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/170706

From-SVN: r270214
2019-04-08 18:36:25 +00:00
Ian Lance Taylor ea5ac5a69b compiler,runtime: pass old slice's ptr/len/cap by value to growslice
In the C calling convention, on AMD64, and probably a number of
    other architectures, a 3-word struct argument is passed on stack.
    This is less efficient than passing in three registers. Further,
    this may affect the code generation in other part of the program,
    even if the function is not actually called.
    
    Slices are common in Go and append is a common slice operation,
    which calls growslice in the growing path. To improve the code
    generation, pass the slice header's three fields as separate
    values, instead of a struct, to growslice.
    
    The drawback is that this makes the runtime implementation
    slightly diverges from the gc runtime.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/168277

From-SVN: r269811
2019-03-19 18:42:43 +00:00
Ian Lance Taylor 9195aa172b libgo: fix build on AIX
Since aix/ppc64 has been added to GC toolchain, a mix between new and
    old files were created in gcc toolchain.
    This commit corrects this merge for aix/ppc64 and aix/ppc.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/167658

From-SVN: r269797
2019-03-19 14:00:59 +00:00
Ian Lance Taylor a8b58d84bf libgo: update to Go 1.12.1
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/167749

From-SVN: r269780
2019-03-18 20:27:59 +00:00
Ian Lance Taylor ee973155b2 re PR go/89447 (libgo largefile support is incomplete and inconsistent)
PR go/89447
    syscall, internal/syscall: adjust use of largefile functions
    
    Consistently call __go_openat for openat.  Use fstatat64, creat64,
    sendfile64, and getdents64 where needed.
    
    Based on patch by Rainer Orth.
    
    Fixes https://gcc.gnu.org/PR89447
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/166420

From-SVN: r269521
2019-03-09 02:10:22 +00:00
Ian Lance Taylor 0e1a6d2700 mksysinfo: actually use modified Statfs_t value
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/165737

From-SVN: r269424
2019-03-06 14:19:56 +00:00
Ian Lance Taylor 03ac8302a6 runtime: enable precise GC checks when using stack maps
In the runtime there are bad pointer checks that currently don't
    work with the concervative collector. With stack maps, the GC is
    precise and the checks should work. Enable them.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/153871

From-SVN: r269406
2019-03-05 23:05:38 +00:00
Ian Lance Taylor b211cd1b46 cmd/go: pass -X64 to ar on aix/ppc64
On aix/ppc64, ar tool must always have -X64 argument if it aims to
    create 64 bits archives.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/165317

From-SVN: r269404
2019-03-05 22:40:21 +00:00
Ian Lance Taylor 9bf54c938a sysinfo: add Flags to Statfs_t if not already there
If there is no f_flags field in statfs_t then rename one of the
    f_spare fields, as happened in Linux kernel version 2.6.36.  This
    fixes the build on CentOS 5.11.  The CentOS kernel will hopefully not
    fill in the f_spare field, so the resulting flags will be zero.
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/165417

From-SVN: r269401
2019-03-05 20:49:21 +00:00
Ian Lance Taylor 64ef1e96ff re PR go/89406 (Go testing leaves many temporary directories in /tmp around)
PR go/89406
    go/internal/gccgoimporter: remove temporary directories in test
    
    Backport of https://golang.org/cl/164862.
    
    Updates https://gcc.gnu.org/PR89406
    
    Reviewed-on: https://go-review.googlesource.com/c/164863

From-SVN: r269338
2019-03-02 00:50:30 +00:00
Ian Lance Taylor 8ea1c33cb3 cmd/go: restore passing D to ar
This restores part of https://golang.org/cl/45695 that was
    accidentally lost in https://golang.org/cl/158019 (the update to
    Go1.12beta2).
    
    Reviewed-on: https://go-review.googlesource.com/c/164737

From-SVN: r269333
2019-03-01 22:22:18 +00:00
Ian Lance Taylor 337f1caed6 runtime: call execname and getpagesize on Solaris
Interpreting auxv as []uintptr is incorrect on 64-bit big-endian,
    as auxv alternates a 32-bit int with a 64-bit pointer.
    
    Patch from Rainer Orth.
    
    Reviewed-on: https://go-review.googlesource.com/c/164739

From-SVN: r269315
2019-03-01 14:21:24 +00:00
Ian Lance Taylor 3eba09884e cmd/go: add -O2 to invocation of gccgo
When using the go tool with gccgo, this changes the default
    compilation to use -O2.  The -gccgoflags option can be used to
    override this default.  I think this change better corresponds to what
    people expect when using the go tool.
    
    Reviewed-on: https://go-review.googlesource.com/c/164378

From-SVN: r269299
2019-03-01 01:23:09 +00:00
Ian Lance Taylor 5b2eaa1170 commit 66ac9466852d11e968f8fd2ad6ffc7386cee49e1
gotest: avoid using echo inside $()
    
    The handling of newlines is not portable between bash and ksh.
    
    Reviewed-on: https://go-review.googlesource.com/c/164597

From-SVN: r269298
2019-03-01 01:03:54 +00:00
Ian Lance Taylor b0cf10e423 libgo: fix go_export extraction on Darwin
On Darwin, the section name is prefixed with the segment name, __GNU_GO.
    
    Reviewed-on: https://go-review.googlesource.com/c/151097

From-SVN: r269271
2019-02-28 01:01:46 +00:00
Ian Lance Taylor cba8a572c2 re PR go/89172 (FAIL: runtime/pprof)
PR go/89172
    internal/cpu, runtime, runtime/pprof: handle function descriptors
    
    When using PPC64 ELF ABI v1 a function address is not a PC, but is the
    address of a function descriptor.  The first field in the function
    descriptor is the actual PC (see
    http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#FUNC-DES).
    The libbacktrace library knows about this, and libgo uses actual PC
    values consistently except for the helper function funcPC that appears
    in both runtime and runtime/pprof.
    
    This patch fixes funcPC by recording, in the internal/cpu package,
    whether function descriptors are being used.  We have to check for
    function descriptors using a C compiler check, because GCC can be
    configured using --with-abi to select the ELF ABI to use.
    
    Fixes https://gcc.gnu.org/PR89172
    
    Reviewed-on: https://go-review.googlesource.com/c/162978

From-SVN: r269266
2019-02-27 22:35:10 +00:00
Ian Lance Taylor b91dfdcc68 runtime: align first persistentalloc chunk as requested
Backport of upstream https://golang.org/cl/163859.
    
    This fixes various failures on 32-bit SPARC.
    
    Patch from Eric Boctazou.
    
    Reviewed-on: https://go-review.googlesource.com/c/163860

From-SVN: r269258
2019-02-27 15:51:49 +00:00
Ian Lance Taylor 15994bfbca cmd/go: preserve CC for TestScript child processes
Reviewed-on: https://go-review.googlesource.com/c/158838

From-SVN: r269240
2019-02-27 01:11:20 +00:00
Ian Lance Taylor 4fd3c8aad9 libgo: update to Go 1.12 release
Reviewed-on: https://go-review.googlesource.com/c/163742

From-SVN: r269216
2019-02-26 15:38:12 +00:00
Ian Lance Taylor 5c98b419f7 re PR go/86535 (FreeBSD/PowerPC64 - Building Go Frontend support for gcc 7.3.0 fails)
PR go/86535
    runtime: always declare nanotime in Go
    
    For libgo it's always defined in C.
    
    Updates https://gcc.gnu.org/PR86535
    
    Reviewed-on: https://go-review.googlesource.com/c/163743

From-SVN: r269214
2019-02-26 14:46:56 +00:00
Ian Lance Taylor 99e20ba51d libgo: update to Go1.12rc1
Reviewed-on: https://go-review.googlesource.com/c/162881

From-SVN: r269202
2019-02-26 01:00:39 +00:00
Ian Lance Taylor f08e60e988 re PR go/89406 (Go testing leaves many temporary directories in /tmp around)
PR go/89406
    net: remove unixgram test sockets
    
    Backport https://golang.org/cl/163277 from the master library.
    
    Updates https://gcc.gnu.org/PR89406
    
    Reviewed-on: https://go-review.googlesource.com/c/163200

From-SVN: r269087
2019-02-22 00:47:30 +00:00
Ian Lance Taylor 8aef6e02ad cmd/go: remove work directory on usage error
Backport https://golang.org/cl/163237 from the master library:
    
        Ensure that cmd/go consistently calls base.Exit rather than os.Exit,
        so that we don't incorrectly leave the work directory around on exit.
    
        Test this by modifying the testsuite to run all the tests with TMPDIR
        set to a temporary directory, and then check that no files are left
        behind in that temporary directory. Adjust a couple of tests to make
        this approach work.
    
    Updates https://gcc.gnu.org/PR89406
    
    Reviewed-on: https://go-review.googlesource.com/c/163198

From-SVN: r269086
2019-02-22 00:41:25 +00:00
Ian Lance Taylor 556bef7efc re PR go/89407 (go bootstrap failure on s390x starting with r268941)
PR go/89407
    internal/cpu: use #ifdef __s390x__ in C code
    
    Patch by Jakub Jelinek.
    
    Fixes https://gcc.gnu.org/PR89407
    
    Reviewed-on: https://go-review.googlesource.com/c/163297

From-SVN: r269063
2019-02-21 01:06:01 +00:00
Ian Lance Taylor b05b2dba3d re PR go/89169 (FAIL: internal/cpu)
PR go/89169
    internal/cpu: do not require POWER8
    
    Although the gc toolchain requires POWER8, the gccgo toolchain does not.
    
    Fixes https://gcc.gnu.org/PR89169
    
    Reviewed-on: https://go-review.googlesource.com/c/162979

From-SVN: r269019
2019-02-19 15:42:09 +00:00
Ian Lance Taylor 6bd37418a3 runtime: abort stack scan in cases that we cannot unwind the stack
In signal-triggered stack scan, if the signal is delivered at
    certain bad time (e.g. in vdso, or in the middle of setcontext?),
    the unwinder may not be able to unwind the whole stack, while it
    still reports _URC_END_OF_STACK. So we cannot rely on _URC_END_OF_STACK
    to tell if it successfully scanned the stack. Instead, we check
    the last Go frame to see it actually reached the end of the stack.
    For Go-created stack, this is runtime.kickoff. For C-created
    stack, we need to record the outermost Go frame when it enters
    the Go side.
    
    Also we cannot unwind the stack if the signal is delivered in the
    middle of runtime.gogo, halfway through a goroutine switch, where
    the g and the stack don't match. Give up in this case as well.
    
    Reviewed-on: https://go-review.googlesource.com/c/159098

From-SVN: r269018
2019-02-19 15:32:34 +00:00
Cherry Zhang fba70f605e compiler,runtime: use __builtin_dwarf_cfa for getcallersp
Currently, the compiler lowers runtime.getcallersp to
    __builtin_frame_address(1). In the C side of the runtime,
    getcallersp is defined as __builtin_frame_address(0). They don't
    match. Further, neither of them actually returns the caller's SP.
    On AMD64, __builtin_frame_address(0) just returns the frame
    pointer. __builtin_frame_address(1) returns the memory content
    where the frame pointer points to, which is typically the
    caller's frame pointer but can also be garbage if the frame
    pointer is not enabled.
    
    This CL changes it to use __builtin_dwarf_cfa(), which returns
    the caller's SP at the call site. This matches the SP we get
    from unwinding the stack.
    
    Currently getcallersp is not used for anything real. It will be
    used for precise stack scan (a new version of CL 159098).
    
    Reviewed-on: https://go-review.googlesource.com/c/162905

	* go-gcc.cc (Gcc_backend::Gcc_backend): Define __builtin_dwarf_cfa
	instead of __builtin_frame_address.

From-SVN: r268952
2019-02-15 23:22:29 +00:00
Ian Lance Taylor a72128258b re PR go/89123 (Too many go test failures on s390x-linux)
PR go/89123
    internal/cpu, runtime: add S/390 CPU capability support
    
    Patch by Robin Dapp.
    
    Updates https://gcc.gnu.org/PR89123
    
    Reviewed-on: https://go-review.googlesource.com/c/162887

From-SVN: r268941
2019-02-15 14:51:10 +00:00
Ian Lance Taylor 7b54753033 runtime: include <syscall.h> and <sys/syscall.h> if available
Fixes Solaris build.
    
    Reviewed-on: https://go-review.googlesource.com/c/162885

From-SVN: r268940
2019-02-15 14:25:12 +00:00
Ian Lance Taylor d86dd2490f runtime: add type cast for non-split-stack calls to scanstackblock
Reviewed-on: https://go-review.googlesource.com/c/162884

From-SVN: r268939
2019-02-15 13:54:45 +00:00
Ian Lance Taylor 8a9f2a6bbd compiler, runtime: harmonize types referenced by both C and Go
Compiling with LTO revealed a number of cases in the runtime and
    standard library where C and Go disagreed about the type of an object or
    function (or where Go and code generated by the compiler disagreed). In
    all cases the underlying representation was the same (e.g., uintptr vs.
    void*), so this wasn't causing actual problems, but it did result in a
    number of annoying warnings when compiling with LTO.
    
    Reviewed-on: https://go-review.googlesource.com/c/160700

From-SVN: r268923
2019-02-15 01:57:51 +00:00
Ian Lance Taylor c8530c4109 re PR go/89168 (FAIL: cmd/go/internal/load)
PR go/89168
    libgo: change gotest to run examples with output
    
    Change the gotest script to act like "go test" and run examples that
    have "output" comments.  This is not done with full generality, but
    just enough to run the libgo tests.  Other packages should be tested
    with "go test" as usual.
    
    While we're here clean up some old bits of gotest, and only run
    TestXXX functions that are actually in *_test.go files.  The latter
    change should fix https://gcc.gnu.org/PR89168.
    
    Reviewed-on: https://go-review.googlesource.com/c/162139

From-SVN: r268922
2019-02-15 00:36:50 +00:00
Ian Lance Taylor 2faf2a305d syscall: don't assume that WIFCONTINUED is defined
It's not defined on the Hurd.
    
    Reviewed-on: https://go-review.googlesource.com/c/161963

From-SVN: r268828
2019-02-12 21:29:52 +00:00
Ian Lance Taylor 42ee82045d mksysinfo: remove incorrect quotes in st_fsid handling for Hurd
Also stop converting st_dev on Hurd; it shouldn't appear, but if it
    somehow does we don't want to convert it.
    
    Reviewed-on: https://go-review.googlesource.com/c/161961

From-SVN: r268785
2019-02-12 00:15:34 +00:00
Ian Lance Taylor 18591d3ee7 os, syscall: Hurd fixes for a couple of tests
Based on patch by Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/161520

From-SVN: r268605
2019-02-07 05:02:26 +00:00