1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
13 * Helpers for building runtime.
16 // mkzversion writes zversion.go:
20 // (Nothing right now!)
21 func mkzversion(dir, file string) {
22 var buf strings.Builder
24 fmt.Fprintf(&buf, "package sys\n")
25 writefile(buf.String(), file, writeSkipSame)
28 // mkbuildcfg writes internal/buildcfg/zbootstrap.go:
32 // const defaultGOROOT = <goroot>
33 // const defaultGO386 = <go386>
35 // const defaultGOOS = runtime.GOOS
36 // const defaultGOARCH = runtime.GOARCH
38 // The use of runtime.GOOS and runtime.GOARCH makes sure that
39 // a cross-compiled compiler expects to compile for its own target
40 // system. That is, if on a Mac you do:
42 // GOOS=linux GOARCH=ppc64 go build cmd/compile
44 // the resulting compiler will default to generating linux/ppc64 object files.
45 // This is more useful than having it default to generating objects for the
46 // original target (in this example, a Mac).
47 func mkbuildcfg(file string) {
48 var buf strings.Builder
50 fmt.Fprintf(&buf, "package buildcfg\n")
52 fmt.Fprintf(&buf, "import \"runtime\"\n")
54 fmt.Fprintf(&buf, "const defaultGO386 = `%s`\n", go386)
55 fmt.Fprintf(&buf, "const defaultGOAMD64 = `%s`\n", goamd64)
56 fmt.Fprintf(&buf, "const defaultGOARM = `%s`\n", goarm)
57 fmt.Fprintf(&buf, "const defaultGOMIPS = `%s`\n", gomips)
58 fmt.Fprintf(&buf, "const defaultGOMIPS64 = `%s`\n", gomips64)
59 fmt.Fprintf(&buf, "const defaultGOPPC64 = `%s`\n", goppc64)
60 fmt.Fprintf(&buf, "const defaultGOEXPERIMENT = `%s`\n", goexperiment)
61 fmt.Fprintf(&buf, "const defaultGO_EXTLINK_ENABLED = `%s`\n", goextlinkenabled)
62 fmt.Fprintf(&buf, "const defaultGO_LDSO = `%s`\n", defaultldso)
63 fmt.Fprintf(&buf, "const version = `%s`\n", findgoversion())
64 fmt.Fprintf(&buf, "const defaultGOOS = runtime.GOOS\n")
65 fmt.Fprintf(&buf, "const defaultGOARCH = runtime.GOARCH\n")
67 writefile(buf.String(), file, writeSkipSame)
70 // mkobjabi writes cmd/internal/objabi/zbootstrap.go:
74 // (Nothing right now!)
75 func mkobjabi(file string) {
76 var buf strings.Builder
78 fmt.Fprintf(&buf, "package objabi\n")
80 writefile(buf.String(), file, writeSkipSame)