Skip to content

cmd/compile: large arrays cause large binaries and toolchain errors #17378

@crawshaw

Description

@crawshaw

On tip, go version devel +0db9518 Fri Oct 7 03:46:50 2016 +0000 darwin/amd64:

$ cat j.go 
package main

var x = [1 << 30]byte{0: 1}

func main() {
    println(x[0])
}
$ go build j.go
$ ls -l j
-rwxr-xr-x  1 crawshaw  eng  1074669392 Oct  7 10:34 j

Bumping 1<<30 to 1<<31 turns it into a linker error:

~$ go build j.go 
# command-line-arguments
main.x: symbol too large (2147483648 bytes)
too much data in section SNOPTRDATA (over 2000000000 bytes)
too much data in section SDATA (over 2000000000 bytes)
too much data in section SBSS (over 2000000000 bytes)
too much data in section SNOPTRBSS (over 2000000000 bytes)
main.init: pc-relative relocation address for main.initdone· is too big: 0x800ad36a
main.init: pc-relative relocation address for main.initdone· is too big: 0x800ad355
runtime.alginit: pc-relative relocation address for runtime.cpuid_ecx is too big: 0x800ac585
runtime.alginit: pc-relative relocation address for runtime.hashkey is too big: 0x800ac72d
runtime.alginit: pc-relative relocation address for runtime.hashkey is too big: 0x800ac70b
runtime.alginit: pc-relative relocation address for runtime.hashkey is too big: 0x800ac700
runtime.alginit: pc-relative relocation address for runtime.hashkey is too big: 0x800ac701
runtime.alginit: pc-relative relocation address for runtime.hashkey is too big: 0x800ac6f6
runtime.alginit: pc-relative relocation address for runtime.hashkey is too big: 0x800ac6f7
runtime.alginit: pc-relative relocation address for runtime.hashkey is too big: 0x800ac6ec
runtime.alginit: pc-relative relocation address for runtime.hashkey is too big: 0x800ac6ed
runtime.alginit: pc-relative relocation address for runtime.hashkey is too big: 0x800ac6e2
runtime.alginit: pc-relative relocation address for runtime.useAeshash is too big: 0x800ac4ea
runtime.alginit: pc-relative relocation address for runtime.algarray is too big: 0x80091a0b
runtime.alginit: pc-relative relocation address for runtime.algarray is too big: 0x80091a0d
runtime.alginit: pc-relative relocation address for runtime.algarray is too big: 0x80091a1f
/Users/crawshaw/go/pkg/tool/darwin_amd64/link: too many errors

(Inspired by https://codegolf.stackexchange.com/questions/69189/build-a-compiler-bomb/69193#69193)

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.compiler/runtimeIssues related to the Go compiler and/or runtime.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions