From 3567e62f97b48c495f43b1d95f35ed80d8485e95 Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Thu, 15 Nov 2018 14:01:36 -0800 Subject: [PATCH] Switch to clang-r346389. * Add -fno-sanitize=implicit-integer-sign-change when there is any integer related sanitizer, and this check is not explicitly specified. Android core does not boot with this new sanitizer yet. * Filter out -fno-sanitize=implicit-integer-sign-change from tooling flags. Bug: 119329758 Bug: 119557795 Test: make checkbuild, boot, go/clang-r346389-testing Change-Id: I709de569cb73d070fc4958e2b4387f4041bc5438 --- cc/config/clang.go | 4 +++- cc/config/global.go | 4 ++-- cc/sanitize.go | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/cc/config/clang.go b/cc/config/clang.go index 89e567dcb..46d852880 100644 --- a/cc/config/clang.go +++ b/cc/config/clang.go @@ -91,7 +91,9 @@ var ClangUnknownLldflags = sorted([]string{ "-Wl,-m,aarch64_elf64_le_vec", }) -var ClangLibToolingUnknownCflags []string = nil +var ClangLibToolingUnknownCflags = sorted([]string{ + "-fno-sanitize=implicit-integer-sign-change", +}) func init() { pctx.StaticVariable("ClangExtraCflags", strings.Join([]string{ diff --git a/cc/config/global.go b/cc/config/global.go index 31f64fe60..92969b0b7 100644 --- a/cc/config/global.go +++ b/cc/config/global.go @@ -120,8 +120,8 @@ var ( // prebuilts/clang default settings. ClangDefaultBase = "prebuilts/clang/host" - ClangDefaultVersion = "clang-r344140b" - ClangDefaultShortVersion = "8.0.4" + ClangDefaultVersion = "clang-r346389" + ClangDefaultShortVersion = "8.0.5" // Directories with warnings from Android.bp files. WarningAllowedProjects = []string{ diff --git a/cc/sanitize.go b/cc/sanitize.go index 56013b61d..08c672cca 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -376,6 +376,22 @@ func (sanitize *sanitize) deps(ctx BaseModuleContext, deps Deps) Deps { return deps } +func toDisableImplicitIntegerChange(flags []string) bool { + // Returns true if any flag is fsanitize*integer, and there is + // no explicit flag about sanitize=implicit-integer-sign-change. + for _, f := range flags { + if strings.Contains(f, "sanitize=implicit-integer-sign-change") { + return false + } + } + for _, f := range flags { + if strings.HasPrefix(f, "-fsanitize") && strings.Contains(f, "integer") { + return true + } + } + return false +} + func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { minimalRuntimeLib := config.UndefinedBehaviorSanitizerMinimalRuntimeLibrary(ctx.toolchain()) + ".a" minimalRuntimePath := "${config.ClangAsanLibDir}/" + minimalRuntimeLib @@ -533,6 +549,10 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { flags.LdFlags = append(flags.LdFlags, "-Wl,--exclude-libs,"+minimalRuntimeLib) } } + // http://b/119329758, Android core does not boot up with this sanitizer yet. + if toDisableImplicitIntegerChange(flags.CFlags) { + flags.CFlags = append(flags.CFlags, "-fno-sanitize=implicit-integer-sign-change") + } } if len(diagSanitizers) > 0 {