summaryrefslogtreecommitdiffhomepage
path: root/tools/go_generics/go_merge
diff options
context:
space:
mode:
authorAdin Scannell <ascannell@google.com>2021-01-11 22:31:16 -0800
committergVisor bot <gvisor-bot@google.com>2021-01-11 22:33:36 -0800
commita20da708291e2e5bdece5176dce61c1b4b10b7d9 (patch)
tree1546859b6436ee1ad7dffa6b67849c67d2182ccf /tools/go_generics/go_merge
parente06c2b1264f5800730b93eff5c9913fd870025b9 (diff)
Fix Go branch for arm64.
This requires several changes: * Templates must preserve relevant tags. * Pagetables templates are split into two targets, each preserving tags. * The binary VDSO is similarly split into two targets, with some juggling. * The top level tools/go_branch.sh now does a crossbuild of ARM64 as well, and checks and merges the results of the two branches together. Fixes #5178 PiperOrigin-RevId: 351304330
Diffstat (limited to 'tools/go_generics/go_merge')
-rw-r--r--tools/go_generics/go_merge/BUILD3
-rw-r--r--tools/go_generics/go_merge/main.go19
2 files changed, 17 insertions, 5 deletions
diff --git a/tools/go_generics/go_merge/BUILD b/tools/go_generics/go_merge/BUILD
index 2fd5a200d..5e0487e93 100644
--- a/tools/go_generics/go_merge/BUILD
+++ b/tools/go_generics/go_merge/BUILD
@@ -6,4 +6,7 @@ go_binary(
name = "go_merge",
srcs = ["main.go"],
visibility = ["//:sandbox"],
+ deps = [
+ "//tools/tags",
+ ],
)
diff --git a/tools/go_generics/go_merge/main.go b/tools/go_generics/go_merge/main.go
index e0345500f..801f2354f 100644
--- a/tools/go_generics/go_merge/main.go
+++ b/tools/go_generics/go_merge/main.go
@@ -22,10 +22,12 @@ import (
"go/format"
"go/parser"
"go/token"
- "io/ioutil"
"os"
"path/filepath"
"strconv"
+ "strings"
+
+ "gvisor.dev/gvisor/tools/tags"
)
var (
@@ -132,10 +134,17 @@ func main() {
// Write the output file.
var buf bytes.Buffer
if err := format.Node(&buf, fset, f); err != nil {
- fatalf("%v\n", err)
+ fatalf("fomatting: %v\n", err)
}
-
- if err := ioutil.WriteFile(*output, buf.Bytes(), 0644); err != nil {
- fatalf("%v\n", err)
+ outf, err := os.OpenFile(*output, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
+ if err != nil {
+ fatalf("opening output: %v\n", err)
+ }
+ defer outf.Close()
+ if t := tags.Aggregate(flag.Args()); len(t) > 0 {
+ fmt.Fprintf(outf, "%s\n\n", strings.Join(t.Lines(), "\n"))
+ }
+ if _, err := outf.Write(buf.Bytes()); err != nil {
+ fatalf("write: %v\n", err)
}
}