From 6c18d004f2717eb50b16cdb2df0fe10cee3d9655 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 2 Jun 2022 15:11:50 -0700 Subject: [PATCH] Pass -fno-sanitize=vptr,function for musl The prebuilts for musl have the necessary symbols for vptr and function sanitizers, but enabling them implicitly enables RTTI which causes RTTI mismatch issues with dependencies. Bug: 215802826 Test: m USE_HOST_MUSL=true host-native Change-Id: I93edfd617d99efcac0eca58bb3f3c173c4fa121a --- cc/sanitize.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cc/sanitize.go b/cc/sanitize.go index 8e0813ddd..86472a2cc 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -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") }