diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/asm/internal/flags/flags.go | 4 | ||||
| -rw-r--r-- | src/cmd/asm/main.go | 2 | ||||
| -rw-r--r-- | src/cmd/compile/internal/gc/lex.go | 12 | ||||
| -rw-r--r-- | src/cmd/compile/internal/gc/mkbuiltin.go | 17 | ||||
| -rw-r--r-- | src/cmd/compile/internal/gc/obj.go | 3 | ||||
| -rw-r--r-- | src/cmd/dist/build.go | 51 | ||||
| -rw-r--r-- | src/cmd/go/build.go | 56 | ||||
| -rw-r--r-- | src/cmd/go/env.go | 4 | ||||
| -rw-r--r-- | src/cmd/link/internal/ld/lib.go | 2 | ||||
| -rw-r--r-- | src/cmd/link/internal/ld/pobj.go | 5 | ||||
| -rw-r--r-- | src/cmd/pack/pack_test.go | 25 | ||||
| -rw-r--r-- | src/go/build/build.go | 21 | ||||
| -rw-r--r-- | src/go/internal/gcimporter/gcimporter.go | 2 | ||||
| -rw-r--r-- | src/go/internal/gcimporter/gcimporter_test.go | 3 |
14 files changed, 59 insertions, 148 deletions
diff --git a/src/cmd/asm/internal/flags/flags.go b/src/cmd/asm/internal/flags/flags.go index c74f26974a..bf5cb1eef3 100644 --- a/src/cmd/asm/internal/flags/flags.go +++ b/src/cmd/asm/internal/flags/flags.go @@ -51,7 +51,7 @@ func Usage() { os.Exit(2) } -func Parse(theChar int) { +func Parse() { flag.Usage = Usage flag.Parse() if flag.NArg() != 1 { @@ -64,6 +64,6 @@ func Parse(theChar int) { if strings.HasSuffix(input, ".s") { input = input[:len(input)-2] } - *OutputFile = fmt.Sprintf("%s.%c", input, theChar) + *OutputFile = fmt.Sprintf("%s.o", input) } } diff --git a/src/cmd/asm/main.go b/src/cmd/asm/main.go index 32bdee6624..db0e28e2e5 100644 --- a/src/cmd/asm/main.go +++ b/src/cmd/asm/main.go @@ -29,7 +29,7 @@ func main() { log.Fatalf("asm: unrecognized architecture %s", GOARCH) } - flags.Parse(architecture.Thechar) + flags.Parse() // Create object file, write header. fd, err := os.Create(*flags.OutputFile) diff --git a/src/cmd/compile/internal/gc/lex.go b/src/cmd/compile/internal/gc/lex.go index f9211407fb..3b93207ef1 100644 --- a/src/cmd/compile/internal/gc/lex.go +++ b/src/cmd/compile/internal/gc/lex.go @@ -583,7 +583,7 @@ func findpkg(name string) (file string, ok bool) { if obj.Access(file, 0) >= 0 { return file, true } - file = fmt.Sprintf("%s.%c", name, Thearch.Thechar) + file = fmt.Sprintf("%s.o", name) if obj.Access(file, 0) >= 0 { return file, true } @@ -605,7 +605,7 @@ func findpkg(name string) (file string, ok bool) { if obj.Access(file, 0) >= 0 { return file, true } - file = fmt.Sprintf("%s/%s.%c", p.dir, name, Thearch.Thechar) + file = fmt.Sprintf("%s/%s.o", p.dir, name) if obj.Access(file, 0) >= 0 { return file, true } @@ -626,7 +626,7 @@ func findpkg(name string) (file string, ok bool) { if obj.Access(file, 0) >= 0 { return file, true } - file = fmt.Sprintf("%s/pkg/%s_%s%s%s/%s.%c", goroot, goos, goarch, suffixsep, suffix, name, Thearch.Thechar) + file = fmt.Sprintf("%s/pkg/%s_%s%s%s/%s.o", goroot, goos, goarch, suffixsep, suffix, name) if obj.Access(file, 0) >= 0 { return file, true } @@ -637,7 +637,7 @@ func findpkg(name string) (file string, ok bool) { func fakeimport() { importpkg = mkpkg("fake") - cannedimports("fake.6", "$$\n") + cannedimports("fake.o", "$$\n") } func importfile(f *Val, line int) { @@ -679,7 +679,7 @@ func importfile(f *Val, line int) { } importpkg = mkpkg(f.U.(string)) - cannedimports("unsafe.6", unsafeimport) + cannedimports("unsafe.o", unsafeimport) imported_unsafe = 1 return } @@ -2596,6 +2596,6 @@ func mkpackage(pkgname string) { if i := strings.LastIndex(p, "."); i >= 0 { p = p[:i] } - outfile = fmt.Sprintf("%s.%c", p, Thearch.Thechar) + outfile = fmt.Sprintf("%s.o", p) } } diff --git a/src/cmd/compile/internal/gc/mkbuiltin.go b/src/cmd/compile/internal/gc/mkbuiltin.go index b2362a6f01..f4569b48c2 100644 --- a/src/cmd/compile/internal/gc/mkbuiltin.go +++ b/src/cmd/compile/internal/gc/mkbuiltin.go @@ -13,21 +13,14 @@ package main import ( "bufio" "fmt" - "go/build" "io" "log" "os" "os/exec" - "runtime" "strings" ) func main() { - gochar, err := build.ArchChar(runtime.GOARCH) - if err != nil { - log.Fatal(err) - } - f, err := os.Create("builtin.go") if err != nil { log.Fatal(err) @@ -40,7 +33,7 @@ func main() { fmt.Fprintln(w, "package gc") for _, name := range os.Args[1:] { - mkbuiltin(w, gochar, name) + mkbuiltin(w, name) } if err := w.Flush(); err != nil { @@ -49,11 +42,11 @@ func main() { } // Compile .go file, import data from .6 file, and write Go string version. -func mkbuiltin(w io.Writer, gochar string, name string) { - if err := exec.Command("go", "tool", gochar+"g", "-A", "builtin/"+name+".go").Run(); err != nil { +func mkbuiltin(w io.Writer, name string) { + if err := exec.Command("go", "tool", "compile", "-A", "builtin/"+name+".go").Run(); err != nil { log.Fatal(err) } - obj := fmt.Sprintf("%s.%s", name, gochar) + obj := "name.o" defer os.Remove(obj) r, err := os.Open(obj) @@ -77,7 +70,7 @@ Begin: fmt.Fprintf(w, "\nconst %simport = \"\" +\n", name) // sys.go claims to be in package PACKAGE to avoid - // conflicts during "6g sys.go". Rename PACKAGE to $2. + // conflicts during "go tool compile sys.go". Rename PACKAGE to $2. replacer := strings.NewReplacer("PACKAGE", name) // Process imports, stopping at $$ that closes them. diff --git a/src/cmd/compile/internal/gc/obj.go b/src/cmd/compile/internal/gc/obj.go index 2afd786dc1..9bb334ca34 100644 --- a/src/cmd/compile/internal/gc/obj.go +++ b/src/cmd/compile/internal/gc/obj.go @@ -102,8 +102,7 @@ func dumpobj() { obj.Bputc(bout, 0) } obj.Bseek(bout, startobj-ArhdrSize, 0) - name := fmt.Sprintf("_go_.%c", Thearch.Thechar) - formathdr(arhdr[:], name, size) + formathdr(arhdr[:], "_go_.o", size) bout.Write(arhdr[:]) } diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index d6cfaf02cb..0cdb7d69f7 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -20,7 +20,6 @@ var ( goarch string gobin string gohostarch string - gohostchar string gohostos string goos string goarm string @@ -30,10 +29,8 @@ var ( goextlinkenabled string workdir string tooldir string - gochar string oldgoos string oldgoarch string - oldgochar string slash string exe string defaultcc string @@ -48,17 +45,13 @@ var ( vflag int // verbosity ) -// The known architecture letters. -var gochars = "5667899" - // The known architectures. var okgoarch = []string{ - // same order as gochars - "arm", + "386", "amd64", "amd64p32", + "arm", "arm64", - "386", "ppc64", "ppc64le", } @@ -147,22 +140,18 @@ func xinit() { gohostarch = b } - i := find(gohostarch, okgoarch) - if i < 0 { + if find(gohostarch, okgoarch) < 0 { fatal("unknown $GOHOSTARCH %s", gohostarch) } - gohostchar = gochars[i : i+1] b = os.Getenv("GOARCH") if b == "" { b = gohostarch } goarch = b - i = find(goarch, okgoarch) - if i < 0 { + if find(goarch, okgoarch) < 0 { fatal("unknown $GOARCH %s", goarch) } - gochar = gochars[i : i+1] b = os.Getenv("GO_EXTLINK_ENABLED") if b != "" { @@ -436,7 +425,7 @@ func setup() { } // If $GOBIN is set and has a Go compiler, it must be cleaned. - for _, char := range gochars { + for _, char := range "56789" { if isfile(pathf("%s%s%c%s", gobin, slash, char, "g")) { for _, old := range oldtool { xremove(pathf("%s/%s", gobin, old)) @@ -703,11 +692,7 @@ func install(dir string) { b := pathf("%s/%s", workdir, filepath.Base(p)) // Change the last character of the output file (which was c or s). - if gohostos == "plan9" { - b = b[:len(b)-1] + gohostchar - } else { - b = b[:len(b)-1] + "o" - } + b = b[:len(b)-1] + "o" compile = append(compile, "-o", b, p) bgrun(path, compile...) @@ -1035,7 +1020,6 @@ func cmdenv() { xprintf(format, "GOHOSTARCH", gohostarch) xprintf(format, "GOHOSTOS", gohostos) xprintf(format, "GOTOOLDIR", tooldir) - xprintf(format, "GOCHAR", gochar) if goarch == "arm" { xprintf(format, "GOARM", goarm) } @@ -1080,10 +1064,8 @@ func cmdbootstrap() { // For the main bootstrap, building for host os/arch. oldgoos = goos oldgoarch = goarch - oldgochar = gochar goos = gohostos goarch = gohostarch - gochar = gohostchar os.Setenv("GOHOSTARCH", gohostarch) os.Setenv("GOHOSTOS", gohostos) os.Setenv("GOARCH", goarch) @@ -1097,37 +1079,22 @@ func cmdbootstrap() { // than in a standard release like Go 1.4, so don't do this rebuild by default. if false { xprintf("##### Building Go toolchain using itself.\n") - for _, pattern := range buildorder { - if pattern == "cmd/go" { + for _, dir := range buildorder { + if dir == "cmd/go" { break } - dir := pattern - if strings.Contains(pattern, "%s") { - dir = fmt.Sprintf(pattern, gohostchar) - } install(dir) - if oldgochar != gohostchar && strings.Contains(pattern, "%s") { - install(fmt.Sprintf(pattern, oldgochar)) - } } xprintf("\n") } xprintf("##### Building compilers and go_bootstrap for host, %s/%s.\n", gohostos, gohostarch) - for _, pattern := range buildorder { - dir := pattern - if strings.Contains(pattern, "%s") { - dir = fmt.Sprintf(pattern, gohostchar) - } + for _, dir := range buildorder { install(dir) - if oldgochar != gohostchar && strings.Contains(pattern, "%s") { - install(fmt.Sprintf(pattern, oldgochar)) - } } goos = oldgoos goarch = oldgoarch - gochar = oldgochar os.Setenv("GOARCH", goarch) os.Setenv("GOOS", goos) diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go index aa9a408eff..17ff7e0cbb 100644 --- a/src/cmd/go/build.go +++ b/src/cmd/go/build.go @@ -547,9 +547,6 @@ var ( goarch string goos string exeSuffix string - - archCharVal string - archCharErr error ) func init() { @@ -558,16 +555,6 @@ func init() { if goos == "windows" { exeSuffix = ".exe" } - archCharVal, archCharErr = build.ArchChar(goarch) -} - -// archChar returns the architecture character. This is only needed -// for the gc toolchain, so only fail if we actually need it. -func archChar() string { - if archCharErr != nil { - fatalf("%s", archCharErr) - } - return archCharVal } // A builder holds global state about a build. @@ -1208,7 +1195,7 @@ func (b *builder) build(a *action) (err error) { fmt.Fprintf(os.Stderr, "%s\n", a.p.ImportPath) } - if a.p.Standard && a.p.ImportPath == "runtime" && buildContext.Compiler == "gc" && archChar() != "" && + if a.p.Standard && a.p.ImportPath == "runtime" && buildContext.Compiler == "gc" && (!hasString(a.p.GoFiles, "zgoos_"+buildContext.GOOS+".go") || !hasString(a.p.GoFiles, "zgoarch_"+buildContext.GOARCH+".go")) { return fmt.Errorf("%s/%s must be bootstrapped using make%v", buildContext.GOOS, buildContext.GOARCH, defaultSuffix()) @@ -1371,15 +1358,8 @@ func (b *builder) build(a *action) (err error) { } } - var objExt string - if _, ok := buildToolchain.(gccgoToolchain); ok { - objExt = "o" - } else { - objExt = archChar() - } - for _, file := range cfiles { - out := file[:len(file)-len(".c")] + "." + objExt + out := file[:len(file)-len(".c")] + ".o" if err := buildToolchain.cc(b, a.p, obj, obj+out, file); err != nil { return err } @@ -1388,7 +1368,7 @@ func (b *builder) build(a *action) (err error) { // Assemble .s files. for _, file := range sfiles { - out := file[:len(file)-len(".s")] + "." + objExt + out := file[:len(file)-len(".s")] + ".o" if err := buildToolchain.asm(b, a.p, obj, obj+out, file); err != nil { return err } @@ -2120,7 +2100,7 @@ func (gcToolchain) gc(b *builder, p *Package, archive, obj string, asmhdr bool, if archive != "" { ofile = archive } else { - out := "_go_." + archChar() + out := "_go_.o" ofile = obj + out } @@ -2182,9 +2162,22 @@ func (gcToolchain) asm(b *builder, p *Package, obj, ofile, sfile string) error { } // Disable checks when additional flags are passed, as the old assemblers // don't implement some of them (e.g., -shared). - if verifyAsm && goarch != "arm64" && len(buildAsmflags) == 0 { - if err := toolVerify(b, p, "old"+archChar()+"a", ofile, args); err != nil { - return err + if verifyAsm && len(buildAsmflags) == 0 { + old := "" + switch goarch { + case "arm": + old = "old5a" + case "amd64", "amd64p32": + old = "old6a" + case "386": + old = "old8a" + case "ppc64", "ppc64le": + old = "old9a" + } + if old != "" { + if err := toolVerify(b, p, old, ofile, args); err != nil { + return err + } } } return nil @@ -2785,13 +2778,6 @@ func (b *builder) cgo(p *Package, cgoExe, obj string, pcCFLAGS, pcLDFLAGS, cgofi cgoflags := []string{} // TODO: make cgo not depend on $GOARCH? - var objExt string - if _, ok := buildToolchain.(gccgoToolchain); ok { - objExt = "o" - } else { - objExt = archChar() - } - if p.Standard && p.ImportPath == "runtime/cgo" { cgoflags = append(cgoflags, "-import_runtime_cgo=false") } @@ -2836,7 +2822,7 @@ func (b *builder) cgo(p *Package, cgoExe, obj string, pcCFLAGS, pcLDFLAGS, cgofi // cc _cgo_defun.c _, gccgo := buildToolchain.(gccgoToolchain) if gccgo { - defunObj := obj + "_cgo_defun." + objExt + defunObj := obj + "_cgo_defun.o" if err := buildToolchain.cc(b, p, obj, defunObj, defunC); err != nil { return nil, nil, err } diff --git a/src/cmd/go/env.go b/src/cmd/go/env.go index 863eb4d26e..8d427b37c2 100644 --- a/src/cmd/go/env.go +++ b/src/cmd/go/env.go @@ -49,10 +49,6 @@ func mkEnv() []envVar { {"TERM", "dumb"}, } - if archCharErr == nil { - env = append(env, envVar{"GOCHAR", archChar()}) - } - if goos != "plan9" { cmd := b.gccCmd(".") env = append(env, envVar{"CC", cmd[0]}) diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index a36cd0f8f4..6cf0b525e5 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -1627,7 +1627,7 @@ func Cput(c uint8) { } func usage() { - fmt.Fprintf(os.Stderr, "usage: %cl [options] obj.%c\n", Thearch.Thechar, Thearch.Thechar) + fmt.Fprintf(os.Stderr, "usage: link [options] main.o\n") obj.Flagprint(2) Exit(2) } diff --git a/src/cmd/link/internal/ld/pobj.go b/src/cmd/link/internal/ld/pobj.go index 8568744c3d..5b24428059 100644 --- a/src/cmd/link/internal/ld/pobj.go +++ b/src/cmd/link/internal/ld/pobj.go @@ -160,10 +160,9 @@ func Ldmain() { } if outfile == "" { + outfile = "a.out" if HEADTYPE == obj.Hwindows { - outfile = fmt.Sprintf("%c.out.exe", Thearch.Thechar) - } else { - outfile = fmt.Sprintf("%c.out", Thearch.Thechar) + outfile += ".exe" } } diff --git a/src/cmd/pack/pack_test.go b/src/cmd/pack/pack_test.go index 97992059b9..cd32020501 100644 --- a/src/cmd/pack/pack_test.go +++ b/src/cmd/pack/pack_test.go @@ -13,7 +13,6 @@ import ( "os" "os/exec" "path/filepath" - "regexp" "runtime" "testing" "time" @@ -223,15 +222,13 @@ func TestHello(t *testing.T) { t.Fatal(err) } - char := findChar(t, dir) - run := func(args ...string) string { return doRun(t, dir, args...) } run("go", "build", "cmd/pack") // writes pack binary to dir run("go", "tool", "compile", "hello.go") - run("./pack", "grc", "hello.a", "hello."+char) + run("./pack", "grc", "hello.a", "hello.o") run("go", "tool", "link", "-o", "a.out", "hello.a") out := run("./a.out") if out != "hello world\n" { @@ -297,17 +294,15 @@ func TestLargeDefs(t *testing.T) { t.Fatal(err) } - char := findChar(t, dir) - run := func(args ...string) string { return doRun(t, dir, args...) } run("go", "build", "cmd/pack") // writes pack binary to dir run("go", "tool", "compile", "large.go") - run("./pack", "grc", "large.a", "large."+char) + run("./pack", "grc", "large.a", "large.o") run("go", "tool", "compile", "-I", ".", "main.go") - run("go", "tool", "link", "-L", ".", "-o", "a.out", "main."+char) + run("go", "tool", "link", "-L", ".", "-o", "a.out", "main.o") out := run("./a.out") if out != "ok\n" { t.Fatalf("incorrect output: %q, want %q", out, "ok\n") @@ -325,20 +320,6 @@ func doRun(t *testing.T, dir string, args ...string) string { return string(out) } -// findChar returns the architecture character for the go command. -func findChar(t *testing.T, dir string) string { - out := doRun(t, dir, "go", "env") - re, err := regexp.Compile(`\s*GOCHAR=['"]?(\w)['"]?`) - if err != nil { - t.Fatal(err) - } - fields := re.FindStringSubmatch(out) - if fields == nil { - t.Fatal("cannot find GOCHAR in 'go env' output:\n", out) - } - return fields[1] -} - // Fake implementation of files. var helloFile = &FakeFile{ diff --git a/src/go/build/build.go b/src/go/build/build.go index 820434bc4a..1fd06b5d92 100644 --- a/src/go/build/build.go +++ b/src/go/build/build.go @@ -1391,20 +1391,11 @@ func IsLocalImport(path string) bool { strings.HasPrefix(path, "./") || strings.HasPrefix(path, "../") } -// ArchChar returns the architecture character for the given goarch. -// For example, ArchChar("amd64") returns "6". +// ArchChar returns "?" and an error. +// In earlier versions of Go, the returned string was used to derive +// the compiler and linker tool names, the default object file suffix, +// and the default linker output name. As of Go 1.5, those strings +// no longer vary by architecture; they are compile, link, .o, and a.out, respectively. func ArchChar(goarch string) (string, error) { - switch goarch { - case "386": - return "8", nil - case "amd64", "amd64p32": - return "6", nil - case "arm": - return "5", nil - case "arm64": - return "7", nil - case "ppc64", "ppc64le": - return "9", nil - } - return "", errors.New("unsupported GOARCH " + goarch) + return "", errors.New("architecture letter no longer used") } diff --git a/src/go/internal/gcimporter/gcimporter.go b/src/go/internal/gcimporter/gcimporter.go index ec71d793bd..7278c0c0a0 100644 --- a/src/go/internal/gcimporter/gcimporter.go +++ b/src/go/internal/gcimporter/gcimporter.go @@ -25,7 +25,7 @@ import ( // debugging/development support const debug = false -var pkgExts = [...]string{".a", ".5", ".6", ".7", ".8", ".9"} +var pkgExts = [...]string{".a", ".o"} // FindPkg returns the filename and unique package id for an import // path based on package information provided by build.Import (using diff --git a/src/go/internal/gcimporter/gcimporter_test.go b/src/go/internal/gcimporter/gcimporter_test.go index 5d4de39712..fe4a758cd4 100644 --- a/src/go/internal/gcimporter/gcimporter_test.go +++ b/src/go/internal/gcimporter/gcimporter_test.go @@ -50,9 +50,8 @@ func compile(t *testing.T, dirname, filename string) string { t.Logf("%s", out) t.Fatalf("%s %s failed: %s", gcPath, filename, err) } - archCh, _ := build.ArchChar(runtime.GOARCH) // filename should end with ".go" - return filepath.Join(dirname, filename[:len(filename)-2]+archCh) + return filepath.Join(dirname, filename[:len(filename)-2]+"o") } // Use the same global imports map for all tests. The effect is |
