From 3ede294729a87be8fd33b8b3179691e9454260df Mon Sep 17 00:00:00 2001 From: Chih-Hung Hsieh Date: Wed, 10 Jan 2018 14:30:44 -0800 Subject: [PATCH] Switch to clang 7.0 * Suppress more noisy new warnings at global level. * Add -no-pie to partial link .o files, with -r. * Revert workaround of b/72706604, no need of -Wl,-plugin-opt,-emulated-tls * Filter out clang 7.0 unknown flag "-Wno-extended-offsetof" Bug: 72706604 Bug: 72412006 Test: make checkbuild Change-Id: I7ff45465c4bd771991f42b40f68dc35586045656 --- cc/builder.go | 4 +++- cc/config/clang.go | 8 ++++++++ cc/config/global.go | 4 ++-- cc/lto.go | 6 ------ cc/sanitize.go | 6 ------ 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/cc/builder.go b/cc/builder.go index 754391566..53ef69c47 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -67,7 +67,9 @@ var ( partialLd = pctx.AndroidStaticRule("partialLd", blueprint.RuleParams{ - Command: "$ldCmd -nostdlib -Wl,-r ${in} -o ${out} ${ldFlags}", + // Without -no-pie, clang 7.0 adds -pie to link Android files, + // but -r and -pie cannot be used together. + Command: "$ldCmd -nostdlib -no-pie -Wl,-r ${in} -o ${out} ${ldFlags}", CommandDeps: []string{"$ldCmd"}, }, "ldCmd", "ldFlags") diff --git a/cc/config/clang.go b/cc/config/clang.go index 7de6f063d..46d6fe227 100644 --- a/cc/config/clang.go +++ b/cc/config/clang.go @@ -36,6 +36,7 @@ var ClangUnknownCflags = sorted([]string{ "-Wno-error=maybe-uninitialized", "-Wno-error=unused-but-set-parameter", "-Wno-error=unused-but-set-variable", + "-Wno-extended-offsetof", "-Wno-free-nonheap-object", "-Wno-literal-suffix", "-Wno-maybe-uninitialized", @@ -116,6 +117,10 @@ func init() { // http://b/68236239 Allow 0/NULL instead of using nullptr everywhere. "-Wno-zero-as-null-pointer-constant", + + // Warnings from clang-7.0 + "-Wno-deprecated-register", + "-Wno-sign-compare", }, " ")) pctx.StaticVariable("ClangExtraCppflags", strings.Join([]string{ @@ -151,6 +156,9 @@ func init() { // http://b/72331526 Disable -Wtautological-* until the instances detected by these // new warnings are fixed. "-Wno-tautological-constant-compare", + "-Wno-tautological-type-limit-compare", + "-Wno-tautological-unsigned-enum-zero-compare", + "-Wno-tautological-unsigned-zero-compare", // http://b/72331524 Allow null pointer arithmetic until the instances detected by // this new warning are fixed. diff --git a/cc/config/global.go b/cc/config/global.go index 359ea8c5a..989c7ee08 100644 --- a/cc/config/global.go +++ b/cc/config/global.go @@ -116,8 +116,8 @@ var ( // prebuilts/clang default settings. ClangDefaultBase = "prebuilts/clang/host" - ClangDefaultVersion = "clang-4639204" - ClangDefaultShortVersion = "6.0.1" + ClangDefaultVersion = "clang-4679922" + ClangDefaultShortVersion = "7.0.1" // Directories with warnings from Android.bp files. WarningAllowedProjects = []string{ diff --git a/cc/lto.go b/cc/lto.go index d7526e285..85057cf48 100644 --- a/cc/lto.go +++ b/cc/lto.go @@ -95,12 +95,6 @@ func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags { flags.LdFlags = append(flags.LdFlags, cachePolicyFormat+policy) } - if ctx.Device() { - // Work around bug in Clang that doesn't pass correct emulated - // TLS option to target. See b/72706604 or - // https://github.com/android-ndk/ndk/issues/498. - flags.LdFlags = append(flags.LdFlags, "-Wl,-plugin-opt,-emulated-tls") - } flags.ArGoldPlugin = true // If the module does not have a profile, be conservative and do not inline diff --git a/cc/sanitize.go b/cc/sanitize.go index 535d28ff8..981d92c73 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -407,12 +407,6 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { flags.CFlags = append(flags.CFlags, "-fvisibility=default") } flags.LdFlags = append(flags.LdFlags, cfiLdflags...) - if ctx.Device() { - // Work around a bug in Clang. The CFI sanitizer requires LTO, and when - // LTO is enabled, the Clang driver fails to enable emutls for Android. - // See b/72706604 or https://github.com/android-ndk/ndk/issues/498. - flags.LdFlags = append(flags.LdFlags, "-Wl,-plugin-opt,-emulated-tls") - } flags.ArGoldPlugin = true if Bool(sanitize.Properties.Sanitize.Diag.Cfi) { diagSanitizers = append(diagSanitizers, "cfi")