[PlaceSafepoints] Remove dependence on LoopSimplify
[oota-llvm.git] / tools / llvm-go / llvm-go.go
index 70d91d83893923e46cd9f00f2a30333058343f20..c5c3fd244cadfd553f7720d95b1d52b3a49c5069 100644 (file)
@@ -137,7 +137,7 @@ type (run_build_sh int)
 `, flags.cpp, flags.cxx, flags.ld)
 }
 
-func runGoWithLLVMEnv(args []string, cc, cxx, llgo, cppflags, cxxflags, ldflags string) {
+func runGoWithLLVMEnv(args []string, cc, cxx, gocmd, llgo, cppflags, cxxflags, ldflags string) {
        args = addTag(args, "byollvm")
 
        srcdir := llvmConfig("--src-root")
@@ -162,26 +162,6 @@ func runGoWithLLVMEnv(args []string, cc, cxx, llgo, cppflags, cxxflags, ldflags
 
        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))
@@ -197,24 +177,29 @@ func runGoWithLLVMEnv(args []string, cc, cxx, llgo, cppflags, cxxflags, ldflags
                "GOPATH=" + newgopath,
                "PATH=" + newpath,
        }
+       if llgo != "" {
+               newenv = append(newenv, "GCCGO=" + llgo)
+       }
+
        for _, v := range os.Environ() {
                if !strings.HasPrefix(v, "CC=") &&
                        !strings.HasPrefix(v, "CXX=") &&
                        !strings.HasPrefix(v, "CGO_CPPFLAGS=") &&
                        !strings.HasPrefix(v, "CGO_CXXFLAGS=") &&
                        !strings.HasPrefix(v, "CGO_LDFLAGS=") &&
+                       !strings.HasPrefix(v, "GCCGO=") &&
                        !strings.HasPrefix(v, "GOPATH=") &&
                        !strings.HasPrefix(v, "PATH=") {
                        newenv = append(newenv, v)
                }
        }
 
-       gocmdpath, err := exec.LookPath("go")
+       gocmdpath, err := exec.LookPath(gocmd)
        if err != nil {
                panic(err.Error())
        }
 
-       proc, err := os.StartProcess(gocmdpath, append([]string{"go"}, args...),
+       proc, err := os.StartProcess(gocmdpath, append([]string{gocmd}, args...),
                &os.ProcAttr{
                        Env:   newenv,
                        Files: []*os.File{os.Stdin, os.Stdout, os.Stderr},
@@ -247,6 +232,7 @@ func main() {
        cppflags := os.Getenv("CGO_CPPFLAGS")
        cxxflags := os.Getenv("CGO_CXXFLAGS")
        ldflags := os.Getenv("CGO_LDFLAGS")
+       gocmd := "go"
        llgo := ""
 
        args := os.Args[1:]
@@ -260,6 +246,9 @@ func main() {
                case strings.HasPrefix(args[0], "cxx="):
                        cxx = args[0][4:]
                        args = args[1:]
+               case strings.HasPrefix(args[0], "go="):
+                       gocmd = args[0][3:]
+                       args = args[1:]
                case strings.HasPrefix(args[0], "llgo="):
                        llgo = args[0][5:]
                        args = args[1:]
@@ -279,7 +268,7 @@ func main() {
 
        switch args[0] {
        case "build", "get", "install", "run", "test":
-               runGoWithLLVMEnv(args, cc, cxx, llgo, cppflags, cxxflags, ldflags)
+               runGoWithLLVMEnv(args, cc, cxx, gocmd, llgo, cppflags, cxxflags, ldflags)
        case "print-components":
                printComponents()
        case "print-config":