aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cc/builder.go8
-rw-r--r--cc/cc.go37
-rw-r--r--cc/clang.go7
-rw-r--r--cc/gen.go43
-rw-r--r--cc/x86_darwin_host.go4
-rw-r--r--cc/x86_linux_host.go16
-rw-r--r--common/androidmk.go3
-rw-r--r--common/config.go2
-rwxr-xr-xsoong.bash2
9 files changed, 81 insertions, 41 deletions
diff --git a/cc/builder.go b/cc/builder.go
index 98f66d9f..bcfbb6ee 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -149,6 +149,14 @@ func TransformSourceToObj(ctx common.AndroidModuleContext, subdir string, srcFil
cppflags := flags.globalFlags + " " + flags.cFlags + " " + flags.cppFlags
asflags := flags.globalFlags + " " + flags.asFlags
+ if flags.clang {
+ cflags += " ${noOverrideClangGlobalCflags}"
+ cppflags += " ${noOverrideClangGlobalCflags}"
+ } else {
+ cflags += " ${noOverrideGlobalCflags}"
+ cppflags += " ${noOverrideGlobalCflags}"
+ }
+
for i, srcFile := range srcFiles {
objFile := common.ObjPathWithExt(ctx, srcFile, subdir, "o")
diff --git a/cc/cc.go b/cc/cc.go
index 6cff27f8..d79cdbee 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -94,6 +94,7 @@ var (
"-Werror=non-virtual-dtor",
"-Werror=address",
"-Werror=sequence-point",
+ "-Werror=date-time",
}
hostGlobalCflags = []string{}
@@ -102,6 +103,11 @@ var (
"-Wsign-promo",
}
+ noOverrideGlobalCflags = []string{
+ "-Werror=int-to-pointer-cast",
+ "-Werror=pointer-to-int-cast",
+ }
+
illegalFlags = []string{
"-w",
}
@@ -111,6 +117,7 @@ func init() {
pctx.StaticVariable("commonGlobalCflags", strings.Join(commonGlobalCflags, " "))
pctx.StaticVariable("deviceGlobalCflags", strings.Join(deviceGlobalCflags, " "))
pctx.StaticVariable("hostGlobalCflags", strings.Join(hostGlobalCflags, " "))
+ pctx.StaticVariable("noOverrideGlobalCflags", strings.Join(noOverrideGlobalCflags, " "))
pctx.StaticVariable("commonGlobalCppflags", strings.Join(commonGlobalCppflags, " "))
@@ -120,6 +127,9 @@ func init() {
strings.Join(append(clangFilterUnknownCflags(deviceGlobalCflags), "${clangExtraTargetCflags}"), " "))
pctx.StaticVariable("hostClangGlobalCflags",
strings.Join(clangFilterUnknownCflags(hostGlobalCflags), " "))
+ pctx.StaticVariable("noOverrideClangGlobalCflags",
+ strings.Join(append(clangFilterUnknownCflags(noOverrideGlobalCflags), "${clangExtraNoOverrideCflags}"), " "))
+
pctx.StaticVariable("commonClangGlobalCppflags",
strings.Join(append(clangFilterUnknownCflags(commonGlobalCppflags), "${clangExtraCppflags}"), " "))
@@ -128,6 +138,7 @@ func init() {
pctx.PrefixedPathsForOptionalSourceVariable("commonGlobalIncludes", "-isystem ",
[]string{
"system/core/include",
+ "system/media/audio/include",
"hardware/libhardware/include",
"hardware/libhardware_legacy/include",
"hardware/ril/include",
@@ -142,7 +153,7 @@ func init() {
pctx.PrefixedPathsForOptionalSourceVariable("commonNativehelperInclude", "-I",
[]string{"libnativehelper/include/nativehelper"})
- pctx.SourcePathVariable("clangPath", "prebuilts/clang/host/${HostPrebuiltTag}/3.8/bin")
+ pctx.SourcePathVariable("clangPath", "prebuilts/clang/host/${HostPrebuiltTag}/clang-2629532/bin")
}
type CCModuleContext common.AndroidBaseContext
@@ -632,6 +643,22 @@ func (c *CCBase) collectFlags(ctx common.AndroidModuleContext, toolchain Toolcha
flags.CppFlags, _ = filterList(flags.CppFlags, illegalFlags)
flags.ConlyFlags, _ = filterList(flags.ConlyFlags, illegalFlags)
+ // We can enforce some rules more strictly in the code we own. strict
+ // indicates if this is code that we can be stricter with. If we have
+ // rules that we want to apply to *our* code (but maybe can't for
+ // vendor/device specific things), we could extend this to be a ternary
+ // value.
+ strict := true
+ if strings.HasPrefix(common.PathForModuleSrc(ctx).String(), "external/") {
+ strict = false
+ }
+
+ // Can be used to make some annotations stricter for code we can fix
+ // (such as when we mark functions as deprecated).
+ if strict {
+ flags.CFlags = append(flags.CFlags, "-DANDROID_STRICT")
+ }
+
// Optimization to reduce size of build.ninja
// Replace the long list of flags for each file with a module-local variable
ctx.Variable(pctx, "cflags", strings.Join(flags.CFlags, " "))
@@ -911,7 +938,7 @@ func (c *CCLinked) flags(ctx common.AndroidModuleContext, flags CCFlags) CCFlags
if ctx.Host() {
flags.CppFlags = append(flags.CppFlags, "-nostdinc++")
flags.LdFlags = append(flags.LdFlags, "-nodefaultlibs")
- flags.LdFlags = append(flags.LdFlags, "-lm", "-lpthread")
+ flags.LdFlags = append(flags.LdFlags, "-lpthread", "-lm")
if c.staticBinary() {
flags.LdFlags = append(flags.LdFlags, hostStaticGccLibs[ctx.HostType()]...)
} else {
@@ -1221,7 +1248,10 @@ func (c *CCLibrary) flags(ctx common.AndroidModuleContext, flags CCFlags) CCFlag
sharedFlag = "-shared"
}
if ctx.Device() {
- flags.LdFlags = append(flags.LdFlags, "-nostdlib")
+ flags.LdFlags = append(flags.LdFlags,
+ "-nostdlib",
+ "-Wl,--gc-sections",
+ )
}
if ctx.Darwin() {
@@ -1233,7 +1263,6 @@ func (c *CCLibrary) flags(ctx common.AndroidModuleContext, flags CCFlags) CCFlag
)
} else {
flags.LdFlags = append(flags.LdFlags,
- "-Wl,--gc-sections",
sharedFlag,
"-Wl,-soname,"+libName+flags.Toolchain.ShlibSuffix(),
)
diff --git a/cc/clang.go b/cc/clang.go
index 5e0302a5..f4c29f01 100644
--- a/cc/clang.go
+++ b/cc/clang.go
@@ -31,7 +31,6 @@ var clangUnknownCflags = sorted([]string{
"-Wunused-but-set-parameter",
"-Wunused-but-set-variable",
"-fdiagnostics-color",
- "-fdebug-prefix-map=/proc/self/cwd=",
// arm + arm64 + mips + mips64
"-fgcse-after-reload",
@@ -102,6 +101,12 @@ func init() {
pctx.StaticVariable("clangExtraTargetCflags", strings.Join([]string{
"-nostdlibinc",
}, " "))
+
+ pctx.StaticVariable("clangExtraNoOverrideCflags", strings.Join([]string{
+ "-Werror=address-of-temporary",
+ "-Werror=null-dereference",
+ "-Werror=return-type",
+ }, " "))
}
func clangFilterUnknownCflags(cflags []string) []string {
diff --git a/cc/gen.go b/cc/gen.go
index 035f40ed..94e2304c 100644
--- a/cc/gen.go
+++ b/cc/gen.go
@@ -33,12 +33,11 @@ func init() {
var (
yacc = pctx.StaticRule("yacc",
blueprint.RuleParams{
- Command: "BISON_PKGDATADIR=$yaccDataDir $yaccCmd -d $yaccFlags -o $cppFile $in && " +
- "cp -f $hppFile $hFile",
+ Command: "BISON_PKGDATADIR=$yaccDataDir $yaccCmd -d $yaccFlags --defines=$hFile -o $cFile $in",
CommandDeps: []string{"$yaccCmd"},
Description: "yacc $out",
},
- "yaccFlags", "cppFile", "hppFile", "hFile")
+ "yaccFlags", "cFile", "hFile")
lex = pctx.StaticRule("lex",
blueprint.RuleParams{
@@ -48,36 +47,29 @@ var (
})
)
-func genYacc(ctx common.AndroidModuleContext, yaccFile common.Path, yaccFlags string) (cppFile, headerFile common.ModuleGenPath) {
- cppFile = common.GenPathWithExt(ctx, yaccFile, "cpp")
- hppFile := common.GenPathWithExt(ctx, yaccFile, "hpp")
+func genYacc(ctx common.AndroidModuleContext, yaccFile common.Path, outFile common.ModuleGenPath, yaccFlags string) (headerFile common.ModuleGenPath) {
headerFile = common.GenPathWithExt(ctx, yaccFile, "h")
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
Rule: yacc,
- Outputs: common.WritablePaths{cppFile, headerFile},
+ Outputs: common.WritablePaths{outFile, headerFile},
Input: yaccFile,
Args: map[string]string{
"yaccFlags": yaccFlags,
- "cppFile": cppFile.String(),
- "hppFile": hppFile.String(),
+ "cFile": outFile.String(),
"hFile": headerFile.String(),
},
})
- return cppFile, headerFile
+ return headerFile
}
-func genLex(ctx common.AndroidModuleContext, lexFile common.Path) (cppFile common.ModuleGenPath) {
- cppFile = common.GenPathWithExt(ctx, lexFile, "cpp")
-
+func genLex(ctx common.AndroidModuleContext, lexFile common.Path, outFile common.ModuleGenPath) {
ctx.ModuleBuild(pctx, common.ModuleBuildParams{
Rule: lex,
- Output: cppFile,
+ Output: outFile,
Input: lexFile,
})
-
- return cppFile
}
func genSources(ctx common.AndroidModuleContext, srcFiles common.Paths,
@@ -87,13 +79,22 @@ func genSources(ctx common.AndroidModuleContext, srcFiles common.Paths,
for i, srcFile := range srcFiles {
switch srcFile.Ext() {
- case ".y", ".yy":
- cppFile, headerFile := genYacc(ctx, srcFile, buildFlags.yaccFlags)
+ case ".y":
+ cFile := common.GenPathWithExt(ctx, srcFile, "c")
+ srcFiles[i] = cFile
+ deps = append(deps, genYacc(ctx, srcFile, cFile, buildFlags.yaccFlags))
+ case ".yy":
+ cppFile := common.GenPathWithExt(ctx, srcFile, "cpp")
srcFiles[i] = cppFile
- deps = append(deps, headerFile)
- case ".l", ".ll":
- cppFile := genLex(ctx, srcFile)
+ deps = append(deps, genYacc(ctx, srcFile, cppFile, buildFlags.yaccFlags))
+ case ".l":
+ cFile := common.GenPathWithExt(ctx, srcFile, "c")
+ srcFiles[i] = cFile
+ genLex(ctx, srcFile, cFile)
+ case ".ll":
+ cppFile := common.GenPathWithExt(ctx, srcFile, "cpp")
srcFiles[i] = cppFile
+ genLex(ctx, srcFile, cppFile)
}
}
diff --git a/cc/x86_darwin_host.go b/cc/x86_darwin_host.go
index 1bd3dd05..7f4c4890 100644
--- a/cc/x86_darwin_host.go
+++ b/cc/x86_darwin_host.go
@@ -63,10 +63,10 @@ var (
"-Wl,-rpath,@loader_path/lib64",
}
- darwinClangCflags = append([]string{
+ darwinClangCflags = append(clangFilterUnknownCflags(darwinCflags), []string{
"-integrated-as",
"-fstack-protector-strong",
- }, clangFilterUnknownCflags(darwinCflags)...)
+ }...)
darwinClangLdflags = clangFilterUnknownCflags(darwinLdflags)
diff --git a/cc/x86_linux_host.go b/cc/x86_linux_host.go
index d1a92f1d..528d2a72 100644
--- a/cc/x86_linux_host.go
+++ b/cc/x86_linux_host.go
@@ -66,28 +66,28 @@ var (
`-Wl,-rpath,\$$ORIGIN/lib64`,
}
- linuxClangCflags = append([]string{
+ linuxClangCflags = append(clangFilterUnknownCflags(linuxCflags), []string{
"--gcc-toolchain=${linuxGccRoot}",
"--sysroot=${linuxGccRoot}/sysroot",
"-fstack-protector-strong",
- }, clangFilterUnknownCflags(linuxCflags)...)
+ }...)
- linuxClangLdflags = append([]string{
+ linuxClangLdflags = append(clangFilterUnknownCflags(linuxLdflags), []string{
"--gcc-toolchain=${linuxGccRoot}",
"--sysroot=${linuxGccRoot}/sysroot",
- }, clangFilterUnknownCflags(linuxLdflags)...)
+ }...)
- linuxX86ClangLdflags = append([]string{
+ linuxX86ClangLdflags = append(clangFilterUnknownCflags(linuxX86Ldflags), []string{
"-B${linuxGccRoot}/lib/gcc/${linuxGccTriple}/${linuxGccVersion}/32",
"-L${linuxGccRoot}/lib/gcc/${linuxGccTriple}/${linuxGccVersion}/32",
"-L${linuxGccRoot}/${linuxGccTriple}/lib32",
- }, clangFilterUnknownCflags(linuxX86Ldflags)...)
+ }...)
- linuxX8664ClangLdflags = append([]string{
+ linuxX8664ClangLdflags = append(clangFilterUnknownCflags(linuxX8664Ldflags), []string{
"-B${linuxGccRoot}/lib/gcc/${linuxGccTriple}/${linuxGccVersion}",
"-L${linuxGccRoot}/lib/gcc/${linuxGccTriple}/${linuxGccVersion}",
"-L${linuxGccRoot}/${linuxGccTriple}/lib64",
- }, clangFilterUnknownCflags(linuxX8664Ldflags)...)
+ }...)
linuxClangCppflags = []string{
"-isystem ${linuxGccRoot}/${linuxGccTriple}/include/c++/${linuxGccVersion}",
diff --git a/common/androidmk.go b/common/androidmk.go
index f041b597..9628a100 100644
--- a/common/androidmk.go
+++ b/common/androidmk.go
@@ -182,9 +182,6 @@ func translateAndroidMkModule(ctx blueprint.SingletonContext, w io.Writer, mod b
fmt.Fprintln(w, "LOCAL_MODULE_HOST_CROSS_ARCH :=", archStr)
} else {
fmt.Fprintln(w, "LOCAL_MODULE_HOST_ARCH :=", archStr)
-
- // TODO: this isn't true for every module, only dependencies of ACP
- fmt.Fprintln(w, "LOCAL_ACP_UNAVAILABLE := true")
}
fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", amod.HostType().String())
fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true")
diff --git a/common/config.go b/common/config.go
index 6fd6dfce..ef59cf72 100644
--- a/common/config.go
+++ b/common/config.go
@@ -261,7 +261,7 @@ func (c *config) DeviceUsesClang() bool {
if c.ProductVariables.DeviceUsesClang != nil {
return *c.ProductVariables.DeviceUsesClang
}
- return false
+ return true
}
func (c *config) ResourceOverlays() []SourcePath {
diff --git a/soong.bash b/soong.bash
index d88ebbfc..f695e626 100755
--- a/soong.bash
+++ b/soong.bash
@@ -40,4 +40,4 @@ if [ -f "${ENVFILE}" ]; then
fi
fi
-"prebuilts/ninja/${PREBUILTOS}/ninja" -f "${BUILDDIR}/build.ninja" "$@"
+"prebuilts/ninja/${PREBUILTOS}/ninja" -f "${BUILDDIR}/build.ninja" -w dupbuild=err "$@"