Always use the standard OSX SDK tools
Instead of whatever happens to be in PATH. Test: port install gcc5; attempt to build host binaries Change-Id: If4af32596edd6fd3e459c3d574ab0ff495f236ff
This commit is contained in:
@@ -262,10 +262,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
|
||||
flags.LdFlags = config.ClangFilterUnknownCflags(flags.LdFlags)
|
||||
|
||||
target := "-target " + tc.ClangTriple()
|
||||
var gccPrefix string
|
||||
if !ctx.Darwin() {
|
||||
gccPrefix = "-B" + filepath.Join(tc.GccRoot(), tc.GccTriple(), "bin")
|
||||
}
|
||||
gccPrefix := "-B" + config.ToolPath(tc)
|
||||
|
||||
flags.CFlags = append(flags.CFlags, target, gccPrefix)
|
||||
flags.AsFlags = append(flags.AsFlags, target, gccPrefix)
|
||||
|
@@ -16,6 +16,7 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"android/soong/android"
|
||||
)
|
||||
@@ -47,6 +48,7 @@ type Toolchain interface {
|
||||
GccTriple() string
|
||||
// GccVersion should return a real value, not a ninja reference
|
||||
GccVersion() string
|
||||
ToolPath() string
|
||||
|
||||
ToolchainCflags() string
|
||||
ToolchainLdflags() string
|
||||
@@ -145,6 +147,10 @@ func (toolchainBase) Bionic() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (t toolchainBase) ToolPath() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type toolchain64Bit struct {
|
||||
toolchainBase
|
||||
}
|
||||
@@ -216,3 +222,10 @@ func UndefinedBehaviorSanitizerRuntimeLibrary(t Toolchain) string {
|
||||
}
|
||||
return "libclang_rt.ubsan_standalone-" + arch + "-android.so"
|
||||
}
|
||||
|
||||
func ToolPath(t Toolchain) string {
|
||||
if p := t.ToolPath(); p != "" {
|
||||
return p
|
||||
}
|
||||
return filepath.Join(t.GccRoot(), t.GccTriple(), "bin")
|
||||
}
|
||||
|
@@ -17,6 +17,7 @@ package config
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"android/soong/android"
|
||||
@@ -131,6 +132,11 @@ func init() {
|
||||
return strings.TrimSpace(string(bytes)), err
|
||||
})
|
||||
|
||||
pctx.VariableFunc("MacToolPath", func(config interface{}) (string, error) {
|
||||
bytes, err := exec.Command("xcrun", "--find", "ld").Output()
|
||||
return filepath.Dir(strings.TrimSpace(string(bytes))), err
|
||||
})
|
||||
|
||||
pctx.StaticVariable("DarwinGccVersion", darwinGccVersion)
|
||||
pctx.SourcePathVariable("DarwinGccRoot",
|
||||
"prebuilts/gcc/${HostPrebuiltTag}/host/i686-apple-darwin-${DarwinGccVersion}")
|
||||
@@ -276,6 +282,10 @@ func (t *toolchainDarwin) Bionic() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (t *toolchainDarwin) ToolPath() string {
|
||||
return "${config.MacToolPath}"
|
||||
}
|
||||
|
||||
var toolchainDarwinX86Singleton Toolchain = &toolchainDarwinX86{}
|
||||
var toolchainDarwinX8664Singleton Toolchain = &toolchainDarwinX8664{}
|
||||
|
||||
|
@@ -16,7 +16,6 @@ package cc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
@@ -186,9 +185,7 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
|
||||
if toolchain.ClangSupported() {
|
||||
clangPrefix := secondPrefix + "CLANG_" + typePrefix
|
||||
clangExtras := "-target " + toolchain.ClangTriple()
|
||||
if target.Os != android.Darwin {
|
||||
clangExtras += " -B" + filepath.Join(toolchain.GccRoot(), toolchain.GccTriple(), "bin")
|
||||
}
|
||||
clangExtras += " -B" + config.ToolPath(toolchain)
|
||||
|
||||
ctx.Strict(clangPrefix+"GLOBAL_CFLAGS", strings.Join([]string{
|
||||
toolchain.ClangCflags(),
|
||||
|
Reference in New Issue
Block a user