summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-go
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2014-11-27 00:15:21 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2014-11-27 00:15:21 +0000
commita4f0bd7857d549f3354329ec23c1c7cb3ed49f71 (patch)
treec145a16308d2db7581dd78ed27c2401b5984b1e2 /llvm/tools/llvm-go
parentbf6952c87a3f9828ef073f23d621f551679bad51 (diff)
downloadbcm5719-llvm-a4f0bd7857d549f3354329ec23c1c7cb3ed49f71.tar.gz
bcm5719-llvm-a4f0bd7857d549f3354329ec23c1c7cb3ed49f71.zip
Teach LLVM about llgo subproject.
llvm-svn: 222860
Diffstat (limited to 'llvm/tools/llvm-go')
-rw-r--r--llvm/tools/llvm-go/llvm-go.go35
1 files changed, 32 insertions, 3 deletions
diff --git a/llvm/tools/llvm-go/llvm-go.go b/llvm/tools/llvm-go/llvm-go.go
index 47f948150f0..cf520bd90e9 100644
--- a/llvm/tools/llvm-go/llvm-go.go
+++ b/llvm/tools/llvm-go/llvm-go.go
@@ -30,6 +30,7 @@ type pkg struct {
var packages = []pkg{
{"bindings/go/llvm", "llvm.org/llvm/bindings/go/llvm"},
+ {"tools/llgo", "llvm.org/llgo"},
}
type compilerFlags struct {
@@ -136,7 +137,7 @@ type (run_build_sh int)
`, flags.cpp, flags.cxx, flags.ld)
}
-func runGoWithLLVMEnv(args []string, cc, cxx, cppflags, cxxflags, ldflags string) {
+func runGoWithLLVMEnv(args []string, cc, cxx, llgo, cppflags, cxxflags, ldflags string) {
args = addTag(args, "byollvm")
srcdir := llvmConfig("--src-root")
@@ -159,6 +160,28 @@ func runGoWithLLVMEnv(args []string, cc, cxx, cppflags, cxxflags, ldflags string
}
}
+ newpath := os.Getenv("PATH")
+
+ if llgo != "" {
+ bindir := filepath.Join(tmpgopath, "bin")
+
+ err = os.MkdirAll(bindir, os.ModePerm)
+ if err != nil {
+ panic(err.Error())
+ }
+
+ err = os.Symlink(llgo, filepath.Join(bindir, "gccgo"))
+ if err != nil {
+ panic(err.Error())
+ }
+
+ newpathlist := []string{bindir}
+ newpathlist = append(newpathlist, filepath.SplitList(newpath)...)
+ newpath = strings.Join(newpathlist, string(filepath.ListSeparator))
+
+ args = append([]string{args[0], "-compiler", "gccgo"}, args[1:]...)
+ }
+
newgopathlist := []string{tmpgopath}
newgopathlist = append(newgopathlist, filepath.SplitList(os.Getenv("GOPATH"))...)
newgopath := strings.Join(newgopathlist, string(filepath.ListSeparator))
@@ -172,6 +195,7 @@ func runGoWithLLVMEnv(args []string, cc, cxx, cppflags, cxxflags, ldflags string
"CGO_CXXFLAGS=" + flags.cxx + " " + cxxflags,
"CGO_LDFLAGS=" + flags.ld + " " + ldflags,
"GOPATH=" + newgopath,
+ "PATH=" + newpath,
}
for _, v := range os.Environ() {
if !strings.HasPrefix(v, "CC=") &&
@@ -179,7 +203,8 @@ func runGoWithLLVMEnv(args []string, cc, cxx, cppflags, cxxflags, ldflags string
!strings.HasPrefix(v, "CGO_CPPFLAGS=") &&
!strings.HasPrefix(v, "CGO_CXXFLAGS=") &&
!strings.HasPrefix(v, "CGO_LDFLAGS=") &&
- !strings.HasPrefix(v, "GOPATH=") {
+ !strings.HasPrefix(v, "GOPATH=") &&
+ !strings.HasPrefix(v, "PATH=") {
newenv = append(newenv, v)
}
}
@@ -222,6 +247,7 @@ func main() {
cppflags := os.Getenv("CGO_CPPFLAGS")
cxxflags := os.Getenv("CGO_CXXFLAGS")
ldflags := os.Getenv("CGO_LDFLAGS")
+ llgo := ""
args := os.Args[1:]
DONE: for {
@@ -234,6 +260,9 @@ func main() {
case strings.HasPrefix(args[0], "cxx="):
cxx = args[0][4:]
args = args[1:]
+ case strings.HasPrefix(args[0], "llgo="):
+ llgo = args[0][5:]
+ args = args[1:]
case strings.HasPrefix(args[0], "cppflags="):
cppflags = args[0][9:]
args = args[1:]
@@ -250,7 +279,7 @@ func main() {
switch args[0] {
case "build", "get", "install", "run", "test":
- runGoWithLLVMEnv(args, cc, cxx, cppflags, cxxflags, ldflags)
+ runGoWithLLVMEnv(args, cc, cxx, llgo, cppflags, cxxflags, ldflags)
case "print-components":
printComponents()
case "print-config":
OpenPOWER on IntegriCloud