@@ -107,6 +107,13 @@ var (
107107 Tags : "ziren" ,
108108 Env : map [string ]string {"GOMIPS" : "softfloat" , "CGO_ENABLED" : "0" },
109109 },
110+ {
111+ Name : "tamago" ,
112+ GOOS : "tamago" ,
113+ GOARCH : "riscv64" ,
114+ Tags : "tamago" ,
115+ Env : map [string ]string {"CGO_ENABLED" : "0" },
116+ },
110117 {
111118 Name : "wasm-js" ,
112119 GOOS : "js" ,
@@ -281,16 +288,37 @@ func doInstallKeeper(cmdline []string) {
281288 flag .CommandLine .Parse (cmdline )
282289 env := build .Env ()
283290
284- // Configure the toolchain.
291+ var (
292+ csdb * download.ChecksumDB
293+ tamagoRoot string
294+ )
285295 tc := build.GoToolchain {}
286296 if * dlgo {
287- csdb := download .MustLoadChecksums ("build/checksums.txt" )
288- tc .Root = build .DownloadGo (csdb )
297+ csdb = download .MustLoadChecksums ("build/checksums.txt" )
289298 }
290299
291300 for _ , target := range keeperTargets {
292301 log .Printf ("Building keeper-%s" , target .Name )
293302
303+ // Configure the toolchain.
304+ if target .Name == "tamago" {
305+ if runtime .GOOS != "linux" {
306+ log .Printf ("Skipping keeper-%s (tamago builds are only supported on linux hosts)" , target .Name )
307+ continue
308+ }
309+ if ! * dlgo {
310+ log .Printf ("Skipping keeper-%s (tamago build requires -dlgo)" , target .Name )
311+ continue
312+ }
313+
314+ if tamagoRoot == "" {
315+ tamagoRoot = downloadTamago (csdb )
316+ }
317+ tc .Root = tamagoRoot
318+ } else if * dlgo {
319+ tc .Root = build .DownloadGo (csdb )
320+ }
321+
294322 // Configure the build.
295323 tc .GOARCH = target .GOARCH
296324 tc .GOOS = target .GOOS
@@ -447,6 +475,42 @@ func downloadSpecTestFixtures(csdb *download.ChecksumDB, cachedir string) string
447475 return filepath .Join (cachedir , base )
448476}
449477
478+ // downloadTamago downloads the tamago-go toolchain and returns its GOROOT.
479+ func downloadTamago (csdb * download.ChecksumDB ) string {
480+ version , err := csdb .FindVersion ("tamago" )
481+ if err != nil {
482+ log .Fatal (err )
483+ }
484+ if runtime .GOOS != "linux" {
485+ log .Printf ("Skipping tamago toolchain download (unsupported host os: %s)" , runtime .GOOS )
486+ return ""
487+ }
488+ arch := runtime .GOARCH
489+ if arch == "arm" {
490+ arch = "armv7l"
491+ }
492+ file := fmt .Sprintf ("tamago-go%s.%s-%s.tar.gz" , version , runtime .GOOS , arch )
493+
494+ ucache , err := os .UserCacheDir ()
495+ if err != nil {
496+ log .Fatal (err )
497+ }
498+ dst := filepath .Join (ucache , file )
499+ if err := csdb .DownloadFileFromKnownURL (dst ); err != nil {
500+ log .Fatal (err )
501+ }
502+
503+ toolRoot := filepath .Join (ucache , fmt .Sprintf ("geth-tamago-go-%s-%s-%s" , version , runtime .GOOS , arch ))
504+ if err := build .ExtractArchive (dst , toolRoot ); err != nil {
505+ log .Fatal (err )
506+ }
507+ goroot , err := filepath .Abs (filepath .Join (toolRoot , "go" ))
508+ if err != nil {
509+ log .Fatal (err )
510+ }
511+ return goroot
512+ }
513+
450514// doCheckGenerate ensures that re-generating generated files does not cause
451515// any mutations in the source file tree.
452516func doCheckGenerate () {
0 commit comments