Commit Graph

1084 Commits

Author SHA1 Message Date
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
Ian Lance Taylor 4f4a855d82 libgo: update to Go1.12beta2
Reviewed-on: https://go-review.googlesource.com/c/158019

gotools/:
	* Makefile.am (go_cmd_vet_files): Update for Go1.12beta2 release.
	(GOTOOLS_TEST_TIMEOUT): Increase to 600.
	(check-runtime): Export LD_LIBRARY_PATH before computing GOARCH
	and GOOS.
	(check-vet): Copy golang.org/x/tools into check-vet-dir.
	* Makefile.in: Regenerate.

gcc/testsuite/:
	* go.go-torture/execute/names-1.go: Stop using debug/xcoff, which
	is no longer externally visible.

From-SVN: r268084
2019-01-18 19:04:36 +00:00
Ian Lance Taylor aee6ed4a2c re PR go/88202 (FAIL: runtime/pprof)
PR go/88202
    runtime: in sigprof, skip to sigtrampgo if we don't find sigtramp
    
    Fixes https://gcc.gnu.org/PR88202
    
    Reviewed-on: https://go-review.googlesource.com/c/158218

From-SVN: r268057
2019-01-18 03:29:38 +00:00
Ian Lance Taylor f41bf58736 runtime: dropg before CAS g status to _Grunnable/_Gwaiting
Currently, we dropg (which clears gp.m) after we CAS the g status
    to _Grunnable or _Gwaiting. Immediately after CASing the g status,
    another thread may CAS it to _Gscan status and scan its stack.
    With precise stack scan, it accesses gp.m in order to switch to g
    and back (in doscanstackswitch). This races with dropg. If
    doscanstackswitch reads gp.m, then dropg runs, when we restore
    the m at the end of the scan it will set to a stale value. Worse,
    if dropg runs after doscanstackswitch sets the new m, gp will be
    running with a nil m.
    
    To fix this, we do dropg before CAS g status to _Grunnable or
    _Gwaiting. We can do this safely if we are CASing from _Grunning,
    as we own the g when it is in _Grunning. There is one case where
    we CAS from _Gsyscall to _Grunnable. It is not safe to dropg when
    it is in _Gsyscall, as precise stack scan needs to read gp.m in
    order to signal the m. So we need to introduce a transient state,
    _Gexitingsyscall, between _Gsyscall and _Grunnable, where the GC
    should not scan its stack.
    
    In is a little unfortunate that we have to add another g status.
    We could reuse an existing one (e.g. _Gcopystack), but it is
    clearer and safer to just use a new one, as Austin suggested.
    
    Reviewed-on: https://go-review.googlesource.com/c/158157

From-SVN: r268001
2019-01-17 02:14:28 +00:00
Ian Lance Taylor a6804ea929 syscall: mark C syscall functions noescape
Many C syscall functions take pointer arguments. The pointers
    don't escape in the C functions. Mark the C functions noescape so
    calling them doesn't need allocation.
    
    Reviewed-on: https://go-review.googlesource.com/c/158158

From-SVN: r267989
2019-01-16 22:38:33 +00:00
Ian Lance Taylor b7ec44e82b runtime: add padding to FFI type of struct ending with zero-sized field
CL 157557 changes the compiler to add one byte padding to
    non-empty struct ending with a zero-sized field. Add the same
    padding to the FFI type, so reflect.Call works.
    
    This fixes test/fixedbugs/issue26335.go in the main repo.
    
    Reviewed-on: https://go-review.googlesource.com/c/158018

From-SVN: r267956
2019-01-15 23:21:24 +00:00
Ian Lance Taylor 6a0c8e77f2 compiler, runtime: panic on uncomparable map key, even if map is empty
This ports https://golang.org/cl/155918 from the master repo.
    
        runtime: panic on uncomparable map key, even if map is empty
    
        Reorg map flags a bit so we don't need any extra space for the extra flag.
    
    This is a pre-req for updating libgo to the Go 1.12beta2 release.
    
    Reviewed-on: https://go-review.googlesource.com/c/157858

From-SVN: r267950
2019-01-15 20:32:39 +00:00
Jakub Jelinek 831a2e2f86 Remove svn:executable property from a couple of text files
which shouldn't be executable.

From-SVN: r267873
2019-01-12 01:20:04 +01:00
Ian Lance Taylor 33a5d8ccb5 runtime: in doscanstackswitch, set gp->m before gogo
This is following CL 156038. doscanstackswitch uses the same
    mechanism of switching goroutines as getTraceback, and so has
    the same problem as described in issue golang/go#29448. This CL
    applies the same fix.
    
    Reviewed-on: https://go-review.googlesource.com/c/156697

From-SVN: r267661
2019-01-07 22:07:26 +00:00
Ian Lance Taylor fdcef314bc compiler: move slice construction to callers of makeslice
This is the gccgo version of https://golang.org/cl/141822:
    
        Only return a pointer p to the new slices backing array from makeslice.
        Makeslice callers then construct sliceheader{p, len, cap} explictly
        instead of makeslice returning the slice.
    
    This change caused the GCC backend to break the runtime/pprof test by
    merging together the identical functions allocateReflectTransient and
    allocateTransient2M.  This caused the traceback to be other than
    expected.  Fix that by making the functions not identical.
    
    This is a step toward updating libgo to the Go1.12beta1 release.
    
    Reviewed-on: https://go-review.googlesource.com/c/155937

From-SVN: r267660
2019-01-07 21:44:06 +00:00
Ian Lance Taylor 575eb8f58b runtime: in getTraceback, set gp->m before gogo
Currently, when collecting a traceback for another goroutine,
    getTraceback calls gogo(gp) switching to gp, which will resume in
    mcall, which will call gtraceback, which will set up gp->m. There
    is a gap between setting the current running g to gp and setting
    gp->m. If a profiling signal arrives in between, sigtramp will
    see a non-nil gp with a nil m, and will seg fault. Fix this by
    setting up gp->m first.
    
    Fixes golang/go#29448.
    
    Reviewed-on: https://go-review.googlesource.com/c/156038

From-SVN: r267658
2019-01-07 20:12:39 +00:00
Ian Lance Taylor f6be1179bb runtime: prevent deadlock when profiling signal arrives during traceback
Traceback routines, e.g. callers and funcentry, may call
    __go_get_backtrace_state. If a profiling signal arrives while we
    are in the critical section of __go_get_backtrace_state, it tries
    to do a traceback, which also calls __go_get_backtrace_state,
    which tries to enter the same critical section and will deadlock.
    Prevent this deadlock by setting up runtime_in_callers before
    calling __go_get_backtrace_state.
    
    Found while investigating golang/go#29448. Will add a test in the
    next CL.
    
    Updates golang/go#29448.
    
    Reviewed-on: https://go-review.googlesource.com/c/156037

From-SVN: r267590
2019-01-05 00:40:04 +00:00
Ian Lance Taylor e20bfbd18e runtime: prevent deadlock when profiling signal arrives in stack scan
Precise stack scan needs to unwind the stack. When it is
    unwinding the stack, if a profiling signal arrives, which also
    does a traceback, it may deadlock in dl_iterate_phdr. Prevent
    this deadlock by setting up runtime_in_callers before traceback.
    
    Reviewed-on: https://go-review.googlesource.com/c/155766

From-SVN: r267457
2018-12-29 00:07:06 +00:00
Ian Lance Taylor dc65168eb6 runtime: delete export_arm_test.go
The only thing export_arm_test.go does is to export usplit,
    which does not exist in gccgo.
    
    Reviewed-on: https://go-review.googlesource.com/c/155760

From-SVN: r267435
2018-12-27 16:34:50 +00:00
Ian Lance Taylor f1410e7e2e runtime: let ARM32 EABI personality function continue unwind when called from traceback
On ARM32 EABI, unlike other platforms, the personality function is
    called during _Unwind_Backtrace (libgcc/unwind-arm-common.inc:581).
    In this case, simply unwind the frame without returning any
    handlers. Otherwise traceback will loop if there is a frame with
    a defer on stack.
    
    Reviewed-on: https://go-review.googlesource.com/c/155759

From-SVN: r267434
2018-12-27 16:31:50 +00:00
Ian Lance Taylor 75e479a8b5 runtime: on ARM32 EABI, don't get LSDA if compact model is used
On ARM32 EABI, when the "compact" unwinding model is used, it
    does not have standard LSDA and _Unwind_GetLanguageSpecificData
    will not return data that is parseable by us. Check this
    conditon before calling _Unwind_GetLanguageSpecificData.
    
    Fix ARM32 build.
    
    Reviewed-on: https://go-review.googlesource.com/c/155758

From-SVN: r267428
2018-12-27 03:13:11 +00:00
Ian Lance Taylor e7db55f636 runtime: handle DW_EH_PE_absptr in type table encoding
The type table encoding can be DW_EH_PE_absptr, but this case
    was missing, which was causing abort on ARM32 EABI. Add the
    missing case.
    
    Reviewed-on: https://go-review.googlesource.com/c/153857

From-SVN: r267070
2018-12-12 23:26:58 +00:00
Ian Lance Taylor 44cacba39d os/signal: increase deliver time for signal testcase
This increases the time to wait for signals to be delivered in the
    TestAtomicStop testcase. When running gccgo tests on ppc64 or ppc64le,
    there are intermittent failures in this test because the wait time is
    too small.
    
    Updates golang/go#29046
    
    Reviewed-on: https://go-review.googlesource.com/c/153879

From-SVN: r267068
2018-12-12 22:48:46 +00:00
Ian Lance Taylor be68937be2 runtime: use _URC_FAILURE on ARM32
ARM32 EABI unwinder does not define _URC_NORMAL_STOP. Instead,
    it has _URC_FAILURE. Use _URC_FAILURE there.
    
    Should fix ARM32 build.
    
    Reviewed-on: https://go-review.googlesource.com/c/153417

From-SVN: r267033
2018-12-11 20:50:59 +00:00
Ian Lance Taylor 5a58929be8 runtime: add missing return for non-GNU/Linux version of tgkill
Path from Rainer Orth.
    
    Reviewed-on: https://go-review.googlesource.com/c/153118

From-SVN: r266890
2018-12-07 14:22:55 +00:00
Ian Lance Taylor c43137e800 runtime: add precise stack scan support
This CL adds support of precise stack scan using stack maps to
    the runtime. The stack maps are generated by the compiler (if
    supported). Each safepoint is associated with a (real or dummy)
    landing pad, and its "type info" in the exception table is a
    pointer to the stack map. When a stack is scanned, the stack map
    is found by the stack unwinding code by inspecting the exception
    table (LSDA).
    
    For precise stack scan we need to unwind the stack. There are
    three cases:
    
    - If a goroutine is scanning its own stack, it can unwind the
      stack and scan the frames.
    
    - If a goroutine is scanning another, stopped, goroutine, it
      cannot directly unwind the target stack. We handle this by
      switching (runtime.gogo) to the target g, letting it unwind
      and scan the stack, and switch back.
    
    - If we are scanning a goroutine that is blocked in a syscall,
      we send a signal to the target goroutine's thread, and let the
      signal handler unwind and scan the stack. Extra care is needed
      as this races with enter/exit syscall.
    
    Currently this is only implemented on linux.
    
    Reviewed-on: https://go-review.googlesource.com/c/140518

From-SVN: r266832
2018-12-05 23:09:51 +00:00
Ian Lance Taylor 9cf3cb7c25 syscall: remove Flock for aix/ppc64
CL 152397 removed it from gc's syscall package.
    
    Updates golang/go#29084
    
    Reviewed-on: https://go-review.googlesource.com/c/152557

From-SVN: r266812
2018-12-05 01:11:02 +00:00
Ian Lance Taylor 8f80bd8972 cmd/vet: use default compiler when determining type sizes
Fixes a segfault running vet on alpha.
    
    Patch by Uros Bizjak.
    
    Reviewed-on: https://go-review.googlesource.com/c/152437

From-SVN: r266781
2018-12-04 14:29:11 +00:00
Ian Lance Taylor ab25c42d05 cmd/go: allow buildmode c-archive for gccgo on ppc64
In buildmodeinit, the c-archive buildmode is flagged as invalid
    on linux/ppc64 for gccgo when it should be valid. This happens
    because the check against the gccgo flag is done after the checks
    for valid GOOS/GOARCH pairs instead of before as is done for all
    other buildmode cases in this switch. This corrects the problem and
    allows several of the gccgo gotools testcases to pass on linux/ppc64.
    
    Updates #29046
    
    Reviewed-on: https://go-review.googlesource.com/c/152137

From-SVN: r266764
2018-12-03 20:25:11 +00:00
Ian Lance Taylor 80d7d30d24 compiler: add '$' to names in expression export data
For inlined function bodies we're going to need to refer to variables,
    so change the existing export data to add a '$' to names that look
    like identifiers: true, false, nil, convert.
    
    While we're here drop an unnecessary space character after operators.
    
    Reviewed-on: https://go-review.googlesource.com/c/150067

From-SVN: r266529
2018-11-27 21:25:58 +00:00
Ian Lance Taylor 0abbc8f15e syscall: always define WEXITED and WNOWAIT on GNU/Linux
Fixes https://gcc.gnu.org/PR88135
    
    Reviewed-on: https://go-review.googlesource.com/c/150897

From-SVN: r266495
2018-11-26 23:58:34 +00:00
Ian Lance Taylor 1e4cc1d4b0 compiler: initial support for exporting function bodies
Create a framework for putting function bodies in export data.  At
    present only empty functions will be put there, and they will be
    ignored on import.  Later patches will get this to the point of
    supporting inlining of (some) functions defined in other packages.
    
    Reviewed-on: https://go-review.googlesource.com/c/150061

From-SVN: r266490
2018-11-26 21:44:20 +00:00
Ian Lance Taylor d3d684c642 re PR go/88060 (../../../gcc-8.2.0/libgo/go/syscall/libcall_linux_utimesnano.go:17:18: error: reference to undefined name ‘_AT_FDCWD’)
PR go/88060
    syscall: always define _AT_FDCWD and IPv6MTUInfo
    
    They aren't defined by old versions of glibc, but are required by the
    code in syscall_linux.go.
    
    Reviewed-on: https://go-review.googlesource.com/c/150697

From-SVN: r266333
2018-11-21 02:16:15 +00:00
Ian Lance Taylor 0d26cdf1cf cmd/cgo: fix typo in gccgo name mangling recipe
The code to implement new-style gccgo name mangling had a recipe that
    didn't quite match the one in the compiler (incorrect handling for
    '.'). This showed up as a failure in the gotools cgo test if the
    directory containing the test run included a "." character.
    
    Reviewed-on: https://go-review.googlesource.com/c/147917

From-SVN: r265981
2018-11-09 19:03:59 +00:00
Ian Lance Taylor 71caffb725 syscall: change RLIM_INFINITY from 0xffffffffffffffff to -1
For compatibility with the gc toolchain's syscall package.
    
    Fixes golang/go#28665
    
    Reviewed-on: https://go-review.googlesource.com/c/148697

From-SVN: r265974
2018-11-09 15:30:51 +00:00
Ian Lance Taylor 73b6d7a990 re PR bootstrap/82856 (--enable-maintainter-mode broken by incompatiblity of gcc's required automake and modern Perl)
PR bootstrap/82856

    libgo: update to autoconf 2.69 and automake 1.15.1
    
    Initial patch from Joseph Myers.
    
    Reviewed-on: https://go-review.googlesource.com/c/146417

From-SVN: r265701
2018-10-31 20:46:17 +00:00
Ian Lance Taylor 827651b074 libgo: simplify gotest script to avoid sed substitution to \n
Reviewed-on: https://go-review.googlesource.com/c/145057

From-SVN: r265541
2018-10-26 18:36:44 +00:00
Ian Lance Taylor dbd93b9dbb libgo: avoid use of 'local' directive in shell script
Avoid declaring shell variables with 'local' (not supported
    on all systems of interest).
    
    Reviewed-on: https://go-review.googlesource.com/c/145021

From-SVN: r265534
2018-10-26 16:58:13 +00:00
Ian Lance Taylor 797ea25427 libgo: fix improperly mangled linker symbol directive
Fix asm name directive for the C version of log/syslog.syslog_c,
    which didn't get included in the recent name mangling change.
    
    Reviewed-on: https://go-review.googlesource.com/c/145017

From-SVN: r265533
2018-10-26 16:53:24 +00:00
Ian Lance Taylor c404b3b9c6 libgo: don't use wc in gotest
The wc command is not in the GNU approved list of Makefile utilities
    (https://www.gnu.org/prep/standards/html_node/Utilities-in-Makefiles.html#Utilities-in-Makefiles).
    
    Reviewed-on: https://go-review.googlesource.com/c/144897

From-SVN: r265515
2018-10-26 02:43:35 +00:00
Ian Lance Taylor 34489eb2af compiler: improve name mangling for packpaths
The current implementation of Gogo::pkgpath_for_symbol was written in
    a way that allowed two distinct package paths to map to the same
    symbol, which could cause collisions at link- time or compile-time.
    
    Switch to a better mangling scheme to insure that we get a unique
    packagepath symbol for each package. In the new scheme instead of having
    separate mangling schemes for identifiers and package paths, the
    main identifier mangler ("go_encode_id") now handles mangling of
    both packagepath characters and identifier characters.
    
    The new mangling scheme is more intrusive: "foo/bar.Baz" is mangled as
    "foo..z2fbar.Baz" instead of "foo_bar.Baz". To mitigate this, this
    patch also adds a demangling capability so that function names
    returned from runtime.CallersFrames are converted back to their
    original unmangled form.
    
    Changing the pkgpath_for_symbol scheme requires updating a number of
    //go:linkname directives and C "__asm__" directives to match the new
    scheme, as well as updating the 'gotest' driver (which makes
    assumptions about the correct mapping from pkgpath symbol to package
    name).
    
    Fixes golang/go#27534.
    
    Reviewed-on: https://go-review.googlesource.com/c/135455

From-SVN: r265510
2018-10-25 22:18:08 +00:00
Ian Lance Taylor 8dd2ae4bc7 re PR go/87661 (libgo bootstrap failure on arm-linux-gnueabihf (redefinition of constants))
PR go/87661
    runtime: remove unused armArch, hwcap and hardDiv
    
    After CL 140057 these are only written but never read in gccgo.
    
    Reviewed-on: https://go-review.googlesource.com/c/141077

From-SVN: r265439
2018-10-23 19:02:29 +00:00
Ian Lance Taylor a847d2b7b1 compiler: export indexed type data, read unexported types lazily
Introduce a new "types" command to the export data to record the
    number of types and the size of their export data. It is immediately
    followed by new "type" commands that can be indexed. Parse all the
    exported types immediately so that we register them, but parse other
    type data only as needed.
    
    Reviewed-on: https://go-review.googlesource.com/c/143022

From-SVN: r265409
2018-10-23 02:46:41 +00:00
Ian Lance Taylor dbf9376f9e compiler: list indirect imports separately in export data
Previously when export data referred to a type that was not defined in
    a directly imported package, we would write the package name as
    additional information in the type's export data.  That approach
    required all type information to be read in order.  This patch changes
    the compiler to find all references to indirectly imported packages,
    and write them out as an indirectimport line in the import data.  This
    will permit us to read exported type data out of order.
    
    The type traversal used to find indirect imports is a little more
    complicated than necessary in preparation for later patches in this
    series.
    
    Reviewed-on: https://go-review.googlesource.com/c/143020

From-SVN: r265296
2018-10-18 23:22:01 +00:00