From f5310e3f88f810dfde6b8859dc00a38a6370345c Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Wed, 19 Jul 2017 11:39:53 -0700 Subject: [PATCH] Add to cflags in compilerFlags() These compiler flags weren't being properly added to ToolingCFlags, which was causing clang-tidy to complain a lot about incompatible redeclarations of library functions. Moving them to compilerFlags() causes them to be added to ToolingCFlags. Bug: None Test: mma in bionic/. clang-tidy now shows 7,142 fewer high-severity warnings. Change-Id: If5148858d9db143a3dd9b0ce6c970258ec4ff9cb --- cc/llndk_library.go | 5 +++++ cc/ndk_library.go | 31 +++++++++++++++++++------------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/cc/llndk_library.go b/cc/llndk_library.go index 66ffc9fe7..c3d3462bb 100644 --- a/cc/llndk_library.go +++ b/cc/llndk_library.go @@ -61,6 +61,11 @@ type llndkStubDecorator struct { versionScriptPath android.ModuleGenPath } +func (stub *llndkStubDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags { + flags = stub.baseCompiler.compilerFlags(ctx, flags) + return addStubLibraryCompilerFlags(flags) +} + func (stub *llndkStubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects { objs, versionScript := compileStubLibrary(ctx, flags, stub.Properties.Symbol_file, "current", "--vndk") stub.versionScriptPath = versionScript diff --git a/cc/ndk_library.go b/cc/ndk_library.go index 5765aa92a..dbfc5be3c 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -242,6 +242,25 @@ func (c *stubDecorator) compilerInit(ctx BaseModuleContext) { ndkMigratedLibs = append(ndkMigratedLibs, name) } +func addStubLibraryCompilerFlags(flags Flags) Flags { + flags.CFlags = append(flags.CFlags, + // We're knowingly doing some otherwise unsightly things with builtin + // functions here. We're just generating stub libraries, so ignore it. + "-Wno-incompatible-library-redeclaration", + "-Wno-builtin-requires-header", + "-Wno-invalid-noreturn", + // These libraries aren't actually used. Don't worry about unwinding + // (avoids the need to link an unwinder into a fake library). + "-fno-unwind-tables", + ) + return flags +} + +func (stub *stubDecorator) compilerFlags(ctx ModuleContext, flags Flags) Flags { + flags = stub.baseCompiler.compilerFlags(ctx, flags) + return addStubLibraryCompilerFlags(flags) +} + func compileStubLibrary(ctx ModuleContext, flags Flags, symbolFile, apiLevel, vndk string) (Objects, android.ModuleGenPath) { arch := ctx.Arch().ArchType.String() @@ -263,18 +282,6 @@ func compileStubLibrary(ctx ModuleContext, flags Flags, symbolFile, apiLevel, vn }, }) - flags.CFlags = append(flags.CFlags, - // We're knowingly doing some otherwise unsightly things with builtin - // functions here. We're just generating stub libraries, so ignore it. - "-Wno-incompatible-library-redeclaration", - "-Wno-builtin-requires-header", - "-Wno-invalid-noreturn", - - // These libraries aren't actually used. Don't worry about unwinding - // (avoids the need to link an unwinder into a fake library). - "-fno-unwind-tables", - ) - subdir := "" srcs := []android.Path{stubSrcPath} return compileObjs(ctx, flagsToBuilderFlags(flags), subdir, srcs, nil), versionScriptPath