From 4af21ed26f41f9779c4e48dfb3b8d86366a24346 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 4 Nov 2019 09:37:55 -0800 Subject: [PATCH] Split local and global cflags Native compiler flags are currently applied in approximately: global cflags local cflags local include dirs global include dirs global conlyflags local conlyflags global cppflags local cppflags This means that a flag that is enabled in the global cppflags cannot be disabled in the local cflags, and an Android.bp author must know to disable it in the local cppflags. A better order would be: global cflags global conlyflags global cppflags local cflags local conlyflags local cppflags local include dirs global include dirs We are mixing both the global and local cflags into a single variable, and similar for conlyflags and cppflags, which prevents reordering them. This CL prepares to reorder them by splitting the global and local cflags into separate variables. Bug: 143713277 Test: m native Change-Id: Ic55a8c3516c331dc5f2af9d00e59ceca9d3e6c15 --- cc/binary.go | 24 ++++----- cc/builder.go | 8 +-- cc/cc.go | 56 ++++++++++--------- cc/cflag_artifacts.go | 4 +- cc/cmakelists.go | 46 ++++++++++------ cc/compdb.go | 12 +++-- cc/compiler.go | 105 ++++++++++++++++++------------------ cc/coverage.go | 8 +-- cc/gen_test.go | 4 +- cc/library.go | 26 ++++----- cc/library_test.go | 2 +- cc/linker.go | 41 +++++++------- cc/llndk_library.go | 2 +- cc/lto.go | 15 +++--- cc/ndk_library.go | 4 +- cc/object.go | 4 +- cc/pgo.go | 14 ++--- cc/proto.go | 6 +-- cc/rs.go | 2 +- cc/sabi.go | 6 ++- cc/sanitize.go | 82 ++++++++++++++-------------- cc/stl.go | 16 +++--- cc/test.go | 12 ++--- cc/util.go | 42 +++++++-------- cc/vendor_public_library.go | 2 +- cc/xom.go | 2 +- 26 files changed, 286 insertions(+), 259 deletions(-) diff --git a/cc/binary.go b/cc/binary.go index b27142cf7..617d4dda0 100644 --- a/cc/binary.go +++ b/cc/binary.go @@ -227,7 +227,7 @@ func (binary *binaryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags if ctx.Host() && !ctx.Windows() && !binary.static() { if !ctx.Config().IsEnvTrue("DISABLE_HOST_PIE") { - flags.LdFlags = append(flags.LdFlags, "-pie") + flags.Global.LdFlags = append(flags.Global.LdFlags, "-pie") } } @@ -235,7 +235,7 @@ func (binary *binaryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags // all code is position independent, and then those warnings get promoted to // errors. if !ctx.Windows() { - flags.CFlags = append(flags.CFlags, "-fPIE") + flags.Global.CFlags = append(flags.Global.CFlags, "-fPIE") } if ctx.toolchain().Bionic() { @@ -244,11 +244,11 @@ func (binary *binaryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags // However, bionic/linker uses -shared to overwrite. // Linker for x86 targets does not allow coexistance of -static and -shared, // so we add -static only if -shared is not used. - if !inList("-shared", flags.LdFlags) { - flags.LdFlags = append(flags.LdFlags, "-static") + if !inList("-shared", flags.Local.LdFlags) { + flags.Global.LdFlags = append(flags.Global.LdFlags, "-static") } - flags.LdFlags = append(flags.LdFlags, + flags.Global.LdFlags = append(flags.Global.LdFlags, "-nostdlib", "-Bstatic", "-Wl,--gc-sections", @@ -278,14 +278,14 @@ func (binary *binaryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags if ctx.Os() == android.LinuxBionic { // Use the dlwrap entry point, but keep _start around so // that it can be used by host_bionic_inject - flags.LdFlags = append(flags.LdFlags, + flags.Global.LdFlags = append(flags.Global.LdFlags, "-Wl,--entry=__dlwrap__start", "-Wl,--undefined=_start", ) } } - flags.LdFlags = append(flags.LdFlags, + flags.Global.LdFlags = append(flags.Global.LdFlags, "-pie", "-nostdlib", "-Bdynamic", @@ -295,10 +295,10 @@ func (binary *binaryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags } } else { if binary.static() { - flags.LdFlags = append(flags.LdFlags, "-static") + flags.Global.LdFlags = append(flags.Global.LdFlags, "-static") } if ctx.Darwin() { - flags.LdFlags = append(flags.LdFlags, "-Wl,-headerpad_max_install_names") + flags.Global.LdFlags = append(flags.Global.LdFlags, "-Wl,-headerpad_max_install_names") } } @@ -315,14 +315,14 @@ func (binary *binaryDecorator) link(ctx ModuleContext, var linkerDeps android.Paths if deps.LinkerFlagsFile.Valid() { - flags.LdFlags = append(flags.LdFlags, "$$(cat "+deps.LinkerFlagsFile.String()+")") + flags.Local.LdFlags = append(flags.Local.LdFlags, "$$(cat "+deps.LinkerFlagsFile.String()+")") linkerDeps = append(linkerDeps, deps.LinkerFlagsFile.Path()) } if flags.DynamicLinker != "" { - flags.LdFlags = append(flags.LdFlags, "-Wl,-dynamic-linker,"+flags.DynamicLinker) + flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-dynamic-linker,"+flags.DynamicLinker) } else if ctx.toolchain().Bionic() && !binary.static() { - flags.LdFlags = append(flags.LdFlags, "-Wl,--no-dynamic-linker") + flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--no-dynamic-linker") } builderFlags := flagsToBuilderFlags(flags) diff --git a/cc/builder.go b/cc/builder.go index 491ebc59e..5136fc847 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -261,8 +261,7 @@ func init() { } type builderFlags struct { - globalFlags string - arFlags string + commonFlags string asFlags string cFlags string toolingCFlags string // A separate set of cFlags for clang LibTooling tools @@ -350,7 +349,7 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and } commonFlags := strings.Join([]string{ - flags.globalFlags, + flags.commonFlags, flags.systemIncludeFlags, }, " ") @@ -567,9 +566,6 @@ func TransformObjToStaticLib(ctx android.ModuleContext, objFiles android.Paths, if !ctx.Darwin() { arFlags += " -format=gnu" } - if flags.arFlags != "" { - arFlags += " " + flags.arFlags - } ctx.Build(pctx, android.BuildParams{ Rule: ar, diff --git a/cc/cc.go b/cc/cc.go index a312c49aa..3c6eabad9 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -140,26 +140,34 @@ type PathDeps struct { DynamicLinker android.OptionalPath } -type Flags struct { - GlobalFlags []string // Flags that apply to C, C++, and assembly source files - ArFlags []string // Flags that apply to ar +// LocalOrGlobalFlags contains flags that need to have values set globally by the build system or locally by the module +// tracked separately, in order to maintain the required ordering (most of the global flags need to go first on the +// command line so they can be overridden by the local module flags). +type LocalOrGlobalFlags struct { + CommonFlags []string // Flags that apply to C, C++, and assembly source files AsFlags []string // Flags that apply to assembly source files + YasmFlags []string // Flags that apply to yasm assembly source files CFlags []string // Flags that apply to C and C++ source files ToolingCFlags []string // Flags that apply to C and C++ source files parsed by clang LibTooling tools ConlyFlags []string // Flags that apply to C source files CppFlags []string // Flags that apply to C++ source files ToolingCppFlags []string // Flags that apply to C++ source files parsed by clang LibTooling tools - aidlFlags []string // Flags that apply to aidl source files - rsFlags []string // Flags that apply to renderscript source files LdFlags []string // Flags that apply to linker command lines - libFlags []string // Flags to add libraries early to the link order - extraLibFlags []string // Flags to add libraries late in the link order after LdFlags - TidyFlags []string // Flags that apply to clang-tidy - SAbiFlags []string // Flags that apply to header-abi-dumper - YasmFlags []string // Flags that apply to yasm assembly source files +} + +type Flags struct { + Local LocalOrGlobalFlags + Global LocalOrGlobalFlags + + aidlFlags []string // Flags that apply to aidl source files + rsFlags []string // Flags that apply to renderscript source files + libFlags []string // Flags to add libraries early to the link order + extraLibFlags []string // Flags to add libraries late in the link order after LdFlags + TidyFlags []string // Flags that apply to clang-tidy + SAbiFlags []string // Flags that apply to header-abi-dumper // Global include flags that apply to C, C++, and assembly source files - // These must be after any module include flags, which will be in GlobalFlags. + // These must be after any module include flags, which will be in CommonFlags. SystemIncludeFlags []string Toolchain config.Toolchain @@ -1277,17 +1285,17 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { return } - flags.CFlags, _ = filterList(flags.CFlags, config.IllegalFlags) - flags.CppFlags, _ = filterList(flags.CppFlags, config.IllegalFlags) - flags.ConlyFlags, _ = filterList(flags.ConlyFlags, config.IllegalFlags) + flags.Local.CFlags, _ = filterList(flags.Local.CFlags, config.IllegalFlags) + flags.Local.CppFlags, _ = filterList(flags.Local.CppFlags, config.IllegalFlags) + flags.Local.ConlyFlags, _ = filterList(flags.Local.ConlyFlags, config.IllegalFlags) - flags.GlobalFlags = append(flags.GlobalFlags, deps.Flags...) + flags.Local.CommonFlags = append(flags.Local.CommonFlags, deps.Flags...) for _, dir := range deps.IncludeDirs { - flags.GlobalFlags = append(flags.GlobalFlags, "-I"+dir.String()) + flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-I"+dir.String()) } for _, dir := range deps.SystemIncludeDirs { - flags.GlobalFlags = append(flags.GlobalFlags, "-isystem "+dir.String()) + flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-isystem "+dir.String()) } c.flags = flags @@ -1296,16 +1304,16 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { flags = c.sabi.flags(ctx, flags) } - flags.AssemblerWithCpp = inList("-xassembler-with-cpp", flags.AsFlags) + flags.AssemblerWithCpp = inList("-xassembler-with-cpp", flags.Local.AsFlags) // 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, " ")) - ctx.Variable(pctx, "cppflags", strings.Join(flags.CppFlags, " ")) - ctx.Variable(pctx, "asflags", strings.Join(flags.AsFlags, " ")) - flags.CFlags = []string{"$cflags"} - flags.CppFlags = []string{"$cppflags"} - flags.AsFlags = []string{"$asflags"} + ctx.Variable(pctx, "cflags", strings.Join(flags.Local.CFlags, " ")) + ctx.Variable(pctx, "cppflags", strings.Join(flags.Local.CppFlags, " ")) + ctx.Variable(pctx, "asflags", strings.Join(flags.Local.AsFlags, " ")) + flags.Local.CFlags = []string{"$cflags"} + flags.Local.CppFlags = []string{"$cppflags"} + flags.Local.AsFlags = []string{"$asflags"} var objs Objects if c.compiler != nil { diff --git a/cc/cflag_artifacts.go b/cc/cflag_artifacts.go index 9ed3876ab..b61f2a8be 100644 --- a/cc/cflag_artifacts.go +++ b/cc/cflag_artifacts.go @@ -147,8 +147,8 @@ func (s *cflagArtifactsText) GenerateBuildActions(ctx android.SingletonContext) ctx.VisitAllModules(func(module android.Module) { if ccModule, ok := module.(*Module); ok { if allowedDir(ctx.ModuleDir(ccModule)) { - cflags := ccModule.flags.CFlags - cppflags := ccModule.flags.CppFlags + cflags := ccModule.flags.Local.CFlags + cppflags := ccModule.flags.Local.CppFlags module := fmt.Sprintf("%s:%s (%s)", ctx.BlueprintFile(ccModule), ctx.ModuleName(ccModule), diff --git a/cc/cmakelists.go b/cc/cmakelists.go index 7b4f89b54..76b16cc6a 100644 --- a/cc/cmakelists.go +++ b/cc/cmakelists.go @@ -162,25 +162,41 @@ func generateCLionProject(compiledModule CompiledInterface, ctx android.Singleto f.WriteString(")\n") // Add all header search path and compiler parameters (-D, -W, -f, -XXXX) - f.WriteString("\n# GLOBAL FLAGS:\n") - globalParameters := parseCompilerParameters(ccModule.flags.GlobalFlags, ctx, f) - translateToCMake(globalParameters, f, true, true) + f.WriteString("\n# GLOBAL ALL FLAGS:\n") + globalAllParameters := parseCompilerParameters(ccModule.flags.Global.CommonFlags, ctx, f) + translateToCMake(globalAllParameters, f, true, true) - f.WriteString("\n# CFLAGS:\n") - cParameters := parseCompilerParameters(ccModule.flags.CFlags, ctx, f) - translateToCMake(cParameters, f, true, true) + f.WriteString("\n# LOCAL ALL FLAGS:\n") + localAllParameters := parseCompilerParameters(ccModule.flags.Local.CommonFlags, ctx, f) + translateToCMake(localAllParameters, f, true, true) - f.WriteString("\n# C ONLY FLAGS:\n") - cOnlyParameters := parseCompilerParameters(ccModule.flags.ConlyFlags, ctx, f) - translateToCMake(cOnlyParameters, f, true, false) + f.WriteString("\n# GLOBAL CFLAGS:\n") + globalCParameters := parseCompilerParameters(ccModule.flags.Global.CFlags, ctx, f) + translateToCMake(globalCParameters, f, true, true) - f.WriteString("\n# CPP FLAGS:\n") - cppParameters := parseCompilerParameters(ccModule.flags.CppFlags, ctx, f) - translateToCMake(cppParameters, f, false, true) + f.WriteString("\n# LOCAL CFLAGS:\n") + localCParameters := parseCompilerParameters(ccModule.flags.Local.CFlags, ctx, f) + translateToCMake(localCParameters, f, true, true) - f.WriteString("\n# SYSTEM INCLUDE FLAGS:\n") - includeParameters := parseCompilerParameters(ccModule.flags.SystemIncludeFlags, ctx, f) - translateToCMake(includeParameters, f, true, true) + f.WriteString("\n# GLOBAL C ONLY FLAGS:\n") + globalConlyParameters := parseCompilerParameters(ccModule.flags.Global.ConlyFlags, ctx, f) + translateToCMake(globalConlyParameters, f, true, false) + + f.WriteString("\n# LOCAL C ONLY FLAGS:\n") + localConlyParameters := parseCompilerParameters(ccModule.flags.Local.ConlyFlags, ctx, f) + translateToCMake(localConlyParameters, f, true, false) + + f.WriteString("\n# GLOBAL CPP FLAGS:\n") + globalCppParameters := parseCompilerParameters(ccModule.flags.Global.CppFlags, ctx, f) + translateToCMake(globalCppParameters, f, false, true) + + f.WriteString("\n# LOCAL CPP FLAGS:\n") + localCppParameters := parseCompilerParameters(ccModule.flags.Local.CppFlags, ctx, f) + translateToCMake(localCppParameters, f, false, true) + + f.WriteString("\n# GLOBAL SYSTEM INCLUDE FLAGS:\n") + globalIncludeParameters := parseCompilerParameters(ccModule.flags.SystemIncludeFlags, ctx, f) + translateToCMake(globalIncludeParameters, f, true, true) // Add project executable. f.WriteString(fmt.Sprintf("\nadd_executable(%s ${SOURCE_FILES})\n", diff --git a/cc/compdb.go b/cc/compdb.go index ecc67b8b0..519380fa9 100644 --- a/cc/compdb.go +++ b/cc/compdb.go @@ -152,12 +152,16 @@ func getArguments(src android.Path, ctx android.SingletonContext, ccModule *Modu clangPath = ccPath } args = append(args, clangPath) - args = append(args, expandAllVars(ctx, ccModule.flags.GlobalFlags)...) - args = append(args, expandAllVars(ctx, ccModule.flags.CFlags)...) + args = append(args, expandAllVars(ctx, ccModule.flags.Global.CommonFlags)...) + args = append(args, expandAllVars(ctx, ccModule.flags.Local.CommonFlags)...) + args = append(args, expandAllVars(ctx, ccModule.flags.Global.CFlags)...) + args = append(args, expandAllVars(ctx, ccModule.flags.Local.CFlags)...) if isCpp { - args = append(args, expandAllVars(ctx, ccModule.flags.CppFlags)...) + args = append(args, expandAllVars(ctx, ccModule.flags.Global.CppFlags)...) + args = append(args, expandAllVars(ctx, ccModule.flags.Local.CppFlags)...) } else if !isAsm { - args = append(args, expandAllVars(ctx, ccModule.flags.ConlyFlags)...) + args = append(args, expandAllVars(ctx, ccModule.flags.Global.ConlyFlags)...) + args = append(args, expandAllVars(ctx, ccModule.flags.Local.ConlyFlags)...) } args = append(args, expandAllVars(ctx, ccModule.flags.SystemIncludeFlags)...) args = append(args, src.String()) diff --git a/cc/compiler.go b/cc/compiler.go index ff681017e..bb40a5bd2 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -265,11 +265,11 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps esc := proptools.NinjaAndShellEscapeList - flags.CFlags = append(flags.CFlags, esc(compiler.Properties.Cflags)...) - flags.CppFlags = append(flags.CppFlags, esc(compiler.Properties.Cppflags)...) - flags.ConlyFlags = append(flags.ConlyFlags, esc(compiler.Properties.Conlyflags)...) - flags.AsFlags = append(flags.AsFlags, esc(compiler.Properties.Asflags)...) - flags.YasmFlags = append(flags.YasmFlags, esc(compiler.Properties.Asflags)...) + flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Cflags)...) + flags.Local.CppFlags = append(flags.Local.CppFlags, esc(compiler.Properties.Cppflags)...) + flags.Local.ConlyFlags = append(flags.Local.ConlyFlags, esc(compiler.Properties.Conlyflags)...) + flags.Local.AsFlags = append(flags.Local.AsFlags, esc(compiler.Properties.Asflags)...) + flags.Local.YasmFlags = append(flags.Local.YasmFlags, esc(compiler.Properties.Asflags)...) flags.Yacc = compiler.Properties.Yacc @@ -277,20 +277,20 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps localIncludeDirs := android.PathsForModuleSrc(ctx, compiler.Properties.Local_include_dirs) if len(localIncludeDirs) > 0 { f := includeDirsToFlags(localIncludeDirs) - flags.GlobalFlags = append(flags.GlobalFlags, f) - flags.YasmFlags = append(flags.YasmFlags, f) + flags.Local.CommonFlags = append(flags.Local.CommonFlags, f) + flags.Local.YasmFlags = append(flags.Local.YasmFlags, f) } rootIncludeDirs := android.PathsForSource(ctx, compiler.Properties.Include_dirs) if len(rootIncludeDirs) > 0 { f := includeDirsToFlags(rootIncludeDirs) - flags.GlobalFlags = append(flags.GlobalFlags, f) - flags.YasmFlags = append(flags.YasmFlags, f) + flags.Local.CommonFlags = append(flags.Local.CommonFlags, f) + flags.Local.YasmFlags = append(flags.Local.YasmFlags, f) } if compiler.Properties.Include_build_directory == nil || *compiler.Properties.Include_build_directory { - flags.GlobalFlags = append(flags.GlobalFlags, "-I"+android.PathForModuleSrc(ctx).String()) - flags.YasmFlags = append(flags.YasmFlags, "-I"+android.PathForModuleSrc(ctx).String()) + flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-I"+android.PathForModuleSrc(ctx).String()) + flags.Local.YasmFlags = append(flags.Local.YasmFlags, "-I"+android.PathForModuleSrc(ctx).String()) } if !(ctx.useSdk() || ctx.useVndk()) || ctx.Host() { @@ -312,16 +312,17 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps } if ctx.useVndk() { - flags.GlobalFlags = append(flags.GlobalFlags, "-D__ANDROID_VNDK__") + flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_VNDK__") } if ctx.inRecovery() { - flags.GlobalFlags = append(flags.GlobalFlags, "-D__ANDROID_RECOVERY__") + flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_RECOVERY__") } if ctx.apexName() != "" { - flags.GlobalFlags = append(flags.GlobalFlags, "-D__ANDROID_APEX__") - flags.GlobalFlags = append(flags.GlobalFlags, "-D__ANDROID_APEX_"+makeDefineString(ctx.apexName())+"__") + flags.Global.CommonFlags = append(flags.Global.CommonFlags, + "-D__ANDROID_APEX__", + "-D__ANDROID_APEX_"+makeDefineString(ctx.apexName())+"__") } instructionSet := String(compiler.Properties.Instruction_set) @@ -336,17 +337,17 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps CheckBadCompilerFlags(ctx, "release.cflags", compiler.Properties.Release.Cflags) // TODO: debug - flags.CFlags = append(flags.CFlags, esc(compiler.Properties.Release.Cflags)...) + flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Release.Cflags)...) CheckBadCompilerFlags(ctx, "clang_cflags", compiler.Properties.Clang_cflags) CheckBadCompilerFlags(ctx, "clang_asflags", compiler.Properties.Clang_asflags) - flags.CFlags = config.ClangFilterUnknownCflags(flags.CFlags) - flags.CFlags = append(flags.CFlags, esc(compiler.Properties.Clang_cflags)...) - flags.AsFlags = append(flags.AsFlags, esc(compiler.Properties.Clang_asflags)...) - flags.CppFlags = config.ClangFilterUnknownCflags(flags.CppFlags) - flags.ConlyFlags = config.ClangFilterUnknownCflags(flags.ConlyFlags) - flags.LdFlags = config.ClangFilterUnknownCflags(flags.LdFlags) + flags.Local.CFlags = config.ClangFilterUnknownCflags(flags.Local.CFlags) + flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Clang_cflags)...) + flags.Local.AsFlags = append(flags.Local.AsFlags, esc(compiler.Properties.Clang_asflags)...) + flags.Local.CppFlags = config.ClangFilterUnknownCflags(flags.Local.CppFlags) + flags.Local.ConlyFlags = config.ClangFilterUnknownCflags(flags.Local.ConlyFlags) + flags.Local.LdFlags = config.ClangFilterUnknownCflags(flags.Local.LdFlags) target := "-target " + tc.ClangTriple() if ctx.Os().Class == android.Device { @@ -360,45 +361,45 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps gccPrefix := "-B" + config.ToolPath(tc) - flags.CFlags = append(flags.CFlags, target, gccPrefix) - flags.AsFlags = append(flags.AsFlags, target, gccPrefix) - flags.LdFlags = append(flags.LdFlags, target, gccPrefix) + flags.Global.CFlags = append(flags.Global.CFlags, target, gccPrefix) + flags.Global.AsFlags = append(flags.Global.AsFlags, target, gccPrefix) + flags.Global.LdFlags = append(flags.Global.LdFlags, target, gccPrefix) hod := "Host" if ctx.Os().Class == android.Device { hod = "Device" } - flags.GlobalFlags = append(flags.GlobalFlags, instructionSetFlags) - flags.ConlyFlags = append([]string{"${config.CommonGlobalConlyflags}"}, flags.ConlyFlags...) - flags.CppFlags = append([]string{fmt.Sprintf("${config.%sGlobalCppflags}", hod)}, flags.CppFlags...) + flags.Global.CommonFlags = append(flags.Global.CommonFlags, instructionSetFlags) + flags.Global.ConlyFlags = append([]string{"${config.CommonGlobalConlyflags}"}, flags.Global.ConlyFlags...) + flags.Global.CppFlags = append([]string{fmt.Sprintf("${config.%sGlobalCppflags}", hod)}, flags.Global.CppFlags...) - flags.AsFlags = append(flags.AsFlags, tc.ClangAsflags()) - flags.CppFlags = append([]string{"${config.CommonClangGlobalCppflags}"}, flags.CppFlags...) - flags.GlobalFlags = append(flags.GlobalFlags, + flags.Global.AsFlags = append(flags.Global.AsFlags, tc.ClangAsflags()) + flags.Global.CppFlags = append([]string{"${config.CommonClangGlobalCppflags}"}, flags.Global.CppFlags...) + flags.Global.CommonFlags = append(flags.Global.CommonFlags, tc.ClangCflags(), "${config.CommonClangGlobalCflags}", fmt.Sprintf("${config.%sClangGlobalCflags}", hod)) if strings.HasPrefix(android.PathForModuleSrc(ctx).String(), "external/") { - flags.GlobalFlags = append([]string{"${config.ClangExternalCflags}"}, flags.GlobalFlags...) + flags.Global.CommonFlags = append([]string{"${config.ClangExternalCflags}"}, flags.Global.CommonFlags...) } if tc.Bionic() { if Bool(compiler.Properties.Rtti) { - flags.CppFlags = append(flags.CppFlags, "-frtti") + flags.Local.CppFlags = append(flags.Local.CppFlags, "-frtti") } else { - flags.CppFlags = append(flags.CppFlags, "-fno-rtti") + flags.Local.CppFlags = append(flags.Local.CppFlags, "-fno-rtti") } } - flags.AsFlags = append(flags.AsFlags, "-D__ASSEMBLY__") + flags.Global.AsFlags = append(flags.Global.AsFlags, "-D__ASSEMBLY__") - flags.CppFlags = append(flags.CppFlags, tc.ClangCppflags()) + flags.Global.CppFlags = append(flags.Global.CppFlags, tc.ClangCppflags()) - flags.YasmFlags = append(flags.YasmFlags, tc.YasmFlags()) + flags.Global.YasmFlags = append(flags.Global.YasmFlags, tc.YasmFlags()) - flags.GlobalFlags = append(flags.GlobalFlags, tc.ToolchainClangCflags()) + flags.Global.CommonFlags = append(flags.Global.CommonFlags, tc.ToolchainClangCflags()) cStd := config.CStdVersion if String(compiler.Properties.C_std) == "experimental" { @@ -420,15 +421,15 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps cppStd = gnuToCReplacer.Replace(cppStd) } - flags.ConlyFlags = append([]string{"-std=" + cStd}, flags.ConlyFlags...) - flags.CppFlags = append([]string{"-std=" + cppStd}, flags.CppFlags...) + flags.Local.ConlyFlags = append([]string{"-std=" + cStd}, flags.Local.ConlyFlags...) + flags.Local.CppFlags = append([]string{"-std=" + cppStd}, flags.Local.CppFlags...) if ctx.useVndk() { - flags.CFlags = append(flags.CFlags, esc(compiler.Properties.Target.Vendor.Cflags)...) + flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Vendor.Cflags)...) } if ctx.inRecovery() { - flags.CFlags = append(flags.CFlags, esc(compiler.Properties.Target.Recovery.Cflags)...) + flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Recovery.Cflags)...) } // We can enforce some rules more strictly in the code we own. strict @@ -444,7 +445,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps // 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") + flags.Global.CFlags = append(flags.Global.CFlags, "-DANDROID_STRICT") } if compiler.hasSrcExt(".proto") { @@ -452,12 +453,12 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps } if compiler.hasSrcExt(".y") || compiler.hasSrcExt(".yy") { - flags.GlobalFlags = append(flags.GlobalFlags, + flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-I"+android.PathForModuleGen(ctx, "yacc", ctx.ModuleDir()).String()) } if compiler.hasSrcExt(".mc") { - flags.GlobalFlags = append(flags.GlobalFlags, + flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-I"+android.PathForModuleGen(ctx, "windmc", ctx.ModuleDir()).String()) } @@ -475,7 +476,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps flags.aidlFlags = append(flags.aidlFlags, "-t") } - flags.GlobalFlags = append(flags.GlobalFlags, + flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-I"+android.PathForModuleGen(ctx, "aidl").String()) } @@ -484,26 +485,26 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps } if compiler.hasSrcExt(".sysprop") { - flags.GlobalFlags = append(flags.GlobalFlags, + flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-I"+android.PathForModuleGen(ctx, "sysprop", "include").String()) } if len(compiler.Properties.Srcs) > 0 { module := ctx.ModuleDir() + "/Android.bp:" + ctx.ModuleName() - if inList("-Wno-error", flags.CFlags) || inList("-Wno-error", flags.CppFlags) { + if inList("-Wno-error", flags.Local.CFlags) || inList("-Wno-error", flags.Local.CppFlags) { addToModuleList(ctx, modulesUsingWnoErrorKey, module) - } else if !inList("-Werror", flags.CFlags) && !inList("-Werror", flags.CppFlags) { + } else if !inList("-Werror", flags.Local.CFlags) && !inList("-Werror", flags.Local.CppFlags) { if warningsAreAllowed(ctx.ModuleDir()) { addToModuleList(ctx, modulesAddedWallKey, module) - flags.CFlags = append([]string{"-Wall"}, flags.CFlags...) + flags.Local.CFlags = append([]string{"-Wall"}, flags.Local.CFlags...) } else { - flags.CFlags = append([]string{"-Wall", "-Werror"}, flags.CFlags...) + flags.Local.CFlags = append([]string{"-Wall", "-Werror"}, flags.Local.CFlags...) } } } if Bool(compiler.Properties.Openmp) { - flags.CFlags = append(flags.CFlags, "-fopenmp") + flags.Local.CFlags = append(flags.Local.CFlags, "-fopenmp") } return flags diff --git a/cc/coverage.go b/cc/coverage.go index 2e81a9e4c..c03a568c3 100644 --- a/cc/coverage.go +++ b/cc/coverage.go @@ -69,12 +69,12 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags if cov.Properties.CoverageEnabled { flags.Coverage = true - flags.GlobalFlags = append(flags.GlobalFlags, "--coverage", "-O0") + flags.Local.CommonFlags = append(flags.Local.CommonFlags, "--coverage", "-O0") cov.linkCoverage = true // Override -Wframe-larger-than and non-default optimization // flags that the module may use. - flags.CFlags = append(flags.CFlags, "-Wno-frame-larger-than=", "-O0") + flags.Local.CFlags = append(flags.Local.CFlags, "-Wno-frame-larger-than=", "-O0") } // Even if we don't have coverage enabled, if any of our object files were compiled @@ -112,12 +112,12 @@ func (cov *coverage) flags(ctx ModuleContext, flags Flags, deps PathDeps) (Flags } if cov.linkCoverage { - flags.LdFlags = append(flags.LdFlags, "--coverage") + flags.Local.LdFlags = append(flags.Local.LdFlags, "--coverage") coverage := ctx.GetDirectDepWithTag(getProfileLibraryName(ctx), coverageDepTag).(*Module) deps.WholeStaticLibs = append(deps.WholeStaticLibs, coverage.OutputFile().Path()) - flags.LdFlags = append(flags.LdFlags, "-Wl,--wrap,getenv") + flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--wrap,getenv") } return flags, deps diff --git a/cc/gen_test.go b/cc/gen_test.go index da3b4e8ad..ceecf1c16 100644 --- a/cc/gen_test.go +++ b/cc/gen_test.go @@ -34,7 +34,7 @@ func TestGen(t *testing.T) { aidl := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("aidl") libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Module().(*Module) - if !inList("-I"+filepath.Dir(aidl.Output.String()), libfoo.flags.GlobalFlags) { + if !inList("-I"+filepath.Dir(aidl.Output.String()), libfoo.flags.Local.CommonFlags) { t.Errorf("missing aidl includes in global flags") } }) @@ -58,7 +58,7 @@ func TestGen(t *testing.T) { aidl := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("aidl") libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Module().(*Module) - if !inList("-I"+filepath.Dir(aidl.Output.String()), libfoo.flags.GlobalFlags) { + if !inList("-I"+filepath.Dir(aidl.Output.String()), libfoo.flags.Local.CommonFlags) { t.Errorf("missing aidl includes in global flags") } diff --git a/cc/library.go b/cc/library.go index 8d90cd8bb..2b74f1166 100644 --- a/cc/library.go +++ b/cc/library.go @@ -394,13 +394,13 @@ func (library *libraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Fla // all code is position independent, and then those warnings get promoted to // errors. if !ctx.Windows() { - flags.CFlags = append(flags.CFlags, "-fPIC") + flags.Global.CFlags = append(flags.Global.CFlags, "-fPIC") } if library.static() { - flags.CFlags = append(flags.CFlags, library.StaticProperties.Static.Cflags...) + flags.Local.CFlags = append(flags.Local.CFlags, library.StaticProperties.Static.Cflags...) } else if library.shared() { - flags.CFlags = append(flags.CFlags, library.SharedProperties.Shared.Cflags...) + flags.Local.CFlags = append(flags.Local.CFlags, library.SharedProperties.Shared.Cflags...) } if library.shared() { @@ -431,7 +431,7 @@ func (library *libraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Fla } } - flags.LdFlags = append(f, flags.LdFlags...) + flags.Global.LdFlags = append(flags.Global.LdFlags, f...) } return flags @@ -441,8 +441,8 @@ func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags, d exportIncludeDirs := library.flagExporter.exportedIncludes(ctx) if len(exportIncludeDirs) > 0 { f := includeDirsToFlags(exportIncludeDirs) - flags.GlobalFlags = append(flags.GlobalFlags, f) - flags.YasmFlags = append(flags.YasmFlags, f) + flags.Local.CommonFlags = append(flags.Local.CommonFlags, f) + flags.Local.YasmFlags = append(flags.Local.YasmFlags, f) } flags = library.baseCompiler.compilerFlags(ctx, flags, deps) @@ -462,8 +462,8 @@ func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags, d } return ret } - flags.GlobalFlags = removeInclude(flags.GlobalFlags) - flags.CFlags = removeInclude(flags.CFlags) + flags.Local.CommonFlags = removeInclude(flags.Local.CommonFlags) + flags.Local.CFlags = removeInclude(flags.Local.CFlags) flags = addStubLibraryCompilerFlags(flags) } @@ -776,21 +776,21 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext, } } else { if unexportedSymbols.Valid() { - flags.LdFlags = append(flags.LdFlags, "-Wl,-unexported_symbols_list,"+unexportedSymbols.String()) + flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-unexported_symbols_list,"+unexportedSymbols.String()) linkerDeps = append(linkerDeps, unexportedSymbols.Path()) } if forceNotWeakSymbols.Valid() { - flags.LdFlags = append(flags.LdFlags, "-Wl,-force_symbols_not_weak_list,"+forceNotWeakSymbols.String()) + flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-force_symbols_not_weak_list,"+forceNotWeakSymbols.String()) linkerDeps = append(linkerDeps, forceNotWeakSymbols.Path()) } if forceWeakSymbols.Valid() { - flags.LdFlags = append(flags.LdFlags, "-Wl,-force_symbols_weak_list,"+forceWeakSymbols.String()) + flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-force_symbols_weak_list,"+forceWeakSymbols.String()) linkerDeps = append(linkerDeps, forceWeakSymbols.Path()) } } if library.buildStubs() { linkerScriptFlags := "-Wl,--version-script," + library.versionScriptPath.String() - flags.LdFlags = append(flags.LdFlags, linkerScriptFlags) + flags.Local.LdFlags = append(flags.Local.LdFlags, linkerScriptFlags) linkerDeps = append(linkerDeps, library.versionScriptPath) } @@ -802,7 +802,7 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext, if ctx.Windows() { importLibraryPath := android.PathForModuleOut(ctx, pathtools.ReplaceExtension(fileName, "lib")) - flags.LdFlags = append(flags.LdFlags, "-Wl,--out-implib="+importLibraryPath.String()) + flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--out-implib="+importLibraryPath.String()) implicitOutputs = append(implicitOutputs, importLibraryPath) } diff --git a/cc/library_test.go b/cc/library_test.go index 2acae35cf..f8d893465 100644 --- a/cc/library_test.go +++ b/cc/library_test.go @@ -181,7 +181,7 @@ func TestLibraryReuse(t *testing.T) { } libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Module().(*Module) - if !inList("-DGOOGLE_PROTOBUF_NO_RTTI", libfoo.flags.CFlags) { + if !inList("-DGOOGLE_PROTOBUF_NO_RTTI", libfoo.flags.Local.CFlags) { t.Errorf("missing protobuf cflags") } }) diff --git a/cc/linker.go b/cc/linker.go index e5e14861e..61ae7575a 100644 --- a/cc/linker.go +++ b/cc/linker.go @@ -331,65 +331,66 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags { } if linker.useClangLld(ctx) { - flags.LdFlags = append(flags.LdFlags, fmt.Sprintf("${config.%sGlobalLldflags}", hod)) + flags.Global.LdFlags = append(flags.Global.LdFlags, fmt.Sprintf("${config.%sGlobalLldflags}", hod)) if !BoolDefault(linker.Properties.Pack_relocations, true) { - flags.LdFlags = append(flags.LdFlags, "-Wl,--pack-dyn-relocs=none") + flags.Global.LdFlags = append(flags.Global.LdFlags, "-Wl,--pack-dyn-relocs=none") } else if ctx.Device() { // The SHT_RELR relocations is only supported by API level >= 28. // Do not turn this on if older version NDK is used. if !ctx.useSdk() || CheckSdkVersionAtLeast(ctx, 28) { - flags.LdFlags = append(flags.LdFlags, "-Wl,--pack-dyn-relocs=android+relr") - flags.LdFlags = append(flags.LdFlags, "-Wl,--use-android-relr-tags") + flags.Global.LdFlags = append(flags.Global.LdFlags, + "-Wl,--pack-dyn-relocs=android+relr", + "-Wl,--use-android-relr-tags") } } } else { - flags.LdFlags = append(flags.LdFlags, fmt.Sprintf("${config.%sGlobalLdflags}", hod)) + flags.Global.LdFlags = append(flags.Global.LdFlags, fmt.Sprintf("${config.%sGlobalLdflags}", hod)) } if Bool(linker.Properties.Allow_undefined_symbols) { if ctx.Darwin() { // darwin defaults to treating undefined symbols as errors - flags.LdFlags = append(flags.LdFlags, "-Wl,-undefined,dynamic_lookup") + flags.Global.LdFlags = append(flags.Global.LdFlags, "-Wl,-undefined,dynamic_lookup") } } else if !ctx.Darwin() && !ctx.Windows() { - flags.LdFlags = append(flags.LdFlags, "-Wl,--no-undefined") + flags.Global.LdFlags = append(flags.Global.LdFlags, "-Wl,--no-undefined") } if linker.useClangLld(ctx) { - flags.LdFlags = append(flags.LdFlags, toolchain.ClangLldflags()) + flags.Global.LdFlags = append(flags.Global.LdFlags, toolchain.ClangLldflags()) } else { - flags.LdFlags = append(flags.LdFlags, toolchain.ClangLdflags()) + flags.Global.LdFlags = append(flags.Global.LdFlags, toolchain.ClangLdflags()) } if !ctx.toolchain().Bionic() && !ctx.Fuchsia() { CheckBadHostLdlibs(ctx, "host_ldlibs", linker.Properties.Host_ldlibs) - flags.LdFlags = append(flags.LdFlags, linker.Properties.Host_ldlibs...) + flags.Local.LdFlags = append(flags.Local.LdFlags, linker.Properties.Host_ldlibs...) if !ctx.Windows() { // Add -ldl, -lpthread, -lm and -lrt to host builds to match the default behavior of device // builds - flags.LdFlags = append(flags.LdFlags, + flags.Global.LdFlags = append(flags.Global.LdFlags, "-ldl", "-lpthread", "-lm", ) if !ctx.Darwin() { - flags.LdFlags = append(flags.LdFlags, "-lrt") + flags.Global.LdFlags = append(flags.Global.LdFlags, "-lrt") } } } if ctx.Fuchsia() { - flags.LdFlags = append(flags.LdFlags, "-lfdio", "-lzircon") + flags.Global.LdFlags = append(flags.Global.LdFlags, "-lfdio", "-lzircon") } if ctx.toolchain().LibclangRuntimeLibraryArch() != "" { - flags.LdFlags = append(flags.LdFlags, "-Wl,--exclude-libs="+config.BuiltinsRuntimeLibrary(ctx.toolchain())+".a") + flags.Global.LdFlags = append(flags.Global.LdFlags, "-Wl,--exclude-libs="+config.BuiltinsRuntimeLibrary(ctx.toolchain())+".a") } CheckBadLinkerFlags(ctx, "ldflags", linker.Properties.Ldflags) - flags.LdFlags = append(flags.LdFlags, proptools.NinjaAndShellEscapeList(linker.Properties.Ldflags)...) + flags.Local.LdFlags = append(flags.Local.LdFlags, proptools.NinjaAndShellEscapeList(linker.Properties.Ldflags)...) if ctx.Host() && !ctx.Windows() { rpath_prefix := `\$$ORIGIN/` @@ -399,7 +400,7 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags { if !ctx.static() { for _, rpath := range linker.dynamicProperties.RunPaths { - flags.LdFlags = append(flags.LdFlags, "-Wl,-rpath,"+rpath_prefix+rpath) + flags.Global.LdFlags = append(flags.Global.LdFlags, "-Wl,-rpath,"+rpath_prefix+rpath) } } } @@ -409,10 +410,10 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags { // to older devices requires the old style hash. Fortunately, we can build with both and // it'll work anywhere. // This is not currently supported on MIPS architectures. - flags.LdFlags = append(flags.LdFlags, "-Wl,--hash-style=both") + flags.Global.LdFlags = append(flags.Global.LdFlags, "-Wl,--hash-style=both") } - flags.LdFlags = append(flags.LdFlags, toolchain.ToolchainClangLdflags()) + flags.Global.LdFlags = append(flags.Global.LdFlags, toolchain.ToolchainClangLdflags()) if Bool(linker.Properties.Group_static_libs) { flags.GroupStaticLibs = true @@ -434,13 +435,13 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags { if ctx.Darwin() { ctx.PropertyErrorf("version_script", "Not supported on Darwin") } else { - flags.LdFlags = append(flags.LdFlags, + flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--version-script,"+versionScript.String()) flags.LdFlagsDeps = append(flags.LdFlagsDeps, versionScript.Path()) if linker.sanitize.isSanitizerEnabled(cfi) { cfiExportsMap := android.PathForSource(ctx, cfiExportsMapPath) - flags.LdFlags = append(flags.LdFlags, + flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--version-script,"+cfiExportsMap.String()) flags.LdFlagsDeps = append(flags.LdFlagsDeps, cfiExportsMap) } diff --git a/cc/llndk_library.go b/cc/llndk_library.go index 16e089e61..3a5b3a6da 100644 --- a/cc/llndk_library.go +++ b/cc/llndk_library.go @@ -133,7 +133,7 @@ func (stub *llndkStubDecorator) link(ctx ModuleContext, flags Flags, deps PathDe if !Bool(stub.Properties.Unversioned) { linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String() - flags.LdFlags = append(flags.LdFlags, linkerScriptFlag) + flags.Local.LdFlags = append(flags.Local.LdFlags, linkerScriptFlag) flags.LdFlagsDeps = append(flags.LdFlagsDeps, stub.versionScriptPath) } diff --git a/cc/lto.go b/cc/lto.go index 580bb090b..4489fc7dd 100644 --- a/cc/lto.go +++ b/cc/lto.go @@ -82,7 +82,7 @@ func (lto *lto) useClangLld(ctx BaseModuleContext) bool { func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags { // TODO(b/131771163): Disable LTO when using explicit fuzzing configurations. // LTO breaks fuzzer builds. - if inList("-fsanitize=fuzzer-no-link", flags.CFlags) { + if inList("-fsanitize=fuzzer-no-link", flags.Local.CFlags) { return flags } @@ -94,27 +94,28 @@ func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags { ltoFlag = "-flto" } - flags.CFlags = append(flags.CFlags, ltoFlag) - flags.LdFlags = append(flags.LdFlags, ltoFlag) + flags.Local.CFlags = append(flags.Local.CFlags, ltoFlag) + flags.Local.LdFlags = append(flags.Local.LdFlags, ltoFlag) if ctx.Config().IsEnvTrue("USE_THINLTO_CACHE") && Bool(lto.Properties.Lto.Thin) && lto.useClangLld(ctx) { // Set appropriate ThinLTO cache policy cacheDirFormat := "-Wl,--thinlto-cache-dir=" cacheDir := android.PathForOutput(ctx, "thinlto-cache").String() - flags.LdFlags = append(flags.LdFlags, cacheDirFormat+cacheDir) + flags.Local.LdFlags = append(flags.Local.LdFlags, cacheDirFormat+cacheDir) // Limit the size of the ThinLTO cache to the lesser of 10% of available // disk space and 10GB. cachePolicyFormat := "-Wl,--thinlto-cache-policy=" policy := "cache_size=10%:cache_size_bytes=10g" - flags.LdFlags = append(flags.LdFlags, cachePolicyFormat+policy) + flags.Local.LdFlags = append(flags.Local.LdFlags, cachePolicyFormat+policy) } // If the module does not have a profile, be conservative and do not inline // or unroll loops during LTO, in order to prevent significant size bloat. if !ctx.isPgoCompile() { - flags.LdFlags = append(flags.LdFlags, "-Wl,-plugin-opt,-inline-threshold=0") - flags.LdFlags = append(flags.LdFlags, "-Wl,-plugin-opt,-unroll-threshold=0") + flags.Local.LdFlags = append(flags.Local.LdFlags, + "-Wl,-plugin-opt,-inline-threshold=0", + "-Wl,-plugin-opt,-unroll-threshold=0") } } return flags diff --git a/cc/ndk_library.go b/cc/ndk_library.go index 3747b41cb..b75c4c898 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -257,7 +257,7 @@ func (c *stubDecorator) compilerInit(ctx BaseModuleContext) { } func addStubLibraryCompilerFlags(flags Flags) Flags { - flags.CFlags = append(flags.CFlags, + flags.Global.CFlags = append(flags.Global.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", @@ -337,7 +337,7 @@ func (stub *stubDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, if useVersionScript { linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String() - flags.LdFlags = append(flags.LdFlags, linkerScriptFlag) + flags.Local.LdFlags = append(flags.Local.LdFlags, linkerScriptFlag) flags.LdFlagsDeps = append(flags.LdFlagsDeps, stub.versionScriptPath) } diff --git a/cc/object.go b/cc/object.go index 31729a5f8..ad31d09fc 100644 --- a/cc/object.go +++ b/cc/object.go @@ -87,10 +87,10 @@ func (object *objectLinker) linkerDeps(ctx DepsContext, deps Deps) Deps { } func (object *objectLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags { - flags.LdFlags = append(flags.LdFlags, ctx.toolchain().ToolchainClangLdflags()) + flags.Global.LdFlags = append(flags.Global.LdFlags, ctx.toolchain().ToolchainClangLdflags()) if lds := android.OptionalPathForModuleSrc(ctx, object.Properties.Linker_script); lds.Valid() { - flags.LdFlags = append(flags.LdFlags, "-Wl,-T,"+lds.String()) + flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-T,"+lds.String()) flags.LdFlagsDeps = append(flags.LdFlagsDeps, lds.Path()) } return flags diff --git a/cc/pgo.go b/cc/pgo.go index 4e915fffe..4618f4e75 100644 --- a/cc/pgo.go +++ b/cc/pgo.go @@ -89,18 +89,18 @@ func (pgo *pgo) props() []interface{} { } func (props *PgoProperties) addProfileGatherFlags(ctx ModuleContext, flags Flags) Flags { - flags.CFlags = append(flags.CFlags, props.Pgo.Cflags...) + flags.Local.CFlags = append(flags.Local.CFlags, props.Pgo.Cflags...) if props.isInstrumentation() { - flags.CFlags = append(flags.CFlags, profileInstrumentFlag) + flags.Local.CFlags = append(flags.Local.CFlags, profileInstrumentFlag) // The profile runtime is added below in deps(). Add the below // flag, which is the only other link-time action performed by // the Clang driver during link. - flags.LdFlags = append(flags.LdFlags, "-u__llvm_profile_runtime") + flags.Local.LdFlags = append(flags.Local.LdFlags, "-u__llvm_profile_runtime") } if props.isSampling() { - flags.CFlags = append(flags.CFlags, profileSamplingFlag) - flags.LdFlags = append(flags.LdFlags, profileSamplingFlag) + flags.Local.CFlags = append(flags.Local.CFlags, profileSamplingFlag) + flags.Local.LdFlags = append(flags.Local.LdFlags, profileSamplingFlag) } return flags } @@ -170,8 +170,8 @@ func (props *PgoProperties) addProfileUseFlags(ctx ModuleContext, flags Flags) F profileFilePath := profileFile.Path() profileUseFlags := props.profileUseFlags(ctx, profileFilePath.String()) - flags.CFlags = append(flags.CFlags, profileUseFlags...) - flags.LdFlags = append(flags.LdFlags, profileUseFlags...) + flags.Local.CFlags = append(flags.Local.CFlags, profileUseFlags...) + flags.Local.LdFlags = append(flags.Local.LdFlags, profileUseFlags...) // Update CFlagsDeps and LdFlagsDeps so the module is rebuilt // if profileFile gets updated diff --git a/cc/proto.go b/cc/proto.go index f818edc95..ae988ec4d 100644 --- a/cc/proto.go +++ b/cc/proto.go @@ -114,13 +114,13 @@ func protoDeps(ctx DepsContext, deps Deps, p *android.ProtoProperties, static bo } func protoFlags(ctx ModuleContext, flags Flags, p *android.ProtoProperties) Flags { - flags.CFlags = append(flags.CFlags, "-DGOOGLE_PROTOBUF_NO_RTTI") + flags.Local.CFlags = append(flags.Local.CFlags, "-DGOOGLE_PROTOBUF_NO_RTTI") flags.proto = android.GetProtoFlags(ctx, p) if flags.proto.CanonicalPathFromRoot { - flags.GlobalFlags = append(flags.GlobalFlags, "-I"+flags.proto.SubDir.String()) + flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-I"+flags.proto.SubDir.String()) } - flags.GlobalFlags = append(flags.GlobalFlags, "-I"+flags.proto.Dir.String()) + flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-I"+flags.proto.Dir.String()) if String(p.Proto.Plugin) == "" { var plugin string diff --git a/cc/rs.go b/cc/rs.go index 5951edbc3..61fd1a84a 100644 --- a/cc/rs.go +++ b/cc/rs.go @@ -123,7 +123,7 @@ func rsFlags(ctx ModuleContext, flags Flags, properties *BaseCompilerProperties) rootRsIncludeDirs := android.PathsForSource(ctx, properties.Renderscript.Include_dirs) flags.rsFlags = append(flags.rsFlags, includeDirsToFlags(rootRsIncludeDirs)) - flags.GlobalFlags = append(flags.GlobalFlags, + flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-I"+android.PathForModuleGen(ctx, "rs").String(), "-Iframeworks/rs", "-Iframeworks/rs/cpp", diff --git a/cc/sabi.go b/cc/sabi.go index 4760313e6..8cef1700c 100644 --- a/cc/sabi.go +++ b/cc/sabi.go @@ -70,8 +70,10 @@ func filterOutWithPrefix(list []string, filter []string) (remainder []string) { func (sabimod *sabi) flags(ctx ModuleContext, flags Flags) Flags { // Assuming that the cflags which clang LibTooling tools cannot // understand have not been converted to ninja variables yet. - flags.ToolingCFlags = filterOutWithPrefix(flags.CFlags, config.ClangLibToolingUnknownCflags) - flags.ToolingCppFlags = filterOutWithPrefix(flags.CppFlags, config.ClangLibToolingUnknownCflags) + flags.Local.ToolingCFlags = filterOutWithPrefix(flags.Local.CFlags, config.ClangLibToolingUnknownCflags) + flags.Global.ToolingCFlags = filterOutWithPrefix(flags.Global.CFlags, config.ClangLibToolingUnknownCflags) + flags.Local.ToolingCppFlags = filterOutWithPrefix(flags.Local.CppFlags, config.ClangLibToolingUnknownCflags) + flags.Global.ToolingCppFlags = filterOutWithPrefix(flags.Global.CppFlags, config.ClangLibToolingUnknownCflags) return flags } diff --git a/cc/sanitize.go b/cc/sanitize.go index a3b4e8ebd..2bf051e5a 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -426,8 +426,9 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { minimalRuntimePath := "${config.ClangAsanLibDir}/" + minimalRuntimeLib if ctx.Device() && sanitize.Properties.MinimalRuntimeDep { - flags.LdFlags = append(flags.LdFlags, minimalRuntimePath) - flags.LdFlags = append(flags.LdFlags, "-Wl,--exclude-libs,"+minimalRuntimeLib) + flags.Local.LdFlags = append(flags.Local.LdFlags, + minimalRuntimePath, + "-Wl,--exclude-libs,"+minimalRuntimeLib) } if !sanitize.Properties.SanitizerEnabled && !sanitize.Properties.UbsanRuntimeDep { return flags @@ -439,15 +440,15 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { // TODO: put in flags? flags.RequiredInstructionSet = "arm" } - flags.CFlags = append(flags.CFlags, asanCflags...) - flags.LdFlags = append(flags.LdFlags, asanLdflags...) + flags.Local.CFlags = append(flags.Local.CFlags, asanCflags...) + flags.Local.LdFlags = append(flags.Local.LdFlags, asanLdflags...) if ctx.Host() { // -nodefaultlibs (provided with libc++) prevents the driver from linking // libraries needed with -fsanitize=address. http://b/18650275 (WAI) - flags.LdFlags = append(flags.LdFlags, "-Wl,--no-as-needed") + flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--no-as-needed") } else { - flags.CFlags = append(flags.CFlags, "-mllvm", "-asan-globals=0") + flags.Local.CFlags = append(flags.Local.CFlags, "-mllvm", "-asan-globals=0") if ctx.bootstrap() { flags.DynamicLinker = "/system/bin/bootstrap/linker_asan" } else { @@ -460,33 +461,30 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { } if Bool(sanitize.Properties.Sanitize.Hwaddress) { - flags.CFlags = append(flags.CFlags, hwasanCflags...) + flags.Local.CFlags = append(flags.Local.CFlags, hwasanCflags...) } if Bool(sanitize.Properties.Sanitize.Fuzzer) { - flags.CFlags = append(flags.CFlags, "-fsanitize=fuzzer-no-link") + flags.Local.CFlags = append(flags.Local.CFlags, "-fsanitize=fuzzer-no-link") // TODO(b/131771163): LTO and Fuzzer support is mutually incompatible. - _, flags.LdFlags = removeFromList("-flto", flags.LdFlags) - _, flags.CFlags = removeFromList("-flto", flags.CFlags) - flags.LdFlags = append(flags.LdFlags, "-fno-lto") - flags.CFlags = append(flags.CFlags, "-fno-lto") + _, flags.Local.LdFlags = removeFromList("-flto", flags.Local.LdFlags) + _, flags.Local.CFlags = removeFromList("-flto", flags.Local.CFlags) + flags.Local.LdFlags = append(flags.Local.LdFlags, "-fno-lto") + flags.Local.CFlags = append(flags.Local.CFlags, "-fno-lto") // TODO(b/142430592): Upstream linker scripts for sanitizer runtime libraries // discard the sancov_lowest_stack symbol, because it's emulated TLS (and thus // doesn't match the linker script due to the "__emutls_v." prefix). - flags.LdFlags = append(flags.LdFlags, "-fno-sanitize-coverage=stack-depth") - flags.CFlags = append(flags.CFlags, "-fno-sanitize-coverage=stack-depth") + flags.Local.LdFlags = append(flags.Local.LdFlags, "-fno-sanitize-coverage=stack-depth") + flags.Local.CFlags = append(flags.Local.CFlags, "-fno-sanitize-coverage=stack-depth") // TODO(b/133876586): Experimental PM breaks sanitizer coverage. - _, flags.CFlags = removeFromList("-fexperimental-new-pass-manager", flags.CFlags) - flags.CFlags = append(flags.CFlags, "-fno-experimental-new-pass-manager") + flags.Local.CFlags = append(flags.Local.CFlags, "-fno-experimental-new-pass-manager") // Disable fortify for fuzzing builds. Generally, we'll be building with // UBSan or ASan here and the fortify checks pollute the stack traces. - _, flags.CFlags = removeFromList("-D_FORTIFY_SOURCE=1", flags.CFlags) - _, flags.CFlags = removeFromList("-D_FORTIFY_SOURCE=2", flags.CFlags) - flags.CFlags = append(flags.CFlags, "-U_FORTIFY_SOURCE") + flags.Local.CFlags = append(flags.Local.CFlags, "-U_FORTIFY_SOURCE") } if Bool(sanitize.Properties.Sanitize.Cfi) { @@ -496,75 +494,75 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { flags.RequiredInstructionSet = "thumb" } - flags.CFlags = append(flags.CFlags, cfiCflags...) - flags.AsFlags = append(flags.AsFlags, cfiAsflags...) + flags.Local.CFlags = append(flags.Local.CFlags, cfiCflags...) + flags.Local.AsFlags = append(flags.Local.AsFlags, cfiAsflags...) // Only append the default visibility flag if -fvisibility has not already been set // to hidden. - if !inList("-fvisibility=hidden", flags.CFlags) { - flags.CFlags = append(flags.CFlags, "-fvisibility=default") + if !inList("-fvisibility=hidden", flags.Local.CFlags) { + flags.Local.CFlags = append(flags.Local.CFlags, "-fvisibility=default") } - flags.LdFlags = append(flags.LdFlags, cfiLdflags...) + flags.Local.LdFlags = append(flags.Local.LdFlags, cfiLdflags...) if ctx.staticBinary() { - _, flags.CFlags = removeFromList("-fsanitize-cfi-cross-dso", flags.CFlags) - _, flags.LdFlags = removeFromList("-fsanitize-cfi-cross-dso", flags.LdFlags) + _, flags.Local.CFlags = removeFromList("-fsanitize-cfi-cross-dso", flags.Local.CFlags) + _, flags.Local.LdFlags = removeFromList("-fsanitize-cfi-cross-dso", flags.Local.LdFlags) } } if Bool(sanitize.Properties.Sanitize.Integer_overflow) { - flags.CFlags = append(flags.CFlags, intOverflowCflags...) + flags.Local.CFlags = append(flags.Local.CFlags, intOverflowCflags...) } if len(sanitize.Properties.Sanitizers) > 0 { sanitizeArg := "-fsanitize=" + strings.Join(sanitize.Properties.Sanitizers, ",") - flags.CFlags = append(flags.CFlags, sanitizeArg) - flags.AsFlags = append(flags.AsFlags, sanitizeArg) + flags.Local.CFlags = append(flags.Local.CFlags, sanitizeArg) + flags.Local.AsFlags = append(flags.Local.AsFlags, sanitizeArg) if ctx.Host() { // Host sanitizers only link symbols in the final executable, so // there will always be undefined symbols in intermediate libraries. - _, flags.LdFlags = removeFromList("-Wl,--no-undefined", flags.LdFlags) - flags.LdFlags = append(flags.LdFlags, sanitizeArg) + _, flags.Global.LdFlags = removeFromList("-Wl,--no-undefined", flags.Global.LdFlags) + flags.Local.LdFlags = append(flags.Local.LdFlags, sanitizeArg) } else { if enableMinimalRuntime(sanitize) { - flags.CFlags = append(flags.CFlags, strings.Join(minimalRuntimeFlags, " ")) + flags.Local.CFlags = append(flags.Local.CFlags, strings.Join(minimalRuntimeFlags, " ")) flags.libFlags = append([]string{minimalRuntimePath}, flags.libFlags...) - flags.LdFlags = append(flags.LdFlags, "-Wl,--exclude-libs,"+minimalRuntimeLib) + flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--exclude-libs,"+minimalRuntimeLib) } } if Bool(sanitize.Properties.Sanitize.Fuzzer) { // When fuzzing, we wish to crash with diagnostics on any bug. - flags.CFlags = append(flags.CFlags, "-fno-sanitize-trap=all", "-fno-sanitize-recover=all") + flags.Local.CFlags = append(flags.Local.CFlags, "-fno-sanitize-trap=all", "-fno-sanitize-recover=all") } else if ctx.Host() { - flags.CFlags = append(flags.CFlags, "-fno-sanitize-recover=all") + flags.Local.CFlags = append(flags.Local.CFlags, "-fno-sanitize-recover=all") } else { - flags.CFlags = append(flags.CFlags, "-fsanitize-trap=all", "-ftrap-function=abort") + flags.Local.CFlags = append(flags.Local.CFlags, "-fsanitize-trap=all", "-ftrap-function=abort") } // 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 toDisableImplicitIntegerChange(flags.Local.CFlags) { + flags.Local.CFlags = append(flags.Local.CFlags, "-fno-sanitize=implicit-integer-sign-change") } } if len(sanitize.Properties.DiagSanitizers) > 0 { - flags.CFlags = append(flags.CFlags, "-fno-sanitize-trap="+strings.Join(sanitize.Properties.DiagSanitizers, ",")) + flags.Local.CFlags = append(flags.Local.CFlags, "-fno-sanitize-trap="+strings.Join(sanitize.Properties.DiagSanitizers, ",")) } // FIXME: enable RTTI if diag + (cfi or vptr) if sanitize.Properties.Sanitize.Recover != nil { - flags.CFlags = append(flags.CFlags, "-fsanitize-recover="+ + flags.Local.CFlags = append(flags.Local.CFlags, "-fsanitize-recover="+ strings.Join(sanitize.Properties.Sanitize.Recover, ",")) } if sanitize.Properties.Sanitize.Diag.No_recover != nil { - flags.CFlags = append(flags.CFlags, "-fno-sanitize-recover="+ + flags.Local.CFlags = append(flags.Local.CFlags, "-fno-sanitize-recover="+ strings.Join(sanitize.Properties.Sanitize.Diag.No_recover, ",")) } blacklist := android.OptionalPathForModuleSrc(ctx, sanitize.Properties.Sanitize.Blacklist) if blacklist.Valid() { - flags.CFlags = append(flags.CFlags, "-fsanitize-blacklist="+blacklist.String()) + flags.Local.CFlags = append(flags.Local.CFlags, "-fsanitize-blacklist="+blacklist.String()) flags.CFlagsDeps = append(flags.CFlagsDeps, blacklist.Path()) } diff --git a/cc/stl.go b/cc/stl.go index 101519b05..5ccd44a4a 100644 --- a/cc/stl.go +++ b/cc/stl.go @@ -215,12 +215,12 @@ func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags { // these availability attributes are meaningless for us but cause // build breaks when we try to use code that would not be available // in the system's dylib. - flags.CppFlags = append(flags.CppFlags, + flags.Local.CppFlags = append(flags.Local.CppFlags, "-D_LIBCPP_DISABLE_AVAILABILITY") } if !ctx.toolchain().Bionic() { - flags.CppFlags = append(flags.CppFlags, "-nostdinc++") + flags.Local.CppFlags = append(flags.Local.CppFlags, "-nostdinc++") flags.extraLibFlags = append(flags.extraLibFlags, "-nostdlib++") if ctx.Windows() { if stl.Properties.SelectedStl == "libc++_static" { @@ -231,9 +231,9 @@ func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags { // Use SjLj exceptions for 32-bit. libgcc_eh implements SjLj // exception model for 32-bit. if ctx.Arch().ArchType == android.X86 { - flags.CppFlags = append(flags.CppFlags, "-fsjlj-exceptions") + flags.Local.CppFlags = append(flags.Local.CppFlags, "-fsjlj-exceptions") } - flags.CppFlags = append(flags.CppFlags, + flags.Local.CppFlags = append(flags.Local.CppFlags, // Disable visiblity annotations since we're using static // libc++. "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS", @@ -243,23 +243,23 @@ func (stl *stl) flags(ctx ModuleContext, flags Flags) Flags { } } else { if ctx.Arch().ArchType == android.Arm { - flags.LdFlags = append(flags.LdFlags, "-Wl,--exclude-libs,libunwind_llvm.a") + flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--exclude-libs,libunwind_llvm.a") } } case "libstdc++": // Nothing case "ndk_system": ndkSrcRoot := android.PathForSource(ctx, "prebuilts/ndk/current/sources/cxx-stl/system/include") - flags.CFlags = append(flags.CFlags, "-isystem "+ndkSrcRoot.String()) + flags.Local.CFlags = append(flags.Local.CFlags, "-isystem "+ndkSrcRoot.String()) case "ndk_libc++_shared", "ndk_libc++_static": if ctx.Arch().ArchType == android.Arm { // Make sure the _Unwind_XXX symbols are not re-exported. - flags.LdFlags = append(flags.LdFlags, "-Wl,--exclude-libs,libunwind.a") + flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,--exclude-libs,libunwind.a") } case "": // None or error. if !ctx.toolchain().Bionic() { - flags.CppFlags = append(flags.CppFlags, "-nostdinc++") + flags.Local.CppFlags = append(flags.Local.CppFlags, "-nostdinc++") flags.extraLibFlags = append(flags.extraLibFlags, "-nostdlib++") } default: diff --git a/cc/test.go b/cc/test.go index 5c49d6e2b..05e6fe5e5 100644 --- a/cc/test.go +++ b/cc/test.go @@ -220,20 +220,20 @@ func (test *testDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags { return flags } - flags.CFlags = append(flags.CFlags, "-DGTEST_HAS_STD_STRING") + flags.Local.CFlags = append(flags.Local.CFlags, "-DGTEST_HAS_STD_STRING") if ctx.Host() { - flags.CFlags = append(flags.CFlags, "-O0", "-g") + flags.Local.CFlags = append(flags.Local.CFlags, "-O0", "-g") switch ctx.Os() { case android.Windows: - flags.CFlags = append(flags.CFlags, "-DGTEST_OS_WINDOWS") + flags.Local.CFlags = append(flags.Local.CFlags, "-DGTEST_OS_WINDOWS") case android.Linux: - flags.CFlags = append(flags.CFlags, "-DGTEST_OS_LINUX") + flags.Local.CFlags = append(flags.Local.CFlags, "-DGTEST_OS_LINUX") case android.Darwin: - flags.CFlags = append(flags.CFlags, "-DGTEST_OS_MAC") + flags.Local.CFlags = append(flags.Local.CFlags, "-DGTEST_OS_MAC") } } else { - flags.CFlags = append(flags.CFlags, "-DGTEST_OS_LINUX_ANDROID") + flags.Local.CFlags = append(flags.Local.CFlags, "-DGTEST_OS_LINUX_ANDROID") } return flags diff --git a/cc/util.go b/cc/util.go index 2f7bec2bb..6404489ac 100644 --- a/cc/util.go +++ b/cc/util.go @@ -55,27 +55,27 @@ func moduleToLibName(module string) (string, error) { func flagsToBuilderFlags(in Flags) builderFlags { return builderFlags{ - globalFlags: strings.Join(in.GlobalFlags, " "), - arFlags: strings.Join(in.ArFlags, " "), - asFlags: strings.Join(in.AsFlags, " "), - cFlags: strings.Join(in.CFlags, " "), - toolingCFlags: strings.Join(in.ToolingCFlags, " "), - toolingCppFlags: strings.Join(in.ToolingCppFlags, " "), - conlyFlags: strings.Join(in.ConlyFlags, " "), - cppFlags: strings.Join(in.CppFlags, " "), - aidlFlags: strings.Join(in.aidlFlags, " "), - rsFlags: strings.Join(in.rsFlags, " "), - ldFlags: strings.Join(in.LdFlags, " "), - libFlags: strings.Join(in.libFlags, " "), - extraLibFlags: strings.Join(in.extraLibFlags, " "), - tidyFlags: strings.Join(in.TidyFlags, " "), - sAbiFlags: strings.Join(in.SAbiFlags, " "), - yasmFlags: strings.Join(in.YasmFlags, " "), - toolchain: in.Toolchain, - coverage: in.Coverage, - tidy: in.Tidy, - sAbiDump: in.SAbiDump, - emitXrefs: in.EmitXrefs, + commonFlags: strings.Join(append(android.CopyOf(in.Global.CommonFlags), in.Local.CommonFlags...), " "), + asFlags: strings.Join(append(android.CopyOf(in.Global.AsFlags), in.Local.AsFlags...), " "), + yasmFlags: strings.Join(append(android.CopyOf(in.Global.YasmFlags), in.Local.YasmFlags...), " "), + cFlags: strings.Join(append(android.CopyOf(in.Global.CFlags), in.Local.CFlags...), " "), + toolingCFlags: strings.Join(append(android.CopyOf(in.Global.ToolingCFlags), in.Local.ToolingCFlags...), " "), + toolingCppFlags: strings.Join(append(android.CopyOf(in.Global.ToolingCppFlags), in.Local.ToolingCppFlags...), " "), + conlyFlags: strings.Join(append(android.CopyOf(in.Global.ConlyFlags), in.Local.ConlyFlags...), " "), + cppFlags: strings.Join(append(android.CopyOf(in.Global.CppFlags), in.Local.CppFlags...), " "), + ldFlags: strings.Join(append(android.CopyOf(in.Global.LdFlags), in.Local.LdFlags...), " "), + + aidlFlags: strings.Join(in.aidlFlags, " "), + rsFlags: strings.Join(in.rsFlags, " "), + libFlags: strings.Join(in.libFlags, " "), + extraLibFlags: strings.Join(in.extraLibFlags, " "), + tidyFlags: strings.Join(in.TidyFlags, " "), + sAbiFlags: strings.Join(in.SAbiFlags, " "), + toolchain: in.Toolchain, + coverage: in.Coverage, + tidy: in.Tidy, + sAbiDump: in.SAbiDump, + emitXrefs: in.EmitXrefs, systemIncludeFlags: strings.Join(in.SystemIncludeFlags, " "), diff --git a/cc/vendor_public_library.go b/cc/vendor_public_library.go index f0de267c1..e9d1c7378 100644 --- a/cc/vendor_public_library.go +++ b/cc/vendor_public_library.go @@ -124,7 +124,7 @@ func (stub *vendorPublicLibraryStubDecorator) link(ctx ModuleContext, flags Flag objs Objects) android.Path { if !Bool(stub.Properties.Unversioned) { linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String() - flags.LdFlags = append(flags.LdFlags, linkerScriptFlag) + flags.Local.LdFlags = append(flags.Local.LdFlags, linkerScriptFlag) flags.LdFlagsDeps = append(flags.LdFlagsDeps, stub.versionScriptPath) } return stub.libraryDecorator.link(ctx, flags, deps, objs) diff --git a/cc/xom.go b/cc/xom.go index 9337990f8..e1cac53fa 100644 --- a/cc/xom.go +++ b/cc/xom.go @@ -68,7 +68,7 @@ func (xom *xom) flags(ctx ModuleContext, flags Flags) Flags { if !disableXom || (xom.Properties.Xom != nil && *xom.Properties.Xom) { // XOM is only supported on AArch64 when using lld. if ctx.Arch().ArchType == android.Arm64 && ctx.useClangLld(ctx) { - flags.LdFlags = append(flags.LdFlags, "-Wl,-execute-only") + flags.Local.LdFlags = append(flags.Local.LdFlags, "-Wl,-execute-only") } }