github.com/llvm-mirror/llgo@v0.0.0-20190322182713-bf6f0a60fce1/cmd/cgo/zdefaultcc.go (about) 1 //===- zdefaultcc.go - default compiler locations -------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file provides a default location for cc. 10 // 11 //===----------------------------------------------------------------------===// 12 13 package main 14 15 import ( 16 "path/filepath" 17 "os" 18 "os/exec" 19 ) 20 21 var defaultCC string 22 23 func getInstPrefix() (string, error) { 24 path, err := exec.LookPath(os.Args[0]) 25 if err != nil { 26 return "", err 27 } 28 29 path, err = filepath.EvalSymlinks(path) 30 if err != nil { 31 return "", err 32 } 33 34 prefix := filepath.Join(path, "..", "..", "..", "..") 35 return prefix, nil 36 } 37 38 func init() { 39 prefix, err := getInstPrefix() 40 if err != nil { 41 panic(err.Error()) 42 } 43 44 defaultCC = filepath.Join(prefix, "bin", "clang") 45 }