Merge changes from topic "musl_clang_runtimes" am: 0f2a718ce4 am: e3f28d26a6 am: c068a7d423
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1980450
Change-Id: I45f717f96780715af04c0c4eef61bd4db763cc63
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 3cf8b58..814fef6 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -480,8 +480,8 @@
s.Diag.Cfi = nil
}
- // Disable sanitizers that depend on the UBSan runtime for windows/darwin/musl builds.
- if !ctx.Os().Linux() || ctx.Os() == android.LinuxMusl {
+ // Disable sanitizers that depend on the UBSan runtime for windows/darwin builds.
+ if !ctx.Os().Linux() {
s.Cfi = nil
s.Diag.Cfi = nil
s.Misc_undefined = nil
@@ -490,6 +490,12 @@
s.Integer_overflow = nil
}
+ // Disable CFI for musl
+ if ctx.toolchain().Musl() {
+ s.Cfi = nil
+ s.Diag.Cfi = nil
+ }
+
// Also disable CFI for VNDK variants of components
if ctx.isVndk() && ctx.useVndk() {
if ctx.static() {
@@ -702,10 +708,10 @@
flags.Local.AsFlags = append(flags.Local.AsFlags, sanitizeArg)
flags.Local.LdFlags = append(flags.Local.LdFlags, sanitizeArg)
- if ctx.toolchain().Bionic() {
- // Bionic sanitizer runtimes have already been added as dependencies so that
- // the right variant of the runtime will be used (with the "-android"
- // suffix), so don't let clang the runtime library.
+ if ctx.toolchain().Bionic() || ctx.toolchain().Musl() {
+ // Bionic and musl sanitizer runtimes have already been added as dependencies so that
+ // the right variant of the runtime will be used (with the "-android" or "-musl"
+ // suffixes), so don't let clang the runtime library.
flags.Local.LdFlags = append(flags.Local.LdFlags, "-fno-sanitize-link-runtime")
} else {
// Host sanitizers only link symbols in the final executable, so
@@ -1217,7 +1223,7 @@
addStaticDeps(config.BuiltinsRuntimeLibrary(toolchain))
}
- if runtimeLibrary != "" && (toolchain.Bionic() || c.sanitize.Properties.UbsanRuntimeDep) {
+ if runtimeLibrary != "" && (toolchain.Bionic() || toolchain.Musl() || c.sanitize.Properties.UbsanRuntimeDep) {
// UBSan is supported on non-bionic linux host builds as well
// Adding dependency to the runtime library. We are using *FarVariation*