summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/allowlists/allowlists.go8
-rw-r--r--bp2build/testing.go17
-rw-r--r--cc/cc.go4
-rw-r--r--cc/config/riscv64_device.go4
-rw-r--r--cc/fuzz.go11
-rw-r--r--cc/linkable.go3
-rw-r--r--cc/lto_test.go22
-rw-r--r--cmd/soong_build/main.go3
-rw-r--r--genrule/allowlists.go1
-rw-r--r--genrule/genrule.go53
-rw-r--r--rust/fuzz_test.go66
-rw-r--r--rust/rust.go9
-rw-r--r--rust/sanitize.go3
13 files changed, 159 insertions, 45 deletions
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index 1ae2284b3..64e9958c6 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -1489,6 +1489,14 @@ var (
"libprotobuf-full-test", // TODO(b/246997908): cannot convert proto_libraries which implicitly include other srcs in the same directory
"libprotobuf-lite-test", // TODO(b/246997908): cannot convert proto_libraries which implicitly include other srcs in the same directory
+
+ "expresscatalogvalidator", // TODO(b/246997908): cannot convert proto_libraries which implicitly include other srcs in the same directory
+
+ // depends on other //art modules
+ "libart-for-test",
+ "libart_generated_headers",
+ "libart-runtime-gtest",
+ "libartd-runtime-gtest",
}
MixedBuildsDisabledList = []string{
diff --git a/bp2build/testing.go b/bp2build/testing.go
index fd99ff007..f3263a1b2 100644
--- a/bp2build/testing.go
+++ b/bp2build/testing.go
@@ -76,10 +76,19 @@ type Bp2buildTestCase struct {
Description string
ModuleTypeUnderTest string
ModuleTypeUnderTestFactory android.ModuleFactory
- Blueprint string
- ExpectedBazelTargets []string
- Filesystem map[string]string
- Dir string
+ // Text to add to the toplevel, root Android.bp file. If Dir is not set, all
+ // ExpectedBazelTargets are assumed to be generated by this file.
+ Blueprint string
+ // ExpectedBazelTargets compares the BazelTargets generated in `Dir` (if not empty).
+ // Otherwise, it checks the BazelTargets generated by `Blueprint` in the root directory.
+ ExpectedBazelTargets []string
+ Filesystem map[string]string
+ // Dir sets the directory which will be compared against the targets in ExpectedBazelTargets.
+ // This should used in conjunction with the Filesystem property to check for targets
+ // generated from a directory that is not the root.
+ // If not set, all ExpectedBazelTargets are assumed to be generated by the text in the
+ // Blueprint property.
+ Dir string
// An error with a string contained within the string of the expected error
ExpectedErr error
UnconvertedDepsMode unconvertedDepsMode
diff --git a/cc/cc.go b/cc/cc.go
index f2c852573..a7d6ff585 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1077,6 +1077,10 @@ func (c *Module) CcLibraryInterface() bool {
return false
}
+func (c *Module) RustLibraryInterface() bool {
+ return false
+}
+
func (c *Module) IsFuzzModule() bool {
if _, ok := c.compiler.(*fuzzBinary); ok {
return true
diff --git a/cc/config/riscv64_device.go b/cc/config/riscv64_device.go
index d66697c6b..77ee9774e 100644
--- a/cc/config/riscv64_device.go
+++ b/cc/config/riscv64_device.go
@@ -29,14 +29,14 @@ var (
// A temporary fix for SExtWRemoval miscompilation bug.
"-mllvm",
"-riscv-disable-sextw-removal=true",
- "-march=rv64gc_zbb",
+ "-march=rv64gc_zba_zbb",
}
riscv64ArchVariantCflags = map[string][]string{}
riscv64Ldflags = []string{
"-Wl,--hash-style=gnu",
- "-march=rv64gc_zbb",
+ "-march=rv64gc_zba_zbb",
}
riscv64Lldflags = append(riscv64Ldflags,
diff --git a/cc/fuzz.go b/cc/fuzz.go
index c897501e8..636ad855b 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -535,6 +535,17 @@ func CollectAllSharedDependencies(ctx android.ModuleContext) (android.RuleBuilde
})
ctx.WalkDeps(func(child, parent android.Module) bool {
+
+ // If this is a Rust module which is not rust_ffi_shared, we still want to bundle any transitive
+ // shared dependencies (even for rust_ffi_static)
+ if rustmod, ok := child.(LinkableInterface); ok && rustmod.RustLibraryInterface() && !rustmod.Shared() {
+ if recursed[ctx.OtherModuleName(child)] {
+ return false
+ }
+ recursed[ctx.OtherModuleName(child)] = true
+ return true
+ }
+
if !IsValidSharedDependency(child) {
return false
}
diff --git a/cc/linkable.go b/cc/linkable.go
index 557f5d2b3..976a38201 100644
--- a/cc/linkable.go
+++ b/cc/linkable.go
@@ -100,6 +100,9 @@ type LinkableInterface interface {
CcLibrary() bool
CcLibraryInterface() bool
+ // RustLibraryInterface returns true if this is a Rust library module
+ RustLibraryInterface() bool
+
// BaseModuleName returns the android.ModuleBase.BaseModuleName() value for this module.
BaseModuleName() string
diff --git a/cc/lto_test.go b/cc/lto_test.go
index 4220f3255..e0afd4a73 100644
--- a/cc/lto_test.go
+++ b/cc/lto_test.go
@@ -23,6 +23,12 @@ import (
"github.com/google/blueprint"
)
+var NoGlobalThinLTOPreparer = android.GroupFixturePreparers(
+ prepareForCcTest,
+ android.FixtureModifyEnv(func(env map[string]string) {
+ env["GLOBAL_THINLTO"] = "false"
+ }))
+
func TestThinLtoDeps(t *testing.T) {
t.Parallel()
bp := `
@@ -57,9 +63,7 @@ func TestThinLtoDeps(t *testing.T) {
}
`
- result := android.GroupFixturePreparers(
- prepareForCcTest,
- ).RunTestWithBp(t, bp)
+ result := NoGlobalThinLTOPreparer.RunTestWithBp(t, bp)
libLto := result.ModuleForTests("lto_enabled", "android_arm64_armv8-a_shared").Module()
@@ -137,9 +141,7 @@ func TestThinLtoOnlyOnStaticDep(t *testing.T) {
}
`
- result := android.GroupFixturePreparers(
- prepareForCcTest,
- ).RunTestWithBp(t, bp)
+ result := NoGlobalThinLTOPreparer.RunTestWithBp(t, bp)
libRoot := result.ModuleForTests("root", "android_arm64_armv8-a_shared").Module()
libRootLtoNever := result.ModuleForTests("root_no_lto", "android_arm64_armv8-a_shared").Module()
@@ -197,9 +199,7 @@ func TestLtoDisabledButEnabledForArch(t *testing.T) {
},
},
}`
- result := android.GroupFixturePreparers(
- prepareForCcTest,
- ).RunTestWithBp(t, bp)
+ result := NoGlobalThinLTOPreparer.RunTestWithBp(t, bp)
libFooWithLto := result.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Rule("ld")
libFooWithoutLto := result.ModuleForTests("libfoo", "android_arm64_armv8-a_shared").Rule("ld")
@@ -227,9 +227,7 @@ func TestLtoDoesNotPropagateToRuntimeLibs(t *testing.T) {
},
}`
- result := android.GroupFixturePreparers(
- prepareForCcTest,
- ).RunTestWithBp(t, bp)
+ result := NoGlobalThinLTOPreparer.RunTestWithBp(t, bp)
libFoo := result.ModuleForTests("libfoo", "android_arm_armv7-a-neon_shared").Rule("ld")
libBar := result.ModuleForTests("runtime_libbar", "android_arm_armv7-a-neon_shared").Rule("ld")
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index e903c0a94..d2eadbaec 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -817,6 +817,9 @@ func runBp2Build(ctx *android.Context, extraNinjaDeps []string, metricsDir strin
ctx.SetNameInterface(newNameResolver(ctx.Config()))
ctx.RegisterForBazelConversion()
ctx.SetModuleListFile(cmdlineArgs.ModuleListFile)
+ // Skip cloning modules during bp2build's blueprint run. Some mutators set
+ // bp2build-related module values which should be preserved during codegen.
+ ctx.SkipCloneModulesAfterMutators = true
var ninjaDeps []string
ninjaDeps = append(ninjaDeps, extraNinjaDeps...)
diff --git a/genrule/allowlists.go b/genrule/allowlists.go
index b0508cba5..46e3fb022 100644
--- a/genrule/allowlists.go
+++ b/genrule/allowlists.go
@@ -86,7 +86,6 @@ var (
"ltp_config_x86_64",
"vm-tests-tf-lib",
"hidl_cpp_impl_test_gen-headers",
- "pandora_experimental-python-gen-src",
"Refocus-rscript",
"RSTest_v11-rscript",
"RSTest_v16-rscript",
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 889bccd31..a7264ccea 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -24,7 +24,6 @@ import (
"path/filepath"
"strconv"
"strings"
- "sync"
"android/soong/bazel/cquery"
@@ -61,12 +60,6 @@ var PrepareForIntegrationTestWithGenrule = android.GroupFixturePreparers(
PrepareForTestWithGenRuleBuildComponents,
)
-var DepfileAllowSet map[string]bool
-var SandboxingDenyModuleSet map[string]bool
-var SandboxingDenyPathSet map[string]bool
-var SandboxingDenyModuleSetLock sync.Mutex
-var DepfileAllowSetLock sync.Mutex
-
func RegisterGenruleBuildComponents(ctx android.RegistrationContext) {
ctx.RegisterModuleType("genrule_defaults", defaultsFactory)
@@ -618,15 +611,10 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Allowlist genrule to use depfile until we have a solution to remove it.
// TODO(b/235582219): Remove allowlist for genrule
if Bool(g.properties.Depfile) {
- if DepfileAllowSet == nil {
- DepfileAllowSetLock.Lock()
- defer DepfileAllowSetLock.Unlock()
- DepfileAllowSet = map[string]bool{}
- android.AddToStringSet(DepfileAllowSet, DepfileAllowList)
- }
+ sandboxingAllowlistSets := getSandboxingAllowlistSets(ctx)
// TODO(b/283852474): Checking the GenruleSandboxing flag is temporary in
// order to pass the presubmit before internal master is updated.
- if ctx.DeviceConfig().GenruleSandboxing() && !DepfileAllowSet[g.Name()] {
+ if ctx.DeviceConfig().GenruleSandboxing() && !sandboxingAllowlistSets.depfileAllowSet[g.Name()] {
ctx.PropertyErrorf(
"depfile",
"Deprecated to ensure the module type is convertible to Bazel. "+
@@ -1067,20 +1055,37 @@ func DefaultsFactory(props ...interface{}) android.Module {
return module
}
+var sandboxingAllowlistKey = android.NewOnceKey("genruleSandboxingAllowlistKey")
+
+type sandboxingAllowlistSets struct {
+ sandboxingDenyModuleSet map[string]bool
+ sandboxingDenyPathSet map[string]bool
+ depfileAllowSet map[string]bool
+}
+
+func getSandboxingAllowlistSets(ctx android.PathContext) *sandboxingAllowlistSets {
+ return ctx.Config().Once(sandboxingAllowlistKey, func() interface{} {
+ sandboxingDenyModuleSet := map[string]bool{}
+ sandboxingDenyPathSet := map[string]bool{}
+ depfileAllowSet := map[string]bool{}
+
+ android.AddToStringSet(sandboxingDenyModuleSet, append(DepfileAllowList, SandboxingDenyModuleList...))
+ android.AddToStringSet(sandboxingDenyPathSet, SandboxingDenyPathList)
+ android.AddToStringSet(depfileAllowSet, DepfileAllowList)
+ return &sandboxingAllowlistSets{
+ sandboxingDenyModuleSet: sandboxingDenyModuleSet,
+ sandboxingDenyPathSet: sandboxingDenyPathSet,
+ depfileAllowSet: depfileAllowSet,
+ }
+ }).(*sandboxingAllowlistSets)
+}
func getSandboxedRuleBuilder(ctx android.ModuleContext, r *android.RuleBuilder) *android.RuleBuilder {
if !ctx.DeviceConfig().GenruleSandboxing() {
return r.SandboxTools()
}
- if SandboxingDenyModuleSet == nil {
- SandboxingDenyModuleSetLock.Lock()
- defer SandboxingDenyModuleSetLock.Unlock()
- SandboxingDenyModuleSet = map[string]bool{}
- SandboxingDenyPathSet = map[string]bool{}
- android.AddToStringSet(SandboxingDenyModuleSet, append(DepfileAllowList, SandboxingDenyModuleList...))
- android.AddToStringSet(SandboxingDenyPathSet, SandboxingDenyPathList)
- }
-
- if SandboxingDenyPathSet[ctx.ModuleDir()] || SandboxingDenyModuleSet[ctx.ModuleName()] {
+ sandboxingAllowlistSets := getSandboxingAllowlistSets(ctx)
+ if sandboxingAllowlistSets.sandboxingDenyPathSet[ctx.ModuleDir()] ||
+ sandboxingAllowlistSets.sandboxingDenyModuleSet[ctx.ModuleName()] {
return r.SandboxTools()
}
return r.SandboxInputs()
diff --git a/rust/fuzz_test.go b/rust/fuzz_test.go
index 7fa9f5c8f..0aecf617e 100644
--- a/rust/fuzz_test.go
+++ b/rust/fuzz_test.go
@@ -19,6 +19,7 @@ import (
"testing"
"android/soong/android"
+ "android/soong/cc"
)
func TestRustFuzz(t *testing.T) {
@@ -59,3 +60,68 @@ func TestRustFuzz(t *testing.T) {
t.Errorf("rust_fuzz dependent library does not contain the expected flags (sancov-module, cfg fuzzing).")
}
}
+
+func TestRustFuzzDepBundling(t *testing.T) {
+ ctx := testRust(t, `
+ cc_library {
+ name: "libcc_transitive_dep",
+ }
+ cc_library {
+ name: "libcc_direct_dep",
+ }
+ rust_library {
+ name: "libtest_fuzzing",
+ crate_name: "test_fuzzing",
+ srcs: ["foo.rs"],
+ shared_libs: ["libcc_transitive_dep"],
+ }
+ rust_fuzz {
+ name: "fuzz_libtest",
+ srcs: ["foo.rs"],
+ rustlibs: ["libtest_fuzzing"],
+ shared_libs: ["libcc_direct_dep"],
+ }
+ `)
+
+ fuzz_libtest := ctx.ModuleForTests("fuzz_libtest", "android_arm64_armv8-a_fuzzer").Module().(*Module)
+
+ if !strings.Contains(fuzz_libtest.FuzzSharedLibraries().String(), ":libcc_direct_dep.so") {
+ t.Errorf("rust_fuzz does not contain the expected bundled direct shared libs ('libcc_direct_dep'): %#v", fuzz_libtest.FuzzSharedLibraries().String())
+ }
+ if !strings.Contains(fuzz_libtest.FuzzSharedLibraries().String(), ":libcc_transitive_dep.so") {
+ t.Errorf("rust_fuzz does not contain the expected bundled transitive shared libs ('libcc_transitive_dep'): %#v", fuzz_libtest.FuzzSharedLibraries().String())
+ }
+}
+
+func TestCCFuzzDepBundling(t *testing.T) {
+ ctx := testRust(t, `
+ cc_library {
+ name: "libcc_transitive_dep",
+ }
+ rust_ffi {
+ name: "libtest_fuzzing",
+ crate_name: "test_fuzzing",
+ srcs: ["foo.rs"],
+ shared_libs: ["libcc_transitive_dep"],
+ }
+ cc_fuzz {
+ name: "fuzz_shared_libtest",
+ shared_libs: ["libtest_fuzzing"],
+ }
+ cc_fuzz {
+ name: "fuzz_static_libtest",
+ static_libs: ["libtest_fuzzing"],
+ }
+
+ `)
+
+ fuzz_shared_libtest := ctx.ModuleForTests("fuzz_shared_libtest", "android_arm64_armv8-a_fuzzer").Module().(cc.LinkableInterface)
+ fuzz_static_libtest := ctx.ModuleForTests("fuzz_static_libtest", "android_arm64_armv8-a_fuzzer").Module().(cc.LinkableInterface)
+
+ if !strings.Contains(fuzz_shared_libtest.FuzzSharedLibraries().String(), ":libcc_transitive_dep.so") {
+ t.Errorf("cc_fuzz does not contain the expected bundled transitive shared libs from rust_ffi_shared ('libcc_transitive_dep'): %#v", fuzz_shared_libtest.FuzzSharedLibraries().String())
+ }
+ if !strings.Contains(fuzz_static_libtest.FuzzSharedLibraries().String(), ":libcc_transitive_dep.so") {
+ t.Errorf("cc_fuzz does not contain the expected bundled transitive shared libs from rust_ffi_static ('libcc_transitive_dep'): %#v", fuzz_static_libtest.FuzzSharedLibraries().String())
+ }
+}
diff --git a/rust/rust.go b/rust/rust.go
index 4324ecbb9..e524c9fb6 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -631,6 +631,15 @@ func (mod *Module) CcLibraryInterface() bool {
return false
}
+func (mod *Module) RustLibraryInterface() bool {
+ if mod.compiler != nil {
+ if _, ok := mod.compiler.(libraryInterface); ok {
+ return true
+ }
+ }
+ return false
+}
+
func (mod *Module) IsFuzzModule() bool {
if _, ok := mod.compiler.(*fuzzDecorator); ok {
return true
diff --git a/rust/sanitize.go b/rust/sanitize.go
index 83cf05552..0f7cf6e5f 100644
--- a/rust/sanitize.go
+++ b/rust/sanitize.go
@@ -62,8 +62,7 @@ var fuzzerFlags = []string{
"-C llvm-args=-sanitizer-coverage-level=3",
"-C llvm-args=-sanitizer-coverage-trace-compares",
"-C llvm-args=-sanitizer-coverage-inline-8bit-counters",
- "-C llvm-args=-sanitizer-coverage-trace-geps",
- "-C llvm-args=-sanitizer-coverage-prune-blocks=0",
+ "-C llvm-args=-sanitizer-coverage-pc-table",
// See https://github.com/rust-fuzz/cargo-fuzz/pull/193
"-C link-dead-code",