diff options
Diffstat (limited to 'cc')
-rw-r--r-- | cc/coverage.go | 6 | ||||
-rw-r--r-- | cc/prebuilt.go | 31 | ||||
-rw-r--r-- | cc/prebuilt_test.go | 24 | ||||
-rw-r--r-- | cc/sanitize.go | 5 | ||||
-rw-r--r-- | cc/strip.go | 4 |
5 files changed, 63 insertions, 7 deletions
diff --git a/cc/coverage.go b/cc/coverage.go index d0902eab8..a7356f879 100644 --- a/cc/coverage.go +++ b/cc/coverage.go @@ -108,6 +108,12 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags if EnableContinuousCoverage(ctx) { flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-mllvm", "-runtime-counter-relocation") } + + // http://b/248022906, http://b/247941801 enabling coverage and hwasan-globals + // instrumentation together causes duplicate-symbol errors for __llvm_profile_filename. + if c, ok := ctx.Module().(*Module); ok && c.sanitize.isSanitizerEnabled(Hwasan) { + flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-mllvm", "-hwasan-globals=0") + } } } diff --git a/cc/prebuilt.go b/cc/prebuilt.go index 68df87981..3756810bc 100644 --- a/cc/prebuilt.go +++ b/cc/prebuilt.go @@ -674,9 +674,15 @@ func PrebuiltBinaryFactory() android.Module { return module.Init() } +type prebuiltBinaryBazelHandler struct { + module *Module + decorator *binaryDecorator +} + func NewPrebuiltBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator) { - module, binary := newBinary(hod, false) + module, binary := newBinary(hod, true) module.compiler = nil + module.bazelHandler = &prebuiltBinaryBazelHandler{module, binary} prebuilt := &prebuiltBinaryLinker{ binaryDecorator: binary, @@ -690,6 +696,29 @@ func NewPrebuiltBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecor return module, binary } +var _ BazelHandler = (*prebuiltBinaryBazelHandler)(nil) + +func (h *prebuiltBinaryBazelHandler) QueueBazelCall(ctx android.BaseModuleContext, label string) { + bazelCtx := ctx.Config().BazelContext + bazelCtx.QueueBazelRequest(label, cquery.GetOutputFiles, android.GetConfigKey(ctx)) +} + +func (h *prebuiltBinaryBazelHandler) ProcessBazelQueryResponse(ctx android.ModuleContext, label string) { + bazelCtx := ctx.Config().BazelContext + outputs, err := bazelCtx.GetOutputFiles(label, android.GetConfigKey(ctx)) + if err != nil { + ctx.ModuleErrorf(err.Error()) + return + } + if len(outputs) != 1 { + ctx.ModuleErrorf("Expected a single output for `%s`, but got:\n%v", label, outputs) + return + } + out := android.PathForBazelOut(ctx, outputs[0]) + h.module.outputFile = android.OptionalPathForPath(out) + h.module.maybeUnhideFromMake() +} + type bazelPrebuiltBinaryAttributes struct { Src bazel.LabelAttribute Strip stripAttributes diff --git a/cc/prebuilt_test.go b/cc/prebuilt_test.go index 53cf7818d..95fa99e43 100644 --- a/cc/prebuilt_test.go +++ b/cc/prebuilt_test.go @@ -683,3 +683,27 @@ cc_prebuilt_binary { }` testCcError(t, `Android.bp:4:6: module "bintest" variant "android_arm64_armv8-a": srcs: multiple prebuilt source files`, bp) } + +func TestPrebuiltBinaryWithBazel(t *testing.T) { + const bp = ` +cc_prebuilt_binary { + name: "bintest", + srcs: ["bin"], + bazel_module: { label: "//bin/foo:foo" }, +}` + const outBaseDir = "outputbase" + const expectedOut = outBaseDir + "/execroot/__main__/bin" + config := TestConfig(t.TempDir(), android.Android, nil, bp, nil) + config.BazelContext = android.MockBazelContext{ + OutputBaseDir: outBaseDir, + LabelToOutputFiles: map[string][]string{"//bin/foo:foo": []string{"bin"}}, + } + ctx := testCcWithConfig(t, config) + bin := ctx.ModuleForTests("bintest", "android_arm64_armv8-a").Module().(*Module) + out := bin.OutputFile() + if !out.Valid() { + t.Error("Invalid output file") + return + } + android.AssertStringEquals(t, "output file", expectedOut, out.String()) +} diff --git a/cc/sanitize.go b/cc/sanitize.go index 66dfef57b..0b47f0e6d 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -564,11 +564,6 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) { s.Scudo = nil } - if Bool(s.Undefined) || Bool(s.All_undefined) || len(s.Misc_undefined) > 0 { - // TODO(b/251249010): re-enable Hwaddress with UBSan once fixed. - s.Hwaddress = nil - } - if Bool(s.Hwaddress) { s.Address = nil s.Thread = nil diff --git a/cc/strip.go b/cc/strip.go index c60e13530..5c32d8b04 100644 --- a/cc/strip.go +++ b/cc/strip.go @@ -56,7 +56,9 @@ func (stripper *Stripper) NeedsStrip(actx android.ModuleContext) bool { forceEnable := Bool(stripper.StripProperties.Strip.All) || Bool(stripper.StripProperties.Strip.Keep_symbols) || Bool(stripper.StripProperties.Strip.Keep_symbols_and_debug_frame) - return !forceDisable && (forceEnable || defaultEnable) + // create_minidebuginfo doesn't work for riscv64 yet, disable stripping for now + riscv64 := actx.Arch().ArchType == android.Riscv64 + return !forceDisable && (forceEnable || defaultEnable) && !riscv64 } // Keep this consistent with //build/bazel/rules/stripped_shared_library.bzl. |