Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions builder/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package builder
import (
"errors"
"fmt"
"os"
"os/exec"
"runtime"
"strings"
Expand Down Expand Up @@ -76,14 +75,3 @@ func LookupCommand(name string) (string, error) {
}
return "", errors.New("none of these commands were found in your $PATH: " + strings.Join(commands[name], " "))
}

func execCommand(name string, args ...string) error {
name, err := LookupCommand(name)
if err != nil {
return err
}
cmd := exec.Command(name, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}
25 changes: 19 additions & 6 deletions builder/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,29 @@ import (

// runCCompiler invokes a C compiler with the given arguments.
func runCCompiler(flags ...string) error {
// Find the right command to run Clang.
var cmd *exec.Cmd
if hasBuiltinTools {
// Compile this with the internal Clang compiler.
cmd := exec.Command(os.Args[0], append([]string{"clang"}, flags...)...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
cmd = exec.Command(os.Args[0], append([]string{"clang"}, flags...)...)
} else {
// Compile this with an external invocation of the Clang compiler.
name, err := LookupCommand("clang")
if err != nil {
return err
}
cmd = exec.Command(name, flags...)
}

// Compile this with an external invocation of the Clang compiler.
return execCommand("clang", flags...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

// Make sure the command doesn't use any environmental variables.
// Most importantly, it should not use C_INCLUDE_PATH and the like. But
// removing all environmental variables also works.
cmd.Env = []string{}

return cmd.Run()
}

// link invokes a linker with the given name and flags.
Expand Down