DivestOS/Patches/LineageOS-16.0/android_build_soong/0001-Enable_fwrapv.patch
Tad a9f445ad47 16.0: add land and santoni
Signed-off-by: Tad <tad@spotco.us>
2021-10-28 19:07:31 -04:00

54 lines
1.6 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 51ac18404..2829dab32 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -687,6 +687,8 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
}
if c.sanitize != nil {
flags = c.sanitize.flags(ctx, flags)
+ } else {
+ flags.CFlags = append(flags.CFlags, "-fwrapv")
}
if c.coverage != nil {
flags = c.coverage.flags(ctx, flags)
diff --git a/cc/sanitize.go b/cc/sanitize.go
index de970352e..17c11f8b1 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -314,6 +314,7 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
flags.LdFlags = append(flags.LdFlags, "-Wl,--exclude-libs,"+minimalRuntimeLib)
}
if !sanitize.Properties.SanitizerEnabled {
+ flags.CFlags = append(flags.CFlags, "-fwrapv")
return flags
}
@@ -355,6 +356,17 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
sanitizers = append(sanitizers, sanitize.Properties.Sanitize.Misc_undefined...)
}
+ wrapv := true
+ for _, element := range sanitizers {
+ if (element == "signed-integer-overflow" || element == "integer" || element == "undefined") {
+ wrapv = false
+ break
+ }
+ }
+ if wrapv {
+ flags.CFlags = append(flags.CFlags, "-fwrapv")
+ }
+
if Bool(sanitize.Properties.Sanitize.Diag.Undefined) {
diagSanitizers = append(diagSanitizers, "undefined")
}