summaryrefslogtreecommitdiff
path: root/src/syscall
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-09-24 16:55:26 -0400
committerRuss Cox <rsc@golang.org>2014-09-24 16:55:26 -0400
commit14c9b3be770b4a59a4113783600b8d4b06f5ccd3 (patch)
treebbfc37060802619fcfbe4ce647a6571e16e86448 /src/syscall
parent8ca4b32a4ef76cacf6ac5a1ae0e2a1a1113490ee (diff)
downloadgo-14c9b3be770b4a59a4113783600b8d4b06f5ccd3.tar.gz
cmd/cc, cmd/ld, runtime: disallow conservative data/bss objects
In linker, refuse to write conservative (array of pointers) as the garbage collection type for any variable in the data/bss GC program. In the linker, attach the Go type to an already-read C declaration during dedup. This gives us Go types for C globals for free as long as the cmd/dist-generated Go code contains the declaration. (Most runtime C declarations have a corresponding Go declaration. Both are bss declarations and so the linker dedups them.) In cmd/dist, add a few more C files to the auto-Go-declaration list in order to get Go type information for the C declarations into the linker. In C compiler, mark all non-pointer-containing global declarations and all string data as NOPTR. This allows them to exist in C files without any corresponding Go declaration. Count C function pointers as "non-pointer-containing", since we have no heap-allocated C functions. In runtime, add NOPTR to the remaining pointer-containing declarations, none of which refer to Go heap objects. In runtime, also move os.Args and syscall.envs data into runtime-owned variables. Otherwise, in programs that do not import os or syscall, the runtime variables named os.Args and syscall.envs will be missing type information. I believe that this CL eliminates the final source of conservative GC scanning in non-SWIG Go programs, and therefore... Fixes issue 909. LGTM=iant R=iant CC=golang-codereviews https://codereview.appspot.com/149770043
Diffstat (limited to 'src/syscall')
-rw-r--r--src/syscall/env_unix.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/syscall/env_unix.go b/src/syscall/env_unix.go
index ad354ed05..01ac38af1 100644
--- a/src/syscall/env_unix.go
+++ b/src/syscall/env_unix.go
@@ -22,9 +22,11 @@ var (
// envs is provided by the runtime. elements are expected to be
// of the form "key=value".
- envs []string
+ envs []string = runtime_envs()
)
+func runtime_envs() []string // in package runtime
+
// setenv_c is provided by the runtime, but is a no-op if cgo isn't
// loaded.
func setenv_c(k, v string)