github.com/prattmic/llgo-embedded@v0.0.0-20150820070356-41cfecea0e1e/cmd/go/zdefaultcc.go.in (about) 1 //===- zdefaultcc.go - default compiler locations -------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // This file provides default locations for cc, cxx and llgo. 11 // 12 //===----------------------------------------------------------------------===// 13 14 package main 15 16 import ( 17 "path/filepath" 18 "os" 19 "os/exec" 20 ) 21 22 var defaultGCCGO, defaultCC, defaultCXX string 23 24 func getInstPrefix() (string, error) { 25 path, err := exec.LookPath(os.Args[0]) 26 if err != nil { 27 return "", err 28 } 29 30 path, err = filepath.EvalSymlinks(path) 31 if err != nil { 32 return "", err 33 } 34 35 prefix := filepath.Join(path, "..", "..") 36 return prefix, nil 37 } 38 39 func init() { 40 prefix, err := getInstPrefix() 41 if err != nil { 42 panic(err.Error()) 43 } 44 45 defaultCC = filepath.Join(prefix, "bin", "clang") 46 defaultCXX = filepath.Join(prefix, "bin", "clang++") 47 defaultGCCGO = filepath.Join(prefix, "bin", "llgo") 48 toolDir = filepath.Join(prefix, "lib", "go", "llgo-@LLGO_VERSION@") 49 50 gccgoName = os.Getenv("GCCGO") 51 if gccgoName == "" { 52 gccgoName = defaultGCCGO 53 } 54 gccgoBin, _ = exec.LookPath(gccgoName) 55 }