...

Source file src/cmd/compile/main.go

Documentation: cmd/compile

     1  // Copyright 2015 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.
     4  
     5  package main
     6  
     7  import (
     8  	"cmd/compile/internal/amd64"
     9  	"cmd/compile/internal/arm"
    10  	"cmd/compile/internal/arm64"
    11  	"cmd/compile/internal/base"
    12  	"cmd/compile/internal/gc"
    13  	"cmd/compile/internal/loong64"
    14  	"cmd/compile/internal/mips"
    15  	"cmd/compile/internal/mips64"
    16  	"cmd/compile/internal/ppc64"
    17  	"cmd/compile/internal/riscv64"
    18  	"cmd/compile/internal/s390x"
    19  	"cmd/compile/internal/ssagen"
    20  	"cmd/compile/internal/wasm"
    21  	"cmd/compile/internal/x86"
    22  	"fmt"
    23  	"internal/buildcfg"
    24  	"log"
    25  	"os"
    26  )
    27  
    28  var archInits = map[string]func(*ssagen.ArchInfo){
    29  	"386":      x86.Init,
    30  	"amd64":    amd64.Init,
    31  	"arm":      arm.Init,
    32  	"arm64":    arm64.Init,
    33  	"loong64":  loong64.Init,
    34  	"mips":     mips.Init,
    35  	"mipsle":   mips.Init,
    36  	"mips64":   mips64.Init,
    37  	"mips64le": mips64.Init,
    38  	"ppc64":    ppc64.Init,
    39  	"ppc64le":  ppc64.Init,
    40  	"riscv64":  riscv64.Init,
    41  	"s390x":    s390x.Init,
    42  	"wasm":     wasm.Init,
    43  }
    44  
    45  func main() {
    46  	// disable timestamps for reproducible output
    47  	log.SetFlags(0)
    48  	log.SetPrefix("compile: ")
    49  
    50  	buildcfg.Check()
    51  	archInit, ok := archInits[buildcfg.GOARCH]
    52  	if !ok {
    53  		fmt.Fprintf(os.Stderr, "compile: unknown architecture %q\n", buildcfg.GOARCH)
    54  		os.Exit(2)
    55  	}
    56  
    57  	gc.Main(archInit)
    58  	base.Exit(0)
    59  }
    60  

View as plain text