1
0
mirror of https://github.com/golang/go synced 2024-10-04 16:21:22 -06:00
Commit Graph

156 Commits

Author SHA1 Message Date
Elias Naur
45233734e2 runtime.cmd/ld: Add ARM external linking and implement -shared in terms of external linking
This CL is an aggregate of 10271047, 10499043, 9733044. Descriptions of each follow:

10499043
runtime,cmd/ld: Merge TLS symbols and teach 5l about ARM TLS

This CL prepares for external linking support to ARM.

The pseudo-symbols runtime.g and runtime.m are merged into a single
runtime.tlsgm symbol. When external linking, the offset of a thread local
variable is stored at a memory location instead of being embedded into a offset
of a ldr instruction. With a single runtime.tlsgm symbol for both g and m, only
one such offset is needed.

The larger part of this CL moves TLS code from gcc compiled to internally
compiled. The TLS code now uses the modern MRC instruction, and 5l is taught
about TLS fallbacks in case the instruction is not available or appropriate.

10271047
This CL adds support for -linkmode external to 5l.

For 5l itself, use addrel to allow for D_CALL relocations to be handled by the
host linker. Of the cases listed in rsc's comment in issue 4069, only case 5 and
63 needed an update. One of the TODO: addrel cases was since replaced, and the
rest of the cases are either covered by indirection through addpool (cases with
LTO or LFROM flags) or stubs (case 74). The addpool cases are covered because
addpool emits AWORD instructions, which in turn are handled by case 11.

In the runtime, change the argv argument in the rt0* functions slightly to be a
pointer to the argv list, instead of relying on a particular location of argv.

9733044
The -shared flag to 6l outputs a shared library, implemented in Go
and callable from non-Go programs such as C.

The main part of this CL change the thread local storage model.
Go uses the fastest and least general mode, local exec. TLS data in shared
libraries normally requires at least the local dynamic mode, however, this CL
instead opts for using the initial exec mode. Initial exec mode is faster than
local dynamic mode and can be used in linux since the linker has reserved a
limited amount of TLS space for performance sensitive TLS code.

Initial exec mode requires an extra load from the GOT table to determine the
TLS offset. This penalty will not be paid if ld is not in -shared mode, since
TLS accesses will be reduced to local exec.

The elf sections .init_array and .rela.init_array are added to register the Go
runtime entry with cgo at library load time.

The "hidden" attribute is added to Cgo functions called from Go, since Go
does not generate call through the GOT table, and adding non-GOT relocations for
a global function is not supported by gcc. Cgo symbols don't need to be global
and avoiding the GOT table is also faster.

The changes to 8l are only removes code relevant to the old -shared mode where
internal linking was used.

This CL only address the low level linker work. It can be submitted by itself,
but to be useful, the runtime changes in CL 9738047 is also needed.

Design discussion at
https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/zmjXkGrEx6Q

Fixes #5590.

R=rsc
CC=golang-dev
https://golang.org/cl/12871044
2013-08-14 15:38:54 +00:00
Dmitriy Vyukov
2791ef0b67 runtime/race: add end-to-end test
Fixes #5933.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/12699051
2013-08-12 22:04:10 +04:00
Russ Cox
b78410bda1 cmd/api: eliminate duplicate package import work
On my Mac, cuts the API checks from 15 seconds to 6 seconds.
Also clean up some tag confusion: go run list-of-files ignores tags.

R=bradfitz, gri
CC=golang-dev
https://golang.org/cl/12699048
2013-08-09 18:44:00 -04:00
Brad Fitzpatrick
d5e97ea2f5 build: change how cmd/api is run in run.bash and run.bat
In prep for Robert's forthcoming cmd/api rewrite which
depends on the go.tools subrepo, we'll need to be more
careful about how and when we run cmd/api.

Rather than implement this policy in both run.bash and
run.bat, this change moves the policy and mechanism into
cmd/api/run.go, which will then evolve.

The plan is in a TODO in run.go.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/12482044
2013-08-07 13:49:37 -07:00
Brad Fitzpatrick
74d2e096db build: ignore new zfiles, delete temp goplay binary in run.bash
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12320045
2013-08-02 19:14:13 -07:00
Russ Cox
2ddb672ddc build: on OS X 10.8 and later, use clang instead of gcc
Fixes #5822.
Will no doubt cause other problems, but Apple has forced our hand.

R=golang-dev, bradfitz, khr
CC=golang-dev
https://golang.org/cl/12350044
2013-08-02 14:58:27 -04:00
Brad Fitzpatrick
b8b48abe0f misc/dist: don't ship cmd/api
cmd/api is a tool to prevent the Go developers from breaking
the Go 1 API promise. It has no utility to end users and
doesn't run on arbitrary packages (it's always been full of
hacks for its bespoke type checker to work on the standard
library)

Robert's in-progress rewrite depends on the go.tools repo for
go/types, so we won't be able to ship this tool later
anyway. Just remove it from binary distributions.

A future change to run.bash can conditionally build & run
cmd/api, perhaps automatically fetching go/types if
necessary. I assume people don't want to vendor go/types into
a private gopath just for cmd/api.

I will need help with run.bat.

R=golang-dev, adg, dsymonds, rsc
CC=golang-dev
https://golang.org/cl/12316043
2013-08-02 10:19:52 -07:00
Andrew Gerrand
5f1af1608f build: remove builder from test suite (fix build)
R=golang-dev, dave, dsymonds
CC=golang-dev
https://golang.org/cl/12225043
2013-08-01 13:49:00 +10:00
Andrew Gerrand
fc32bfa9cc doc/codewalk: test source code
Fixes #2648.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/11331043
2013-07-30 09:42:53 +10:00
Russ Cox
fdb69cb0a3 build: fix build
As promised.

TBR=dvyukov
CC=golang-dev
https://golang.org/cl/12063043
2013-07-29 16:52:40 -04:00
Russ Cox
46437f0028 build: break builds
I want to see the timing information in build logs,
and we can't see the logs for "ok" builds.
So make the build fail everywhere.

Will roll back immediately.

TBR=dvyukov
CC=golang-dev
https://golang.org/cl/12058046
2013-07-29 16:52:03 -04:00
Kevin Klues
f7dfeea90f cmd/cgo: Fix issue with cgo cdefs
The problem is that the cdecl() function in cmd/cgo/godefs.go isn't
properly translating the Go array type to a C array type when an
asterisk follows the [] in the array type declaration (it is perfectly
legal to put the asterisk on either side of the [] in go syntax,
depending on how you set up your pointers).

That said, the cdefs tool is only designed to translate from Go types
generated using the cgo *godefs* tool -- where the godefs tool is
designed to translate gcc-style C types into Go types. In essence, the
cdefs tool translates from gcc-style C types to Go types (via the godefs
tool), then back to kenc-style C types. Because of this, cdefs does not
need to know how to translate arbitraty Go types into C, just the ones
produced by godefs.

The problem is that during this translation process, the logic is
slightly wrong when going from (e.g.):

char *array[10];
to:
array [10]*int8;
back to:
int8 *array[10];

In the current implementation of cdecl(), the translation from the Go
type declaration back to the kenc-style declaration looks for Go
types of the form:

name *[]type;
rather than the actual generated Go type declaration of:
name []*type;

Both are valid Go syntax, with slightly different semantics, but the
latter is the only one that can ever be generated by the godefs tools.
(The semantics of the former are not directly expressible in a
single C statement -- you would have to have to first typedef the array
type, then declare a pointer to that typedef'd type in a separate
statement).

This commit changes the logic of cdecl() to look properly for, and
translate, Go type declarations of the form:
name []*type;

Additionally, the original implementation only allowed for a single
asterisk and a single sized aray (i.e. only a single level of pointer
indirection, and only one set of []) on the type, whereas the patched
version allows for an arbitrary number of both.

Tests are included in misc/cgo/testcdefs and the all.bash script has been
updated to account for these.

R=golang-dev, bradfitz, dave, iant
CC=golang-dev
https://golang.org/cl/11377043
2013-07-24 17:27:42 -07:00
Shenghou Ma
0ce56e60b8 run.bash: enlarge timeout of runtime tests
Recently addition to runtime test makes it take very close to 720s
of timeout limit on the netbsd-arm-qemu builder.

R=golang-dev, go.peter.90, rsc
CC=golang-dev
https://golang.org/cl/10935043
2013-07-13 02:00:07 +08:00
Russ Cox
3a8845b525 run.bash: actually stop on cgo failures
I hate bash.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/11200043
2013-07-11 23:24:57 -04:00
Benny Siegert
8a4efed63c run.bash: raise ulimit for the number of threads.
This is needed on NetBSD-current. Support for
ulimit -T in bash was added in 4.2nb3.

R=golang-dev, minux.ma, rsc, dave
CC=golang-dev
https://golang.org/cl/10078047
2013-06-17 19:31:58 +10:00
Dmitriy Vyukov
a8ad859c30 runtime: more flexible heap memory mapping on 64-bits
Fixes #5641.

R=golang-dev, dave, daniel.morsing, iant
CC=golang-dev, kcc
https://golang.org/cl/10126044
2013-06-12 18:47:16 +04:00
Shenghou Ma
bea7b51872 cmd/go: fix LDFLAGS handling, enable misc/cgo/testso on Darwin
Fixes #5479.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/9416047
2013-05-22 00:32:03 +08:00
Brad Fitzpatrick
9e93d5014e api: add go1.1.txt; update cmd/api to use it
R=golang-dev, adg, r
CC=golang-dev
https://golang.org/cl/9250043
2013-05-06 17:25:09 -07:00
Ian Lance Taylor
3197be4807 cmd/dist, cmd/ld: GO_EXTLINK_ENABLED=0 defaults to -linkmode=internal
Change build system to set GO_EXTLINK_ENABLED=0 by default for
OS X 10.6, since the system linker has a bug and can not
handle the object files generated by 6l.

Fixes #5130.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/8183043
2013-03-29 16:33:35 -07:00
Ian Lance Taylor
30e29ee9b6 cmd/ld: emit TLS relocations during external linking
This CL was written by rsc.  I just tweaked 8l.

This CL adds TLS relocation to the ELF .o file we write during external linking,
so that the host linker (gcc) can decide the final location of m and g.

Similar relocations are not necessary on OS X because we use an alternate
program start-time mechanism to acquire thread-local storage.

Similar relocations are not necessary on ARM or Plan 9 or Windows
because external linking mode is not yet supported on those systems.

On almost all ELF systems, the references we use are like %fs:-0x4 or %gs:-0x4,
which we write in 6a/8a as -0x4(FS) or -0x4(GS). On Linux/ELF, however,
Xen's lack of support for this mode forced us long ago to use a two-instruction
sequence: first we load %gs:0x0 into a register r, and then we use -0x4(r).
(The ELF program loader arranges that %gs:0x0 contains a regular pointer to
that same memory location.) In order to relocate those -0x4(r) references,
the linker must know where they are. This CL adds the equivalent notation
-0x4(r)(GS*1) for this purpose: it assembles to the same encoding as -0x4(r)
but the (GS*1) indicates to the linker that this is one of those thread-local
references that needs relocation.

Thanks to Elias Naur for reminding me about this missing piece and
also for writing the test.

R=r
CC=golang-dev
https://golang.org/cl/7891047
2013-03-27 13:27:35 -07:00
Shenghou Ma
976d99b9a8 build, cmd/5l: actually report failures for -linkmode tests
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7938046
2013-03-25 03:18:05 +08:00
Shenghou Ma
0a517e458c build: increase timeout for ARM
in an effort to make builder freebsd-arm-pi and netbsd-arm-qemu pass again.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7621050
2013-03-24 16:31:28 +08:00
Russ Cox
b4f3533c92 cmd/ld: replace -hostobj with -linkmode
Still disabled. Need to fix TLS.

R=golang-dev, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/7783044
2013-03-19 15:45:42 -04:00
Russ Cox
a5b2623dab build: skip benchmarks on OpenBSD
They are making the build die. I want to be able to see that everything else is okay.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7546049
2013-03-15 12:39:14 -04:00
Shenghou Ma
960d7082ee cmd/ld, runtime/cgo: allow a symbol to be both cgo_export and cgo_import.
Fixes #4878.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/7420052
2013-03-11 14:24:51 +08:00
Russ Cox
761c386770 build: enable host linking test for all BSDs
Let's just see what breaks.

R=golang-dev, bradfitz, adg
CC=golang-dev
https://golang.org/cl/7693043
2013-03-11 01:12:18 -04:00
Russ Cox
3b85b724c5 cmd/ld: darwin support for host linking
R=ken2
CC=golang-dev
https://golang.org/cl/7626045
2013-03-11 00:51:42 -04:00
Russ Cox
0598114a90 runtime/cgo: fix arm build, re-enable test
Fixes #4961.

R=golang-dev, r, minux.ma
CC=golang-dev
https://golang.org/cl/7443048
2013-03-01 16:24:23 -05:00
Russ Cox
e02168f659 build: skip cgo test on arm
Update #4961.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7451044
2013-03-01 15:01:26 -05:00
Russ Cox
f5ceeb94a8 build: disable cgo test on openbsd
Update #4878.

R=golang-dev
CC=golang-dev
https://golang.org/cl/7450048
2013-03-01 12:13:42 -05:00
Shenghou Ma
eec961470f cmd/cgo, cmd/dist, cmd/go: cgo with clang fixes
1. Workaround the smart clang diagnostics with -Qunused-arguments:
clang: error: argument unused during compilation: '-XXX'
2. if "clang -print-libgcc-file-name" returns non-absolute path, don't
provide that on linker command line.
3. Fix dwarf.PtrType.Size() in cmd/cgo as clang doesn't generate
DW_AT_byte_size for pointer types.
4. Workaround warnings for -Wno-unneeded-internal-declaration with
-Wno-unknown-warning-option.
5. Add -Wno-unused-function.
6. enable race detector test on darwin with clang
(at least Apple clang version 1.7 (tags/Apple/clang-77) works).

Requires CL 7354043.

Update #4829
This should fix most parts of the problem, but one glitch still remains.
DWARF generated by newer clang doesn't differentiate these
two function types:
    void *malloc(size_t);
    void *malloc(unsigned long int);
so you might need to do this to make make.bash pass:
sed -i -e 's/C.malloc(C.size_t/C.malloc(C.ulong/' pkg/os/user/lookup_unix.go

R=golang-dev, dave, iant, rsc
CC=golang-dev
https://golang.org/cl/7351044
2013-02-23 20:24:38 +08:00
Russ Cox
6d888f1e1b build: clang support
This works with at least one version of clang
that existed at one moment in time.
No guarantees about clangs past or future.

To try:
        CC=clang all.bash

It does not work with the Xcode clang,
because that clang fails at printing a useful answer
to:
        clang -print-libgcc-file-name
The clang that works prints a full path name for
that command, not just "libgcc.a".

Fixes #4713.

R=iant, minux.ma
CC=golang-dev
https://golang.org/cl/7323068
2013-02-15 13:37:43 -08:00
Dave Cheney
fa21df3144 run.bash: fix linux/arm build
Revert to the shell builtin to avoid hosts that do not have /usr/bin/time.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6848054
2012-11-15 13:59:46 +11:00
Dave Cheney
36c4a73fb2 run.{bash,bat,rc}: unset GOMAXPROCS before ../test
test/run.go already executes tests in parallel where
possible. An unknown GOMAXPROCS value during the tests
is known to cause failures with tests that measure
allocations.

ref: https://groups.google.com/d/topic/golang-nuts/tgMhFJ3F5WY/discussion

R=fullung, minux.ma, r
CC=golang-dev
https://golang.org/cl/6847050
2012-11-15 11:40:10 +11:00
Russ Cox
8fadb70cf8 build: do not run race tests with cgo disabled
R=dvyukov
CC=golang-dev
https://golang.org/cl/6810067
2012-11-01 15:13:00 -04:00
Dmitriy Vyukov
95329d4cd4 run.bash: add sanity test for race detector
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6612064
2012-11-01 22:02:52 +04:00
Rob Pike
d87d488953 cmd/api: add exception file
Fixes build.

R=golang-dev, adg, bradfitz, dsymonds, dave
CC=golang-dev
https://golang.org/cl/6586074
2012-10-04 11:35:17 +10:00
Shenghou Ma
a1a414e6f1 run.bash: fix a typo (fix build)
R=golang-dev
CC=golang-dev
https://golang.org/cl/6506121
2012-09-17 01:26:57 +08:00
Shenghou Ma
329b27a566 run.bash: set appropriate ulimits
mainly for NetBSD/OpenBSD.

R=bradfitz, r, rsc
CC=golang-dev
https://golang.org/cl/6453154
2012-09-17 01:11:28 +08:00
Shenghou Ma
1e95429c3f misc/cgo/{life,stdio}, test/run.go: use test/run.go to do the cgo tests
Enhances test/run.go to support testing other directories
   Will enable stdio tests on Windows in a follow-up CL.

R=golang-dev, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/6220049
2012-08-07 09:38:35 +08:00
Dmitriy Vyukov
d5c2154caf build: revert 61d1d72136f7 (add few tests with GOMAXPROCS=32)
Some tests currently fail with GOMAXPROCS>1

R=golang-dev
CC=golang-dev
https://golang.org/cl/6398044
2012-07-14 15:59:52 +04:00
Dmitriy Vyukov
8c777066cb build: add few tests with GOMAXPROCS=32 to run.bash
Some class of bugs (data races, runtime bugs) can be found
only with real parallelism.
Note that GOMAXPROCS=32 is somewhat different from go test -cpu=32,
this intentionally uses GOMAXPROCS to stress program bootstrap,
testing code, garbage collections, etc.
Package selection is mostly random.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/6346070
2012-07-14 15:46:53 +04:00
Brad Fitzpatrick
71c1a7b777 cmd/api: add api/next.txt
This quiets all.bash noise for upcoming features we know about.

The all.bash warnings will now only print for things not in next.txt
(or in next.txt but not in the API).

Once an API is frozen, we rename next.txt to a new frozen file
(like go1.txt)

Fixes #3651

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6218069
2012-05-22 18:41:20 -07:00
Shenghou Ma
34ace1043e build: unset GOROOT_FINAL before tests
Fix the builders.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5976068
2012-04-04 23:14:54 +08:00
Rob Pike
072646cd17 run.bash: set -e in new codewalk block
Otherwise we won't fail if something goes wrong.
This shell programming stuff is tricky.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5905062
2012-03-26 17:03:04 +11:00
Rob Pike
6492cac6dd run.bash: compile the codewalks
They could be tested but that requires more than seems wise right now.

Update #2648.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/5908054
2012-03-26 16:08:21 +11:00
Shenghou Ma
2ceb653b8b build: lengthen timeout for the lengthy runtime test
To fix build on (overheated) Linux/ARM builder.

R=golang-dev, dave
CC=golang-dev
https://golang.org/cl/5865051
2012-03-21 16:19:37 +08:00
Shenghou Ma
23322ab841 build: unset GOPATH before tests
This is because we disallow local import for non-local packages, if
GOROOT happens to be under one of GOPATH, then some tests will fail
to build.
Fixes #3337.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/5852043
2012-03-21 00:47:27 +08:00
Brad Fitzpatrick
f69132d7ad build: catch API changes during build
Adds new file api/go1.txt, locking down the current API.
Any changes to the API will need to update that file.

run.bash (but not make.bash, or Windows) will check for
accidental API changes.

R=golang-dev, dsymonds, rsc
CC=golang-dev
https://golang.org/cl/5820070
2012-03-17 11:20:46 -07:00
Shenghou Ma
6d4da06d36 cmd/dist, cmd/go: move CGO_ENABLED from 'go tool dist env' to 'go env'
So that we don't duplicate knowledge about which OS/ARCH combination
        supports cgo.
        Also updated src/run.bash and src/sudo.bash to use 'go env'.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5792055
2012-03-10 03:42:23 +08:00