builder: use builtin Clang when building statically

This will be a huge help for people installing TinyGo that don't have
LLVM/Clang 9 already installed and in the $PATH variable.
This commit is contained in:
Ayke van Laethem
2019-12-04 16:14:39 +01:00
committed by Ron Evans
parent 49eb414530
commit 8d32a7c3a3
10 changed files with 811 additions and 13 deletions
+2 -10
View File
@@ -154,11 +154,7 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(stri
for i, path := range config.ExtraFiles() {
abspath := filepath.Join(root, path)
outpath := filepath.Join(dir, "extra-"+strconv.Itoa(i)+"-"+filepath.Base(path)+".o")
cmdNames := []string{config.Target.Compiler}
if names, ok := commands[config.Target.Compiler]; ok {
cmdNames = names
}
err := execCommand(cmdNames, append(config.CFlags(), "-c", "-o", outpath, abspath)...)
err := runCCompiler(config.Target.Compiler, append(config.CFlags(), "-c", "-o", outpath, abspath)...)
if err != nil {
return &commandError{"failed to build", path, err}
}
@@ -170,11 +166,7 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(stri
for _, file := range pkg.CFiles {
path := filepath.Join(pkg.Package.Dir, file)
outpath := filepath.Join(dir, "pkg"+strconv.Itoa(i)+"-"+file+".o")
cmdNames := []string{config.Target.Compiler}
if names, ok := commands[config.Target.Compiler]; ok {
cmdNames = names
}
err := execCommand(cmdNames, append(config.CFlags(), "-c", "-o", outpath, path)...)
err := runCCompiler(config.Target.Compiler, append(config.CFlags(), "-c", "-o", outpath, path)...)
if err != nil {
return &commandError{"failed to build", path, err}
}