Commit Graph

172 Commits

Author SHA1 Message Date
Ian Lance Taylor 922cbb7c7b compiler: increase buffer size to avoid -Wformat-length warning
GCC will soon get a new -Wformat-length option as described in
    https://gcc.gnu.org/PR49905.  This change makes a buffer larger to avoid
    a warning.
    
    Reviewed-on: https://go-review.googlesource.com/28915

Also revert ChangeLog entry in gcc/go/ChangeLog--changes to
gcc/go/gofrontend do not get ChangeLog entries.

From-SVN: r240054
2016-09-09 19:39:36 +00:00
Than McIntosh 34144b6ec0 compiler: add abstraction layer for sha1 checksums.
Add new interface for the front end code to use when computing SHA1
    checksums; the intent is to allow the different implementation in
    different back ends.
    
    No change in functionality for gccgo; this is an enabling change to
    permit the front end to be used with other back ends (e.g. LLVM).
    
    Reviewed-on: https://go-review.googlesource.com/28833

	* go-sha1.cc: New file.
	* Make-lang.in (GO_OBJS): Add go/go-sha1.o.
	(CFLAGS-go/go-sha1.o): New variable.

From-SVN: r240053
2016-09-09 18:27:42 +00:00
Ian Lance Taylor 7117752523 compiler: break dependence on hex_value
Rework the lexical analyzer to eliminate the need to call
    hex_value() in libiberty (added equivalent local functionality).
    No change in functionality.
    
    Reviewed-on: https://go-review.googlesource.com/28855

From-SVN: r240049
2016-09-09 17:44:12 +00:00
Ian Lance Taylor ac376b15df runtime: use alignof to check alignment of ucontext_t
Use alignof rather than assuming a 16 byte alignment.
    
    Reviewed-on: https://go-review.googlesource.com/28913

From-SVN: r240047
2016-09-09 16:39:44 +00:00
Ian Lance Taylor a9ca0a9d02 runtime: remove remaining use of MAKECONTEXT_STACK_TOP macro
The definition and most uses of MAKECONTEXT_STACK_TOP were removed in
    https://golang.org/cl/88660043, which removed support for Solaris 8/9.
    One use of MAKECONTEXT_STACK_TOP was accidentally left in the source
    code.  Remove it now.
    
    Reviewed-on: https://go-review.googlesource.com/28911

From-SVN: r240045
2016-09-09 14:00:43 +00:00
Ian Lance Taylor 6f02c13813 runtime: align ucontext_t argument to 16 byte boundary
Some systems, such as ia64 and PPC, require that a ucontext_t pointer
    passed to getcontext and friends be aligned to a 16-byte boundary.
    Currently the ucontext_t fields in the g structure are defined in Go,
    and Go has no way to ensure a 16-byte alignment for a struct field.
    The fields are currently represented by an array of unsafe.Pointer.
    Enforce the alignment by making the array larger, and picking an offset
    into the array that is 16-byte aligned.
    
    Reviewed-on: https://go-review.googlesource.com/28910

From-SVN: r240044
2016-09-09 13:31:49 +00:00
Ian Lance Taylor fc4eaccf10 runtime: make gsignal stack at least SIGSTKSZ bytes
The default stack size for the gsignal goroutine, 32K, is not enough on
    ia64.  Make sure that the stack size is at least SIGSTKSZ.
    
    Reviewed-on: https://go-review.googlesource.com/28224

From-SVN: r239894
2016-08-31 13:59:03 +00:00
Ian Lance Taylor 75791bab05 runtime: use -fgo-c-header to build C header file
Use the new -fgo-c-header option to build a header file for the Go
    runtime code in libgo/go/runtime, and use the new header file in the C
    runtime code in libgo/runtime.  This will ensure that the Go code and C
    code share the same data structures as we convert the runtime from C to
    Go.
    
    The new file libgo/go/runtime/runtime2.go is copied from the Go 1.7
    release, and then edited to remove unnecessary data structures and
    modify others for use with libgo.
    
    The new file libgo/go/runtime/mcache.go is an initial version of the
    same files in the Go 1.7 release, and will be replaced by the Go 1.7
    file when we convert to the new memory allocator.
    
    The new file libgo/go/runtime/type.go describes the gccgo version of the
    reflection data structures, and replaces the Go 1.7 runtime file which
    describes the gc version of those structures.
    
    Using the new header file means changing a number of struct fields to
    use Go naming conventions (that is, no underscores) and to rename
    constants to have a leading underscore so that they are not exported
    from the Go package.  These names were updated in the C code.
    
    The C code was also changed to drop the thread-local variable m, as was
    done some time ago in the gc sources.  Now the m field is always
    accessed using g->m, where g is the single remaining thread-local
    variable.  This in turn required some adjustments to set g->m correctly
    in all cases.
    
    Also pass the new -fgo-compiling-runtime option when compiling the
    runtime package, although that option doesn't do anything yet.
    
    Reviewed-on: https://go-review.googlesource.com/28051

From-SVN: r239872
2016-08-30 21:07:47 +00:00
Ian Lance Taylor 2adb671d18 compiler: add -fgo-c-header=FILE to create a C header
The new -fgo-c-header=FILE option will write a C header file defining
    all the struct types and numeric const values in package scope.  This
    will be used when building the Go runtime package (libgo/go/runtime) to
    generate a C header file that may be included by the C code in the C
    runtime package (libgo/runtime).
    
    This will ensure that the Go code and C code are working with the same
    data structures as we convert the runtime from C to Go to upgrade to the
    current GC runtime, notably the concurrent garbage collector.
    
    Reviewed-on: https://go-review.googlesource.com/28000

	* lang.opt (fgo-c-header, fgo-compiling-runtime): New options.
	* go-c.h (struct go_create_gogo_args): Define.
	(go_create_gogo): Change declaration to take struct pointer.
	* go-lang.c (go_c_header): New static variable.
	(go_langhook_init): Update call to go_create_gogo.
	* gccgo.texi (Invoking gccgo): Document -fgo-c-header and
	-fgo-compiling-runtime.

From-SVN: r239852
2016-08-30 03:27:43 +00:00
Ian Lance Taylor c0ccddb46c compiler: revamp scheme for ordering calls to import init fcns.
Switch to a new method for determining the order in which import init
    functions are invoked: build an init fcn dependence DAG and walk the DAG
    to rewrite/adjust priorities to account for discrepancies introduced by
    "go test".
    
    This patch includes a change to the export data format generated
    by gccgo. Older versions of gccgo will not be able to read object files
    produced by a newer gccgo, but the new gcc will still be able to read
    old object files.
    
    Fixes golang/go#15738.
    
    Reviewed-on: https://go-review.googlesource.com/25301

From-SVN: r239708
2016-08-23 17:45:45 +00:00
Ian Lance Taylor bb748b89df compiler: don't permit P.M if P is a pointer type
When lowering method expressions of the form "P.M" where
    P is a pointer type (e.g. "type P *T") make sure we examine
    the method set of P and not T during method lookup.
    
    Fixes golang/go#15722.
    
    Reviewed-on: https://go-review.googlesource.com/24843

From-SVN: r239675
2016-08-22 21:30:49 +00:00
Ian Lance Taylor 87155d4f6c cmd/go: ignore errors from go/build for standard packages
The go/build package does not know that gccgo's standard packages don't
    have source, and will report an error saying that it can not find them.
    Work around that in the cmd/go sources, since the go/build sources don't
    currently have a list of standard packages.
    
    This should get a real fix in the master sources, somehow.
    
    Fixes golang/go#16701.
    
    Reviewed-on: https://go-review.googlesource.com/27052

From-SVN: r239486
2016-08-15 18:05:24 +00:00
Ian Lance Taylor 82b709f9c4 libgo: don't unset in shell script
Reportedly ksh fails to unset a variable that was not previously set.
    Change match.sh and gotest to not unset LANG, but instead set LANG=C.
    Also don't combine exporting and setting variable in a single statement.
    
    Reviewed-on: https://go-review.googlesource.com/26999

From-SVN: r239443
2016-08-13 02:52:42 +00:00
Ian Lance Taylor 237673d052 crypto/aes, hash/crc32: ignore s390x specific files for now
These files are used to select s390x assembler support in the gc
    toolchain.  We don't currently have that support, as it is written in
    the cmd/asm syntax rather than gas syntax.  Mark the files to be ignored
    for now, falling back to the default implementations.
    
    Patch by Andreas Krebbel.
    
    Reviewed-on: https://go-review.googlesource.com/26994

From-SVN: r239442
2016-08-13 00:19:56 +00:00
Ian Lance Taylor 7159824eb3 syscall: remove exec_solaris_test.go
It is testing functionality that gccgo does not need and does not
    support.
    
    Reviewed-on: https://go-review.googlesource.com/26992

From-SVN: r239438
2016-08-13 00:14:19 +00:00
Ian Lance Taylor 3d0fa95d5c os: fix build tags for dir_regfile.go
We want to build dir_regfile.go if not GNU/linux, and not solaris/386,
    and not solaris/sparc.  The latter two conditions were incorrect.  To
    write ! solaris/386 we have to write !solaris !386.  I forgot De
    Morgan's Law.
    
    Reviewed-on: https://go-review.googlesource.com/26870

From-SVN: r239393
2016-08-11 21:36:13 +00:00
Ian Lance Taylor 4cc1fc4f9e compiler: annotate or fix fall through cases in switch statements
A new GCC warning, -Wimplicit-fallthrough, detected these three cases
    where a switch case falls through to another.  One of them looks like
    a bug, so I fixed it; the two other look like intended fall throughs
    so I just added a "fall through" comment to suppress the GCC warning.
    
    Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.
    
    Reviewed-on: https://go-review.googlesource.com/26695

From-SVN: r239332
2016-08-10 18:56:35 +00:00
Ian Lance Taylor a36cb5b1d4 compiler: implement go:noinline and go:nosplit directives
Reviewed-on: https://go-review.googlesource.com/26652

From-SVN: r239315
2016-08-10 00:46:35 +00:00
Ian Lance Taylor 315873869d compiler: implement go:linkname compiler directive
Implement the go:linkname compiler directive for functions (both
    function definitions and function declarations).  At least for now, give
    an error for code that tries to use go:linkname with a non-function.
    
    Reviewed-on: https://go-review.googlesource.com/26651

From-SVN: r239311
2016-08-09 23:08:32 +00:00
Ian Lance Taylor bbc824cd56 mksysinfo.sh: always define CLONE_NEWNET
CLONE_NEWNET is needed to compile the syscall tests on GNU/Linux.
    The symbol is not defined in the CentOS 5.11 header files.
    
    Patch from Uros Bizjak.
    
    Reviewed-on: https://go-review.googlesource.com/26630

From-SVN: r239296
2016-08-09 16:38:23 +00:00
Ian Lance Taylor b87060ce92 compiler: rewrite compiler directive support
Rewrite the compiler directive support to recognize all the compiler
    directives implemented by the current gc compiler.  The directives other
    than go:linkname are now turned into GOPRAGMA flags attached to a
    function or function declaration.  The go:linkname directive is turned
    into a map attached to the Lex object.  No new directives are actually
    implemented yet, they are just recognized.
    
    Reviewed-on: https://go-review.googlesource.com/26610

From-SVN: r239282
2016-08-09 14:05:17 +00:00
Ian Lance Taylor 0717bdbfbd text/template: reduce maxExecDepth for gccgo further
We already lowered the limit of recursive template invocations from
    100,000 to 10,000, but the tests still fail occasionally on
    x86_64-pc-linux-gnu when using GNU ld (so that split stacks are not
    fully functional).  Reduce the limit further, to 1000, enough so that
    the test passes consistently.
    
    Permitting 1000 recursive template invocations still seems capacious
    enough for real world use.
    
    Reviewed-on: https://go-review.googlesource.com/25590

From-SVN: r239261
2016-08-08 22:55:29 +00:00
Ian Lance Taylor b123572d81 libgo: don't have .lo depend on .lo.dep
Having each .lo depend on the corresponding .lo.dep caused too many
    rebuilds, because the .lo.dep files are rebuilt when Makefile changes.
    Instead, if the .lo.dep file changes, remove the .lo file.
    
    Reviewed-on: https://go-review.googlesource.com/25588

From-SVN: r239258
2016-08-08 21:23:57 +00:00
Ian Lance Taylor 9a7b016159 testsuite: fix gotest for absolute srcdir
The recent changes to Makefile.am mean that if you configure with an
    absolute path as srcdir then gotest will be invoked with absolute paths
    for the files.  That case never worked.  This patch fixes it.
    
    Reviewed-on: https://go-review.googlesource.com/25587

From-SVN: r239256
2016-08-08 20:34:05 +00:00
Ian Lance Taylor f432d1282d re PR go/72814 (reflect FAILs on 32-bit Solaris/SPARC: SIGILL)
PR go/72814

    runtime: treat zero-sized result value as void
    
    Change the FFI interface to treat a call to a function that returns a
    zero-sized result as a call to a function that returns void.
    
    This is part of the fix for https://gcc.gnu.org/PR72814.  On 32-bit
    SPARC systems, a call to a function that returns a non-zero-sized struct
    is followed by an unimp instruction that describes the size of the
    struct.  The function returns to the address after the unimp
    instruction.  The libffi library can not represent a zero-sized struct,
    so we wind up treating it as a 1-byte struct.  Thus in that case libffi
    calls the function with an unimp instruction, but the function does not
    adjust the return address.  The result is that the program attempts to
    execute the unimp instruction, causing a crash.
    
    This is part of a change that fixes the crash by treating all functions
    that return zero bytes as functions that return void.
    
    Reviewed-on: https://go-review.googlesource.com/25585

	* go-gcc.cc (Gcc_backend::function_type): If the return type is
	zero bytes, treat the function as returning void.
	(return_statement): If the return type is zero bytes, don't
	actually return any values.

From-SVN: r239252
2016-08-08 19:53:44 +00:00
Ian Lance Taylor 4f8e688afc internal/syscall/unix: fix syscalls for alpha, ia64, s390
Also change the configure script to set GOARCH correctly for ia64, and
    add ia64 as a processor to match.sh and gotest.
    
    Reviewed-on: https://go-review.googlesource.com/25549

From-SVN: r239225
2016-08-07 22:32:46 +00:00
Ian Lance Taylor 851e6c6a8e libgo: fix getrandom build for 32-bit ppc
Add a ppc build constraint for internal/syscall/unix.
    
    Reviewed-on: https://go-review.googlesource.com/25547

From-SVN: r239210
2016-08-06 15:58:22 +00:00
Ian Lance Taylor e0f69f36ea libgo: change build procedure to use build tags
Previously the libgo Makefile explicitly listed the set of files to
    compile for each package.  For packages that use build tags, this
    required a lot of awkward automake conditionals in the Makefile.
    
    This CL changes the build to look at the build tags in the files.
    The new shell script libgo/match.sh does the matching.  This required
    adjusting a lot of build tags, and removing some files that are never
    used.  I verified that the exact same sets of files are compiled on
    amd64 GNU/Linux.  I also tested the build on i386 Solaris.
    
    Writing match.sh revealed some bugs in the build tag handling that
    already exists, in a slightly different form, in the gotest shell
    script.  This CL fixes those problems as well.
    
    The old code used automake conditionals to handle systems that were
    missing strerror_r and wait4.  Rather than deal with those in Go, those
    functions are now implemented in runtime/go-nosys.c when necessary, so
    the Go code can simply assume that they exist.
    
    The os testsuite looked for dir_unix.go, which was never built for gccgo
    and has now been removed.  I changed the testsuite to look for dir.go
    instead.
    
    Reviewed-on: https://go-review.googlesource.com/25546

From-SVN: r239189
2016-08-06 00:36:33 +00:00
Ian Lance Taylor e91f59b919 runtime: fix incorrectly commented out code in heapdump.c
Reviewed-on: https://go-review.googlesource.com/25490

From-SVN: r239144
2016-08-04 17:21:23 +00:00
Ian Lance Taylor aa8a418bbc text/template: reduce maxExecDepth for gccgo
When using gccgo on systems without full support for split stacks a
    recursive template can overrun the available stack space.  Reduce the
    limit from 100000 to 10000 to make this less likely.  It's still high
    enough that real uses will work.
    
    Reviewed-on: https://go-review.googlesource.com/25467

From-SVN: r239141
2016-08-04 16:48:28 +00:00
Ian Lance Taylor 7a62db9787 compiler: include "go-system.h" in escape.cc
Patch from Rainer Orth.
    
    Reviewed-on: https://go-review.googlesource.com/25466

From-SVN: r239140
2016-08-04 16:23:09 +00:00
Ian Lance Taylor 8a14b86bcf escape: Enable escape analysis in gccgo.
Off by default, enabled through -fgo-optimize-allocs.
    
    Reviewed-on: https://go-review.googlesource.com/22378

From-SVN: r239109
2016-08-04 00:10:35 +00:00
Ian Lance Taylor 9c26dfd08a gotest: multiple +build lines must all be true
The code that handled +build lines did not correctly require them to all
    be true.  While looking into this I discovered that multiple +build
    lines were mishandled in a different way, because the shell does not
    preseve line breaks in backquoted data.  Look for the +build token to
    tell us when we are switching from one +build line to another.
    
    Reviewed-on: https://go-review.googlesource.com/25460

From-SVN: r239100
2016-08-03 22:46:06 +00:00
Ian Lance Taylor f177a3d139 compiler: improve type caching for interface types
Add a cached to Interface_info_expression::do_type() so as to reuse
    previously created interface types. This change reduces gccgo peak heap
    usage when compiling the "fmt" package from around 16mb to around 10mb.
    
    Fixes golang/go#16334
    
    Reviewed-on: https://go-review.googlesource.com/24890

From-SVN: r239095
2016-08-03 20:01:09 +00:00
Ian Lance Taylor 3af8a0a810 escape: Stack allocate non-escaping expressions.
Stack allocate expressions that the analysis tracked and determined
    did not escape.
    
    Reviewed-on: https://go-review.googlesource.com/22377

From-SVN: r239083
2016-08-03 16:32:17 +00:00
Chris Manghane 7295570dd4 escape: Add basic debugging.
Emit basic debug information when compiling with the flag
    -fgo-debug-escape#.
    
    Reviewed-on: https://go-review.googlesource.com/22376

	2016-08-02  Chris Manghane  <cmang@google.com>

	* lang.opt: Add -fgo-debug-escape option.
	* go-c.h (go_create_gogo): Add debug_escape_level parameter.
	* go-lang.c (go_langhook_init): Pass go_debug_escape_level to
	go_create_gogo.

From-SVN: r239002
2016-08-02 21:43:48 +00:00
Ian Lance Taylor c5fe5e8032 libgo: bump library version number for 1.7
Reviewed-on: https://go-review.googlesource.com/25211

From-SVN: r238743
2016-07-26 01:53:27 +00:00
Ian Lance Taylor 870e8ca5a7 os/user: fix Solaris declaration.
Patch from Rainer Orth.
    
    Reviewed-on: https://go-review.googlesource.com/25210

From-SVN: r238742
2016-07-26 01:38:33 +00:00
Ian Lance Taylor 22b955cca5 libgo: update to go1.7rc3
Reviewed-on: https://go-review.googlesource.com/25150

From-SVN: r238662
2016-07-22 18:15:38 +00:00
Ian Lance Taylor 4114e6b1fe compiler: fix check for duplicate declaration
The compiler check that issued a duplicate declaration error for
        a, a, a := 1, 2, 3
    was incorrectly issuing an error for
        a, a, a = 1, 2, 3
    While this is not particularly useful, it is valid Go.
    
    Test is https://golang.org/cl/25143.
    
    Reviewed-on: https://go-review.googlesource.com/25144

From-SVN: r238618
2016-07-22 00:21:51 +00:00
Ian Lance Taylor 221b3e6c32 escape: Add escape notes to export data.
Reviewed-on: https://go-review.googlesource.com/22375

From-SVN: r238266
2016-07-12 20:29:15 +00:00
Ian Lance Taylor f91f0e2173 escape: Implement tag phase.
Adds notes to function parameters which summarize the escape of that
    parameter with respect to the function's scope.
    
    Reviewed-on: https://go-review.googlesource.com/18443

From-SVN: r238057
2016-07-06 17:34:03 +00:00
Ian Lance Taylor 079d2e14e3 escape: Implement flood phase.
Walks the connection graphs built in the assign phase from the
    function context's sink, propagating the escape level to each
    visited node and uncovering nodes that leak out of their scope
    which implies they must be heap allocated.
    
    Reviewed-on: https://go-review.googlesource.com/18413

From-SVN: r237453
2016-06-14 17:20:33 +00:00
Ian Lance Taylor 3db5773f70 escape: Implement assign phase.
Implementation of the assign/connect phase.
    Statements containing expressions which alias local, parameter,
    and global objects are analyzed and the alias relationship between
    objects containing pointers are captured in a connection graph to
    summarize the assignments within a function.
    
    Reviewed-on: https://go-review.googlesource.com/18302

From-SVN: r237424
2016-06-14 04:29:43 +00:00
Ian Lance Taylor 5eeb039f6a compiler: fix quoting in error message
Reviewed-on: https://go-review.googlesource.com/23966

From-SVN: r237286
2016-06-10 01:21:48 +00:00
Ian Lance Taylor 6eaba1b066 escape: Implement the discovery phase.
Implements the discovery phase according the SCC algorithm used in
    gc/esc.go.  Traverse all functions to find components that are either
    trivial or recursive.  The discovered function groups will be analyzed
    from the bottom-up to allow for an inter-procedural analysis.
    
    Reviewed-on: https://go-review.googlesource.com/18221

From-SVN: r236224
2016-05-13 20:42:36 +00:00
Ian Lance Taylor 2c418e1f8f escape: Add escape graph nodes.
Introduces the nodes used to model connectivity in the escape graph
    and related state: a node's escape level and an encoding that will
    be added to import and export data.
    
    Reviewed-on: https://go-review.googlesource.com/18268

From-SVN: r235988
2016-05-06 21:24:19 +00:00
Chris Manghane 2a30f87f75 escape: Add skeleton for gc analysis.
Introduces a skeleton replacement escape analysis
    which contains four different phases extracted from the escape
    analysis implementation in gc/esc.go.  Also introduces the
    Escape_context each phase uses to make decisions.
    
    Reviewed-on: https://go-review.googlesource.com/18220

From-SVN: r235982
2016-05-06 17:37:55 +00:00
Chris Manghane e49aacaf30 escape: Remove previously existing analysis.
* Make-lang.in (GO_OBJS): Remove go/dataflow.o, go/escape.o.

    Reviewed-on: https://go-review.googlesource.com/18261

From-SVN: r235649
2016-04-29 17:33:01 +00:00
Ian Lance Taylor f22693cb96 compiler: Mark concurrent calls.
If a call expression is executed in an independent goroutine via
    use of a Go statement, mark it as concurrent.
    
    Reviewed-on: https://go-review.googlesource.com/18700

From-SVN: r235608
2016-04-28 19:43:20 +00:00