Commit Graph

1122 Commits

Author SHA1 Message Date
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
Ian Lance Taylor 4a3e25712f os, net, crypto/x509: add hurd support
Patch by Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/161519

From-SVN: r268604
2019-02-07 04:45:01 +00:00
Ian Lance Taylor 4321f202f9 syscall: add Hurd support
Loosely based on a patch by Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/161518

From-SVN: r268603
2019-02-07 03:11:47 +00:00
Ian Lance Taylor 9fa4b2aa45 internal/syscall/unix: add constants for hurd
Patch by Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/161517

From-SVN: r268602
2019-02-07 02:22:57 +00:00
Ian Lance Taylor 73fe55d752 re PR go/89199 (libgo regression in implementation of CompareAndSwap functions resulting in intermittent testcase failures on ppc64le power9 after r268458)
PR go/89199
    sync/atomic: use strong form of atomic_compare_exchange_n
    
    In the recent change to use atomic_compare_exchange_n I thought we
    could use the weak form, which can spuriously fail. But that is not
    how it is implemented in the gc library, and it is not what the rest
    of the library expects.
    
    Thanks to Lynn Boger for identifying the problem.
    
    Fixes https://gcc.gnu.org/PR89199
    
    Reviewed-on: https://go-review.googlesource.com/c/161359

From-SVN: r268591
2019-02-06 20:46:00 +00:00
Ian Lance Taylor fc34dbfdb0 runtime: add hurd netpoll and semaphore support
Patch by Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/160827

From-SVN: r268465
2019-02-01 23:57:08 +00:00
Ian Lance Taylor cf5773c116 runtime: add getproccount for hurd
Patch by Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/160825

From-SVN: r268463
2019-02-01 22:55:55 +00:00
Ian Lance Taylor d9f0237f70 libgo: add configury and sysinfo support for hurd
Patch by Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/160824

From-SVN: r268461
2019-02-01 22:46:39 +00:00
Ian Lance Taylor 59ea40d0f2 libgo: add hurd build tags to test files
Patch by Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/160823

From-SVN: r268460
2019-02-01 22:11:50 +00:00
Ian Lance Taylor 27d6b51071 libgo: add hurd build tags
Patch by Svante Signell.
    
    Reviewed-on: https://go-review.googlesource.com/c/160822

From-SVN: r268459
2019-02-01 21:57:36 +00:00
Ian Lance Taylor b52a3881f0 runtime, sync: use __atomic intrinsics instead of __sync
GCC has supported the __atomic intrinsics since 4.7.  They are better
    than the __sync intrinsics in that they specify a memory model and,
    more importantly for our purposes, they are reliably implemented
    either in the compiler or in libatomic.
    
    Fixes https://gcc.gnu.org/PR52084
    
    Reviewed-on: https://go-review.googlesource.com/c/160820

From-SVN: r268458
2019-02-01 21:55:38 +00:00
Ian Lance Taylor 6065f1c588 runtime: fix sigprof frame counting
If sigtramp and sigtrampgo are both on stack, n -= framesToDiscard
    is executed twice, which should actually run only once.
    
    Reviewed-on: https://go-review.googlesource.com/c/159238

From-SVN: r268366
2019-01-29 15:31:10 +00:00
Ian Lance Taylor 053a1f2320 runtime: use the call instruction's PC for panic-in-runtime detection
If a panic happens in the runtime we turn that into a fatal error.
    We use the caller's PC to determine if the panic call is inside
    the runtime. getcallerpc returns the PC immediately after the
    call instruction. If the call is the very last instruction of a
    function, it may not find this PC belong to a runtime function,
    giving false result. We need to back off the PC by 1 to the call
    instruction.
    
    The gc runtime doesn't do this because the gc compiler always
    emit an instruction following a panic call, presumably an UNDEF
    instruction which turns into an architecture-specific illegal
    instruction. Our compiler doesn't do this.
    
    Reviewed-on: https://go-review.googlesource.com/c/159437

From-SVN: r268358
2019-01-29 00:49:23 +00:00
Ian Lance Taylor 52c9cfeb08 runtime: install SIGURG handler on C created threads
Precise stack scan uses SIGURG to trigger a stack scan. We need
    to have Go signal handler installed for SIGURG.
    
    Reviewed-on: https://go-review.googlesource.com/c/159097

From-SVN: r268230
2019-01-24 05:31:14 +00:00
Ian Lance Taylor 494df8753b golang.org/x/tools/go/analysis: pass "gccgo" to types.SizesFor
For the gofrontend copy, change calls to types.SizesFor to pass
    "gccgo" rather than "gc".  Leave the asmdecl pass unchanged since that
    pass is gc-specific anyhow.
    
    This has been fixed in a better way in the external repo by
    https://golang.org/cl/158317 and friends, but that is not in 1.12, so
    use this approach for now.
    
    Reviewed-on: https://go-review.googlesource.com/c/158842

From-SVN: r268153
2019-01-22 15:43:40 +00:00
Ian Lance Taylor 3d338229dc re PR go/88927 (Bootstrap failure on arm in libgo starting with r268084)
PR go/88927
    runtime, internal/cpu: fix build for ARM GNU/Linux
    
    Was failing with
    
    ../../../libgo/go/internal/cpu/cpu.go:138:2: error: reference to undefined name 'doinit'
      138 |  doinit()
          |  ^
    
    Fix it by adding in Go 1.12 internal/cpu/cpu_arm.go, and the code in
    runtime that initializes the values.
    
    Fixes https://gcc.gnu.org/PR88927.
    
    Reviewed-on: https://go-review.googlesource.com/c/158717

From-SVN: r268131
2019-01-22 00:06:44 +00:00
Ian Lance Taylor ea31c98dab libgo: fix building, and some testing, on Solaris
Restore some of the fixes that were applied to golang_org/x/net/lif
    but were lost when 1.12 moved the directory to internal/x/net/lif.
    
    Add support for reading /proc to fetch argc/argv/env for c-archive mode.
    
    Reviewed-on: https://go-review.googlesource.com/c/158640

From-SVN: r268130
2019-01-21 23:05:52 +00:00