Do not add non-existing -Bprebuilts/gcc/.../bin

* Only prebuilts/gcc/linux-x86/host/x86_64-w64-mingw32-4.8/x86_64-w64-mingw32/bin
  exists for x86_windows_host.
* Remove config.ToolPath;
  add required -B flags into ToolchainCflags and ToolchainLdflags.

Bug: 218883919
Test: make droid tidy-soong_subset
Change-Id: I9a18bf8cc0cf84e091c7463b3bda316eaab53aa3
This commit is contained in:
Chih-Hung Hsieh 2022-02-15 22:48:04 -08:00
parent ec76c2f072
commit 57da82697a
6 changed files with 18 additions and 25 deletions

View file

@ -3943,7 +3943,6 @@ func TestIncludeDirectoryOrdering(t *testing.T) {
"${config.ArmGenericCflags}",
"-target",
"armv7a-linux-androideabi20",
"-B${config.ArmGccRoot}/arm-linux-androideabi/bin",
}
expectedIncludes := []string{

View file

@ -450,11 +450,9 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
}
}
gccPrefix := "-B" + config.ToolPath(tc)
flags.Global.CFlags = append(flags.Global.CFlags, target, gccPrefix)
flags.Global.AsFlags = append(flags.Global.AsFlags, target, gccPrefix)
flags.Global.LdFlags = append(flags.Global.LdFlags, target, gccPrefix)
flags.Global.CFlags = append(flags.Global.CFlags, target)
flags.Global.AsFlags = append(flags.Global.AsFlags, target)
flags.Global.LdFlags = append(flags.Global.LdFlags, target)
hod := "Host"
if ctx.Os().Class == android.Device {

View file

@ -258,8 +258,12 @@ func (t *toolchainDarwin) AvailableLibraries() []string {
return darwinAvailableLibraries
}
func (t *toolchainDarwin) ToolPath() string {
return "${config.MacToolPath}"
func (t *toolchainDarwin) ToolchainCflags() string {
return "-B${config.MacToolPath}"
}
func (t *toolchainDarwin) ToolchainLdflags() string {
return "-B${config.MacToolPath}"
}
var toolchainDarwinArmSingleton Toolchain = &toolchainDarwinArm{}

View file

@ -16,7 +16,6 @@ package config
import (
"fmt"
"path/filepath"
"android/soong/android"
)
@ -77,7 +76,6 @@ type Toolchain interface {
GccTriple() string
// GccVersion should return a real value, not a ninja reference
GccVersion() string
ToolPath() string
IncludeFlags() string
@ -198,10 +196,6 @@ func (toolchainBase) Musl() bool {
return false
}
func (t toolchainBase) ToolPath() string {
return ""
}
type toolchain64Bit struct {
toolchainBase
}
@ -283,11 +277,4 @@ func LibFuzzerRuntimeLibrary(t Toolchain) string {
return LibclangRuntimeLibrary(t, "fuzzer")
}
func ToolPath(t Toolchain) string {
if p := t.ToolPath(); p != "" {
return p
}
return filepath.Join(t.GccRoot(), t.GccTriple(), "bin")
}
var inList = android.InList

View file

@ -15,6 +15,7 @@
package config
import (
"path/filepath"
"strings"
"android/soong/android"
@ -180,6 +181,14 @@ func (t *toolchainWindows) GccTriple() string {
return "${config.WindowsGccTriple}"
}
func (t *toolchainWindows) ToolchainCflags() string {
return "-B" + filepath.Join(t.GccRoot(), t.GccTriple(), "bin")
}
func (t *toolchainWindows) ToolchainLdflags() string {
return "-B" + filepath.Join(t.GccRoot(), t.GccTriple(), "bin")
}
func (t *toolchainWindows) GccVersion() string {
return windowsGccVersion
}

View file

@ -227,7 +227,6 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
}
clangPrefix := secondPrefix + "CLANG_" + typePrefix
clangExtras := "-B" + config.ToolPath(toolchain)
ctx.Strict(clangPrefix+"TRIPLE", toolchain.ClangTriple())
ctx.Strict(clangPrefix+"GLOBAL_CFLAGS", strings.Join([]string{
@ -235,7 +234,6 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
"${config.CommonGlobalCflags}",
fmt.Sprintf("${config.%sGlobalCflags}", hod),
toolchain.ToolchainCflags(),
clangExtras,
productExtraCflags,
}, " "))
ctx.Strict(clangPrefix+"GLOBAL_CPPFLAGS", strings.Join([]string{
@ -248,14 +246,12 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
toolchain.Ldflags(),
toolchain.ToolchainLdflags(),
productExtraLdflags,
clangExtras,
}, " "))
ctx.Strict(clangPrefix+"GLOBAL_LLDFLAGS", strings.Join([]string{
fmt.Sprintf("${config.%sGlobalLldflags}", hod),
toolchain.Lldflags(),
toolchain.ToolchainLdflags(),
productExtraLdflags,
clangExtras,
}, " "))
if target.Os.Class == android.Device {