This triggered a check in releaseSudog that g.param not nil, because
libgo uses the param field when starting a goroutine. Fixed by clearing
g->param in kickoff in proc.c.
Reviewed-on: https://go-review.googlesource.com/30951
From-SVN: r241067
Since sparc is a valid architecture, the name of
getrandom_linux_sparc.go means that it will be ignored on sparc64,
even though it's whitelisted with a +build line.
On SPARC, clone has a unique return value convention which requires
some inline assembly to convert it to the normal convention.
Reviewed-on: https://go-review.googlesource.com/30873
From-SVN: r241051
Update the compiler to use the new names. Add calls to printlock and
printunlock around print statements. Move expression evaluation before
the call to printlock. Update g's writebuf field to a slice, and adjust
C code accordingly.
Reviewed-on: https://go-review.googlesource.com/30717
From-SVN: r240958
Update the compiler to use the new names. Add calls to printlock and
printunlock around print statements. Move expression evaluation before
the call to printlock. Update g's writebuf field to a slice, and adjust
C code accordingly.
Reviewed-on: https://go-review.googlesource.com/30717
From-SVN: r240956
Change the compiler to use the new routines. Drop the separation of
small and large values when sending on a channel. Allocate the select
struct on the stack. Remove the old C implementation of channels. Adjust
the garbage collector for the new data structure.
Bring in part of the tracing code, enough for the channel code to call.
Bump the permitted number of allocations in one of the tests in
context_test.go. The difference is that now receiving from a channel
allocates a sudog, which the C code used to simply put on the
stack. This will be somewhat better when we port proc.go.
Reviewed-on: https://go-review.googlesource.com/30714
From-SVN: r240941
Remove the old locking code written in C.
Add a shell script mkrsysinfo.sh to generate the runtime_sysinfo.go
file, so that we can get Go copies of the system time structures and
other types.
Tweak the compiler so that when compiling the runtime package the
address operator does not cause local variables to escape. When the gc
compiler compiles the runtime, an escaping local variable is treated as
an error. We should implement that, instead of this change, when escape
analysis is turned on.
Tweak the compiler so that the generated C header does not include names
that start with an underscore followed by a non-upper-case letter,
except for the special cases of _defer and _panic. Otherwise we
translate C types to Go in runtime_sysinfo.go and then generate those Go
types back as C types in runtime.inc, which is useless and painful for
the C code.
Change entersyscall and friends to take a dummy argument, as the gc
versions do, to simplify calls from the shared code.
Reviewed-on: https://go-review.googlesource.com/30079
From-SVN: r240657
Also copy over cputicks.go, env_posix.go, vdso_none.go, stubs2.go, and a
part of os_linux.go. Remove the corresponding functions from the C code
in libgo/go/runtime. Add some transitional support functions to
stubs.go. This converts several minor functions from C to Go.
Reviewed-on: https://go-review.googlesource.com/29962
From-SVN: r240609
This change removes the gccgo-specific hashmap code and replaces it with
the hashmap code from the Go 1.7 runtime. The Go 1.7 hashmap code is
more efficient, does a better job on details like when to update a key,
and provides some support against denial-of-service attacks.
The compiler is changed to call the new hashmap functions instead of the
old ones.
The compiler now tracks which types are reflexive and which require
updating when used as a map key, and records the information in map type
descriptors.
Map_index_expression is simplified. The special case for a map index on
the right hand side of a tuple expression has been unnecessary for some
time, and is removed. The support for specially marking a map index as
an lvalue is removed, in favor of lowering an assignment to a map index
into a function call. The long-obsolete support for a map index of a
pointer to a map is removed.
The __go_new_map_big function (known to the compiler as
Runtime::MAKEMAPBIG) is no longer needed, as the new runtime.makemap
function takes an int64 hint argument.
The old map descriptor type and supporting expression is removed.
The compiler was still supporting the long-obsolete syntax `m[k] = 0,
false` to delete a value from a map. That is now removed, requiring a
change to one of the gccgo-specific tests.
The builtin len function applied to a map or channel p is now compiled
as `p == nil ? 0 : *(*int)(p)`. The __go_chan_len function (known to
the compiler as Runtime::CHAN_LEN) is removed.
Support for a shared zero value for maps to large value types is
introduced, along the lines of the gc compiler. The zero value is
handled as a common variable.
The hash function is changed to take a seed argument, changing the
runtime hash functions and the compiler-generated hash functions.
Unlike the gc compiler, both the hash and equal functions continue to
take the type length.
Types that can not be compared now store nil for the hash and equal
functions, rather than pointing to functions that throw. Interface hash
and comparison functions now check explicitly for nil. This matches the
gc compiler and permits a simple implementation for ismapkey.
The compiler is changed to permit marking struct and array types as
incomparable, meaning that they have no hash or equal function. We use
this for thunk types, removing the existing special code to avoid
generating hash/equal functions for them.
The C runtime code adds memclr, memequal, and memmove functions.
The hashmap code uses go:linkname comments to make the functions
visible, as otherwise the compiler would discard them.
The hashmap code comments out the unused reference to the address of the
first parameter in the race code, as otherwise the compiler thinks that
the parameter escapes and copies it onto the heap. This is probably not
needed when we enable escape analysis.
Several runtime map tests that ere previously skipped for gccgo are now
run.
The Go runtime picks up type kind information and stubs. The type kind
information causes the generated runtime header file to define some
constants, including `empty`, and the C code is adjusted accordingly.
A Go-callable version of runtime.throw, that takes a Go string, is
added to be called from the hashmap code.
Reviewed-on: https://go-review.googlesource.com/29447
* go.go-torture/execute/map-1.go: Replace old map deletion syntax
with call to builtin delete function.
From-SVN: r240334
Copy over the Go 1.7 runtime/internal/sys package, but instead of having
separate files for each GOARCH and GOOS value, set the values in
configure.ac and write them out in Makefile.am. Setting the values in
configure.ac should make it easier to add new processors.
Remove the automake GOARCH conditionals, which are no longer used.
Leave the GOOS conditionals for now, as they are used for the C runtime
package.
Reviewed-on: https://go-review.googlesource.com/29018
From-SVN: r240083
Copy over the Go 1.7 runtime/internal/atomic package, but implement the
functions in C using __atomic functions rather than using the
processor-specific assembler code.
Reviewed-on: https://go-review.googlesource.com/29010
From-SVN: r240070
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
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
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.
Fixesgolang/go#16701.
Reviewed-on: https://go-review.googlesource.com/27052
From-SVN: r239486
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
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
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
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
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
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
Leaving them incorrectly marked as addressable broke a use of the
text/template package, because state.evalField checks CanAddr and takes
the address if it is addressable.
Reviewed-on: https://go-review.googlesource.com/21908
From-SVN: r234923
PR go/69966
syscall: Add new Getsockopt functions.
Add GetsockoptICMPv6Filter, GetsockoptIPv6MTUInfo, GetsockoptUcred as
appropriate. These functions exist in the master library.
For GCC PR 69966.
Reviewed-on: https://go-review.googlesource.com/19960
From-SVN: r233747
PR go/66904
cmd/go: fix "#cgo pkg-config:" comments with gccgo
Copy of https://golang.org/cl/18790 by Michael Hudson-Doyle.
The unique difficulty of #cgo pkg-config is that the linker flags are recorded
when the package is compiled but (obviously) must be used when the package is
linked into an executable -- so the flags need to be stored on disk somewhere.
As it happens cgo already writes out a _cgo_flags file: nothing uses it
currently, but this change adds it to the lib$pkg.a file when compiling a
package, reads it out when linking (and passes a version of the .a file with
_cgo_flags stripped out of it to the linker). It's all fairly ugly but it works
and I can't really think of any way of reducing the essential level of
ugliness.
Update golang/go#11739.
GCC PR 66904.
Reviewed-on: https://go-review.googlesource.com/19431
From-SVN: r233290
PR go/65785
net: don't run multicast listen test on nil interface in short mode
This is a backport of https://golang.org/cl/17154.
The gccgo bug report https://gcc.gnu.org/PR65785 points out that the
multicast listen tests will use the network even with -test.short.
Fix test by checking testing.Short with a nil interface.
Reviewed-on: https://go-review.googlesource.com/17158
From-SVN: r230695
When using the go command built from gccgo to build and
install a go tool, use the value from runtime GCCGOTOOLDIR as
the install directory.
This also fixes the output from 'go tool' when used with the
gccgo-built go command, to only include the go tools and not
other binaries found in the same directory.
Reviewed-on: https://go-review.googlesource.com/16516
From-SVN: r230677
PR go/68255
cmd/go: always use --whole-archive for gccgo packages
This is a backport of https://golang.org/cl/16775.
This is, in effect, what the gc toolchain does. It fixes cases where Go
code refers to a C global variable; without this, if the global variable
was the only thing visible in the C code, the generated cgo file might
not get pulled in from the archive, leaving the Go variable
uninitialized.
This was reported against gccgo as https://gcc.gnu.org/PR68255 .
Reviewed-on: https://go-review.googlesource.com/16778
From-SVN: r230120
PR go/66138
reflect, encoding/json, encoding/xml: fix unexported embedded structs
Bring in three changes from the master Go repository. These changes
will be in Go 1.6, but they are appropriate for gccgo now because they
resolve a long-standing discrepancy between how gc and gccgo handle the
PkgPath field for embedded unexported struct fields. The core issue is
described at https://golang.org/cl/7247. This has been reported against
gccgo as https://gcc.gnu.org/PR66138.
The three changes being brought over are:
https://golang.org/cl/14010
reflect: adjust access to unexported embedded structs
This CL changes reflect to allow access to exported fields and
methods in unexported embedded structs for gccgo and after gc
has been adjusted to disallow access to embedded unexported structs.
Adresses #12367, #7363, #11007, and #7247.
https://golang.org/cl/14011
encoding/json: check for exported fields in embedded structs
Addresses issue #12367.
https://golang.org/cl/14012
encoding/xml: check for exported fields in embedded structs
Addresses issue #12367.
Reviewed-on: https://go-review.googlesource.com/16723
From-SVN: r229907
Only build net/hook_cloexec.go on GNU/Linux and FreeBSD, because those
are the only systems with accept4.
Add syscall/libcall_bsd.go to define sendfile for *BSD and Solaris.
Revert tcpsockopt_solaris.go back to the earlier version, so that it
works on Solaris 10.
Always pass the address of a Pid_t value to TIOCGPGRP and TIOCSPGRP.
Include <unistd.h> in runtime/go-varargs.c.
Reviewed-on: https://go-review.googlesource.com/16719
From-SVN: r229880
Type descriptors picked up a zero field because the gc map
implementation used it. However, it's since been dropped by the gc
library. It was never used by gccgo. Drop it now in preparation for
upgrading to the Go 1.5 library.
Reviewed-on: https://go-review.googlesource.com/16486
From-SVN: r229546
Change the type descriptor hash and equal functions from C code pointers
to Go func values. This permits them to be set to a Go function
closure. This is in preparation for the Go 1.5, so that we can use a
closure for the hash/equal functions returned by the new reflect.ArrayOf
function.
Reviewed-on: https://go-review.googlesource.com/16485
From-SVN: r229541
PR go/67874
net, runtime: Call C library fcntl function rather than syscall.Syscall.
Not all systems define a fcntl syscall; some only have fcntl64.
Fixes GCC PR go/67874.
Reviewed-on: https://go-review.googlesource.com/15497
From-SVN: r228576
This avoids linker warnings when linking against glibc, as apparently
arm64 GNU/Linux does not support the ustat system call.
Also update to automake 1.11.6, as that is the new GCC standard.
Reviewed-on: https://go-review.googlesource.com/14567
From-SVN: r227777
The struct RawSockaddr contains a field Data which
should be uint8 on ppc64 and ppc64le, but is declared
as int8 in gccgo. This change adds a two new files
which contain the structure declaration for
RawSockaddr, one with the correct types for for ppc64
and ppc64le, and the other for non-ppc64 platforms.
Fixesgolang/go#11469
Reviewed-on: https://go-review.googlesource.com/11946
From-SVN: r226533
The syscall for Getdents in syscall/libcall_linux.go
called Entersyscall and Exitsyscall, causing the
runtime_sched counts for goroutines to be incorrect.
Inconsistent counts caused checkdead in runtime/proc.c
to panic.
Fixesgolang/go#11406
Reviewed-on: https://go-review.googlesource.com/11761
From-SVN: r225745