DivestOS/Patches/LineageOS-18.1/android_build_soong/0001-Enable_fwrapv.patch
Tad 898c040ead More useless churn
Signed-off-by: Tad <tad@spotco.us>
2021-11-01 21:04:59 -04:00

50 lines
1.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Daniel Micay <danielmicay@gmail.com>
Date: Wed, 23 Aug 2017 20:28:03 -0400
Subject: [PATCH] use -fwrapv when signed overflow checking is off
---
cc/cc.go | 2 ++
cc/sanitize.go | 12 ++++++++++++
2 files changed, 14 insertions(+)
diff --git a/cc/cc.go b/cc/cc.go
index 31b381a9d..4ca8e847a 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1478,6 +1478,8 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
}
if c.sanitize != nil {
flags = c.sanitize.flags(ctx, flags)
+ } else {
+ flags.Local.CFlags = append(flags.Local.CFlags, "-fwrapv")
}
if c.coverage != nil {
flags, deps = c.coverage.flags(ctx, flags, deps)
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 463a02ac2..7c92b41dc 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -458,9 +458,21 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
}
if !sanitize.Properties.SanitizerEnabled && !sanitize.Properties.UbsanRuntimeDep {
+ flags.Local.CFlags = append(flags.Local.CFlags, "-fwrapv")
return flags
}
+ wrapv := true
+ for _, element := range sanitize.Properties.Sanitizers {
+ if (element == "signed-integer-overflow" || element == "integer" || element == "undefined") {
+ wrapv = false
+ break
+ }
+ }
+ if wrapv {
+ flags.Local.CFlags = append(flags.Local.CFlags, "-fwrapv")
+ }
+
if Bool(sanitize.Properties.Sanitize.Address) {
if ctx.Arch().ArchType == android.Arm {
// Frame pointer based unwinder in ASan requires ARM frame setup.