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
diff --git a/cc/builder.go b/cc/builder.go
index 7543915..53ef69c 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -67,7 +67,9 @@
 
 	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 7de6f06..46d6fe2 100644
--- a/cc/config/clang.go
+++ b/cc/config/clang.go
@@ -36,6 +36,7 @@
 	"-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 @@
 
 		// 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 @@
 		// 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 359ea8c..989c7ee 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -116,8 +116,8 @@
 
 	// 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 d7526e2..85057cf 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -95,12 +95,6 @@
 			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 535d28f..981d92c 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -407,12 +407,6 @@
 			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")