Merge changes I93edfd61,Icd23b542,I58c84607,Icfa73a75
* changes: Pass -fno-sanitize=vptr,function for musl Use musl rust prebuilts for USE_HOST_MUSL=true Don't package host cross modules in javaFuzzPackager Add rust musl arm and arm64 toolchains
This commit is contained in:
commit
4d2f767217
9 changed files with 192 additions and 12 deletions
|
@ -1825,7 +1825,9 @@ func getCommonTargets(targets []Target) []Target {
|
|||
for _, t := range targets {
|
||||
if _, found := set[t.Os.String()]; !found {
|
||||
set[t.Os.String()] = true
|
||||
ret = append(ret, commonTargetMap[t.Os.String()])
|
||||
common := commonTargetMap[t.Os.String()]
|
||||
common.HostCross = t.HostCross
|
||||
ret = append(ret, common)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -710,8 +710,13 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
|
|||
// Host sanitizers only link symbols in the final executable, so
|
||||
// there will always be undefined symbols in intermediate libraries.
|
||||
_, flags.Global.LdFlags = removeFromList("-Wl,--no-undefined", flags.Global.LdFlags)
|
||||
}
|
||||
|
||||
if !ctx.toolchain().Bionic() {
|
||||
// non-Bionic toolchain prebuilts are missing UBSan's vptr and function san.
|
||||
// Musl toolchain prebuilts have vptr and function sanitizers, but enabling them
|
||||
// implicitly enables RTTI which causes RTTI mismatch issues with dependencies.
|
||||
|
||||
// non-Bionic toolchain prebuilts are missing UBSan's vptr and function san
|
||||
flags.Local.CFlags = append(flags.Local.CFlags, "-fno-sanitize=vptr,function")
|
||||
}
|
||||
|
||||
|
|
|
@ -171,6 +171,10 @@ func (s *javaFuzzPackager) GenerateBuildActions(ctx android.SingletonContext) {
|
|||
return
|
||||
}
|
||||
|
||||
if javaFuzzModule.Target().HostCross {
|
||||
return
|
||||
}
|
||||
|
||||
fuzzModuleValidator := fuzz.FuzzModule{
|
||||
javaFuzzModule.ModuleBase,
|
||||
javaFuzzModule.DefaultableModuleBase,
|
||||
|
|
|
@ -41,10 +41,25 @@ var (
|
|||
|
||||
//TODO(b/160803703) Use a prebuilt bindgen instead of the built bindgen.
|
||||
_ = pctx.HostBinToolVariable("bindgenCmd", "bindgen")
|
||||
_ = pctx.VariableFunc("bindgenHostPrebuiltTag", func(ctx android.PackageVarContext) string {
|
||||
if ctx.Config().UseHostMusl() {
|
||||
// This is a hack to use the glibc bindgen binary until we have a musl version checked in.
|
||||
return "linux-x86"
|
||||
} else {
|
||||
return "${config.HostPrebuiltTag}"
|
||||
}
|
||||
})
|
||||
_ = pctx.VariableFunc("bindgenClangLibdir", func(ctx android.PackageVarContext) string {
|
||||
if ctx.Config().UseHostMusl() {
|
||||
return "musl/lib64/"
|
||||
} else {
|
||||
return "lib64/"
|
||||
}
|
||||
})
|
||||
_ = pctx.SourcePathVariable("bindgenClang",
|
||||
"${cc_config.ClangBase}/${config.HostPrebuiltTag}/${bindgenClangVersion}/bin/clang")
|
||||
"${cc_config.ClangBase}/${bindgenHostPrebuiltTag}/${bindgenClangVersion}/bin/clang")
|
||||
_ = pctx.SourcePathVariable("bindgenLibClang",
|
||||
"${cc_config.ClangBase}/${config.HostPrebuiltTag}/${bindgenClangVersion}/lib64/")
|
||||
"${cc_config.ClangBase}/${bindgenHostPrebuiltTag}/${bindgenClangVersion}/${bindgenClangLibdir}")
|
||||
|
||||
//TODO(ivanlozano) Switch this to RuleBuilder
|
||||
bindgen = pctx.AndroidStaticRule("bindgen",
|
||||
|
|
|
@ -372,7 +372,7 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
|
|||
if !Bool(compiler.Properties.No_stdlibs) {
|
||||
for _, stdlib := range config.Stdlibs {
|
||||
// If we're building for the build host, use the prebuilt stdlibs
|
||||
if ctx.Target().Os == android.Linux || ctx.Target().Os == android.Darwin {
|
||||
if ctx.Host() && !ctx.Target().HostCross {
|
||||
stdlib = "prebuilt_" + stdlib
|
||||
}
|
||||
deps.Stdlibs = append(deps.Stdlibs, stdlib)
|
||||
|
|
|
@ -11,6 +11,7 @@ bootstrap_go_package {
|
|||
],
|
||||
srcs: [
|
||||
"arm_device.go",
|
||||
"arm_linux_host.go",
|
||||
"arm64_device.go",
|
||||
"global.go",
|
||||
"lints.go",
|
||||
|
|
147
rust/config/arm_linux_host.go
Normal file
147
rust/config/arm_linux_host.go
Normal file
|
@ -0,0 +1,147 @@
|
|||
// Copyright 2022 Google Inc. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package config
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"android/soong/android"
|
||||
)
|
||||
|
||||
var (
|
||||
linuxArmRustflags = []string{}
|
||||
linuxArmLinkflags = []string{}
|
||||
linuxArm64Rustflags = []string{}
|
||||
linuxArm64Linkflags = []string{}
|
||||
)
|
||||
|
||||
func init() {
|
||||
registerToolchainFactory(android.LinuxMusl, android.Arm64, linuxMuslArm64ToolchainFactory)
|
||||
registerToolchainFactory(android.LinuxMusl, android.Arm, linuxMuslArmToolchainFactory)
|
||||
|
||||
pctx.StaticVariable("LinuxToolchainArmRustFlags", strings.Join(linuxArmRustflags, " "))
|
||||
pctx.StaticVariable("LinuxToolchainArmLinkFlags", strings.Join(linuxArmLinkflags, " "))
|
||||
pctx.StaticVariable("LinuxToolchainArm64RustFlags", strings.Join(linuxArm64Rustflags, " "))
|
||||
pctx.StaticVariable("LinuxToolchainArm64LinkFlags", strings.Join(linuxArm64Linkflags, " "))
|
||||
}
|
||||
|
||||
// Base 64-bit linux rust toolchain
|
||||
type toolchainLinuxArm64 struct {
|
||||
toolchain64Bit
|
||||
}
|
||||
|
||||
func (toolchainLinuxArm64) Supported() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (toolchainLinuxArm64) Bionic() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxArm64) Name() string {
|
||||
return "arm64"
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxArm64) ToolchainLinkFlags() string {
|
||||
// Prepend the lld flags from cc_config so we stay in sync with cc
|
||||
return "${cc_config.LinuxLldflags} ${cc_config.LinuxArm64Lldflags} " +
|
||||
"${config.LinuxToolchainLinkFlags} ${config.LinuxToolchainArm64LinkFlags}"
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxArm64) ToolchainRustFlags() string {
|
||||
return "${config.LinuxToolchainRustFlags} ${config.LinuxToolchainArm64RustFlags}"
|
||||
}
|
||||
|
||||
// Specialization of the 64-bit linux rust toolchain for musl. Adds the musl rust triple and
|
||||
// linker flags to avoid using the host sysroot.
|
||||
type toolchainLinuxMuslArm64 struct {
|
||||
toolchainLinuxArm64
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxMuslArm64) RustTriple() string {
|
||||
return "aarch64-unknown-linux-musl"
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxMuslArm64) ToolchainLinkFlags() string {
|
||||
return t.toolchainLinuxArm64.ToolchainLinkFlags() + " " + "${config.LinuxMuslToolchainLinkFlags}"
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxMuslArm64) ToolchainRustFlags() string {
|
||||
return t.toolchainLinuxArm64.ToolchainRustFlags() + " " + "${config.LinuxMuslToolchainRustFlags}"
|
||||
}
|
||||
|
||||
func linuxMuslArm64ToolchainFactory(arch android.Arch) Toolchain {
|
||||
return toolchainLinuxMuslArm64Singleton
|
||||
}
|
||||
|
||||
// Base 32-bit linux rust toolchain
|
||||
type toolchainLinuxArm struct {
|
||||
toolchain32Bit
|
||||
}
|
||||
|
||||
func (toolchainLinuxArm) Supported() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (toolchainLinuxArm) Bionic() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxArm) Name() string {
|
||||
return "arm"
|
||||
}
|
||||
|
||||
func (toolchainLinuxArm) LibclangRuntimeLibraryArch() string {
|
||||
return "arm"
|
||||
}
|
||||
|
||||
func (toolchainLinuxArm64) LibclangRuntimeLibraryArch() string {
|
||||
return "arm64"
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxArm) ToolchainLinkFlags() string {
|
||||
// Prepend the lld flags from cc_config so we stay in sync with cc
|
||||
return "${cc_config.LinuxLldflags} ${cc_config.LinuxArmLldflags} " +
|
||||
"${config.LinuxToolchainLinkFlags} ${config.LinuxToolchainArmLinkFlags}"
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxArm) ToolchainRustFlags() string {
|
||||
return "${config.LinuxToolchainRustFlags} ${config.LinuxToolchainArmRustFlags}"
|
||||
}
|
||||
|
||||
// Specialization of the 32-bit linux rust toolchain for musl. Adds the musl rust triple and
|
||||
// linker flags to avoid using the host sysroot.
|
||||
type toolchainLinuxMuslArm struct {
|
||||
toolchainLinuxArm
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxMuslArm) RustTriple() string {
|
||||
return "arm-unknown-linux-musleabihf"
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxMuslArm) ToolchainLinkFlags() string {
|
||||
return t.toolchainLinuxArm.ToolchainLinkFlags() + " " + "${config.LinuxMuslToolchainLinkFlags}"
|
||||
}
|
||||
|
||||
func (t *toolchainLinuxMuslArm) ToolchainRustFlags() string {
|
||||
return t.toolchainLinuxArm.ToolchainRustFlags() + " " + "${config.LinuxMuslToolchainRustFlags}"
|
||||
}
|
||||
|
||||
func linuxMuslArmToolchainFactory(arch android.Arch) Toolchain {
|
||||
return toolchainLinuxMuslArmSingleton
|
||||
}
|
||||
|
||||
var toolchainLinuxMuslArm64Singleton Toolchain = &toolchainLinuxMuslArm64{}
|
||||
var toolchainLinuxMuslArmSingleton Toolchain = &toolchainLinuxMuslArm{}
|
|
@ -78,7 +78,13 @@ var (
|
|||
|
||||
func init() {
|
||||
pctx.SourcePathVariable("RustDefaultBase", RustDefaultBase)
|
||||
pctx.VariableConfigMethod("HostPrebuiltTag", android.Config.PrebuiltOS)
|
||||
pctx.VariableConfigMethod("HostPrebuiltTag", func(config android.Config) string {
|
||||
if config.UseHostMusl() {
|
||||
return "linux-musl-x86"
|
||||
} else {
|
||||
return config.PrebuiltOS()
|
||||
}
|
||||
})
|
||||
|
||||
pctx.VariableFunc("RustBase", func(ctx android.PackageVarContext) string {
|
||||
if override := ctx.Config().Getenv("RUST_PREBUILTS_BASE"); override != "" {
|
||||
|
|
|
@ -174,7 +174,7 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
|
|||
}
|
||||
|
||||
// Enable Memtag for all components in the include paths (for Aarch64 only)
|
||||
if ctx.Arch().ArchType == android.Arm64 {
|
||||
if ctx.Arch().ArchType == android.Arm64 && ctx.Os().Bionic() {
|
||||
if ctx.Config().MemtagHeapSyncEnabledForPath(ctx.ModuleDir()) {
|
||||
if s.Memtag_heap == nil {
|
||||
s.Memtag_heap = proptools.BoolPtr(true)
|
||||
|
@ -200,7 +200,7 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
|
|||
}
|
||||
|
||||
// HWASan requires AArch64 hardware feature (top-byte-ignore).
|
||||
if ctx.Arch().ArchType != android.Arm64 {
|
||||
if ctx.Arch().ArchType != android.Arm64 || !ctx.Os().Bionic() {
|
||||
s.Hwaddress = nil
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
|
|||
}
|
||||
|
||||
// Memtag_heap is only implemented on AArch64.
|
||||
if ctx.Arch().ArchType != android.Arm64 {
|
||||
if ctx.Arch().ArchType != android.Arm64 || !ctx.Os().Bionic() {
|
||||
s.Memtag_heap = nil
|
||||
}
|
||||
|
||||
|
@ -234,7 +234,7 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags, deps PathDeps) (
|
|||
}
|
||||
if Bool(sanitize.Properties.Sanitize.Fuzzer) {
|
||||
flags.RustFlags = append(flags.RustFlags, fuzzerFlags...)
|
||||
if ctx.Arch().ArchType == android.Arm64 {
|
||||
if ctx.Arch().ArchType == android.Arm64 && ctx.Os().Bionic() {
|
||||
flags.RustFlags = append(flags.RustFlags, hwasanFlags...)
|
||||
} else {
|
||||
flags.RustFlags = append(flags.RustFlags, asanFlags...)
|
||||
|
@ -282,13 +282,13 @@ func rustSanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
|
|||
var deps []string
|
||||
|
||||
if mod.IsSanitizerEnabled(cc.Asan) ||
|
||||
(mod.IsSanitizerEnabled(cc.Fuzzer) && mctx.Arch().ArchType != android.Arm64) {
|
||||
(mod.IsSanitizerEnabled(cc.Fuzzer) && (mctx.Arch().ArchType != android.Arm64 || !mctx.Os().Bionic())) {
|
||||
variations = append(variations,
|
||||
blueprint.Variation{Mutator: "link", Variation: "shared"})
|
||||
depTag = cc.SharedDepTag()
|
||||
deps = []string{config.LibclangRuntimeLibrary(mod.toolchain(mctx), "asan")}
|
||||
} else if mod.IsSanitizerEnabled(cc.Hwasan) ||
|
||||
(mod.IsSanitizerEnabled(cc.Fuzzer) && mctx.Arch().ArchType == android.Arm64) {
|
||||
(mod.IsSanitizerEnabled(cc.Fuzzer) && mctx.Arch().ArchType == android.Arm64 && mctx.Os().Bionic()) {
|
||||
// TODO(b/204776996): HWASan for static Rust binaries isn't supported yet.
|
||||
if binary, ok := mod.compiler.(binaryInterface); ok {
|
||||
if binary.staticallyLinked() {
|
||||
|
|
Loading…
Reference in a new issue