diff options
Diffstat (limited to 'cc')
-rw-r--r-- | cc/androidmk.go | 12 | ||||
-rw-r--r-- | cc/binary.go | 2 | ||||
-rw-r--r-- | cc/builder.go | 20 | ||||
-rw-r--r-- | cc/cc.go | 72 | ||||
-rw-r--r-- | cc/compiler.go | 5 | ||||
-rw-r--r-- | cc/kernel_headers.go | 4 | ||||
-rw-r--r-- | cc/library.go | 155 | ||||
-rw-r--r-- | cc/linker.go | 8 | ||||
-rw-r--r-- | cc/llndk_library.go | 11 | ||||
-rw-r--r-- | cc/ndk_library.go | 5 | ||||
-rw-r--r-- | cc/ndk_prebuilt.go | 2 | ||||
-rw-r--r-- | cc/prebuilt.go | 8 | ||||
-rw-r--r-- | cc/sabi.go | 4 | ||||
-rw-r--r-- | cc/util.go | 4 | ||||
-rw-r--r-- | cc/vendor_public_library.go | 1 |
15 files changed, 171 insertions, 142 deletions
diff --git a/cc/androidmk.go b/cc/androidmk.go index 32ccf4c15..272d3d443 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -156,12 +156,18 @@ func makeOverrideModuleNames(ctx AndroidMkContext, overrides []string) []string func (library *libraryDecorator) androidMkWriteExportedFlags(w io.Writer) { exportedFlags := library.exportedFlags() + for _, dir := range library.exportedDirs() { + exportedFlags = append(exportedFlags, "-I"+dir) + } + for _, dir := range library.exportedSystemDirs() { + exportedFlags = append(exportedFlags, "-isystem "+dir) + } if len(exportedFlags) > 0 { fmt.Fprintln(w, "LOCAL_EXPORT_CFLAGS :=", strings.Join(exportedFlags, " ")) } - exportedFlagsDeps := library.exportedFlagsDeps() - if len(exportedFlagsDeps) > 0 { - fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DEPS :=", strings.Join(exportedFlagsDeps.Strings(), " ")) + exportedDeps := library.exportedDeps() + if len(exportedDeps) > 0 { + fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DEPS :=", strings.Join(exportedDeps.Strings(), " ")) } } diff --git a/cc/binary.go b/cc/binary.go index 476803fc5..d0909f166 100644 --- a/cc/binary.go +++ b/cc/binary.go @@ -388,7 +388,7 @@ func (binary *binaryDecorator) link(ctx ModuleContext, TransformObjToDynamicBinary(ctx, objs.objFiles, sharedLibs, deps.StaticLibs, deps.LateStaticLibs, deps.WholeStaticLibs, linkerDeps, deps.CrtBegin, deps.CrtEnd, true, - builderFlags, outputFile) + builderFlags, outputFile, nil) objs.coverageFiles = append(objs.coverageFiles, deps.StaticLibObjs.coverageFiles...) objs.coverageFiles = append(objs.coverageFiles, deps.WholeStaticLibObjs.coverageFiles...) diff --git a/cc/builder.go b/cc/builder.go index d2727b3bf..7cf5c291f 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -26,6 +26,7 @@ import ( "strings" "github.com/google/blueprint" + "github.com/google/blueprint/pathtools" "android/soong/android" "android/soong/cc/config" @@ -611,7 +612,7 @@ func transformDarwinObjToStaticLib(ctx android.ModuleContext, objFiles android.P // and shared libraries, to a shared library (.so) or dynamic executable func TransformObjToDynamicBinary(ctx android.ModuleContext, objFiles, sharedLibs, staticLibs, lateStaticLibs, wholeStaticLibs, deps android.Paths, - crtBegin, crtEnd android.OptionalPath, groupLate bool, flags builderFlags, outputFile android.WritablePath) { + crtBegin, crtEnd android.OptionalPath, groupLate bool, flags builderFlags, outputFile android.WritablePath, implicitOutputs android.WritablePaths) { ldCmd := "${config.ClangBin}/clang++" @@ -648,7 +649,11 @@ func TransformObjToDynamicBinary(ctx android.ModuleContext, } for _, lib := range sharedLibs { - libFlagsList = append(libFlagsList, lib.String()) + libFile := lib.String() + if ctx.Windows() { + libFile = pathtools.ReplaceExtension(libFile, "lib") + } + libFlagsList = append(libFlagsList, libFile) } deps = append(deps, staticLibs...) @@ -659,11 +664,12 @@ func TransformObjToDynamicBinary(ctx android.ModuleContext, } ctx.Build(pctx, android.BuildParams{ - Rule: ld, - Description: "link " + outputFile.Base(), - Output: outputFile, - Inputs: objFiles, - Implicits: deps, + Rule: ld, + Description: "link " + outputFile.Base(), + Output: outputFile, + ImplicitOutputs: implicitOutputs, + Inputs: objFiles, + Implicits: deps, Args: map[string]string{ "ldCmd": ldCmd, "crtBegin": crtBegin.String(), @@ -119,8 +119,13 @@ type PathDeps struct { GeneratedSources android.Paths GeneratedHeaders android.Paths - Flags, ReexportedFlags []string - ReexportedFlagsDeps android.Paths + Flags []string + IncludeDirs []string + SystemIncludeDirs []string + ReexportedDirs []string + ReexportedSystemDirs []string + ReexportedFlags []string + ReexportedDeps android.Paths // Paths to crt*.o files CrtBegin, CrtEnd android.OptionalPath @@ -278,7 +283,7 @@ type ModuleContext interface { } type BaseModuleContext interface { - android.BaseContext + android.BaseModuleContext ModuleContextIntf } @@ -641,7 +646,7 @@ func installToBootstrap(name string, config android.Config) bool { } type baseModuleContext struct { - android.BaseContext + android.BaseModuleContext moduleContextImpl } @@ -988,6 +993,14 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { flags.ConlyFlags, _ = filterList(flags.ConlyFlags, config.IllegalFlags) flags.GlobalFlags = append(flags.GlobalFlags, deps.Flags...) + + for _, dir := range deps.IncludeDirs { + flags.GlobalFlags = append(flags.GlobalFlags, "-I"+dir) + } + for _, dir := range deps.SystemIncludeDirs { + flags.GlobalFlags = append(flags.GlobalFlags, "-isystem "+dir) + } + c.flags = flags // We need access to all the flags seen by a source file. if c.sabi != nil { @@ -1040,7 +1053,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { } } -func (c *Module) toolchain(ctx android.BaseContext) config.Toolchain { +func (c *Module) toolchain(ctx android.BaseModuleContext) config.Toolchain { if c.cachedToolchain == nil { c.cachedToolchain = config.FindToolchain(ctx.Os(), ctx.Arch()) } @@ -1161,7 +1174,7 @@ func (c *Module) deps(ctx DepsContext) Deps { func (c *Module) beginMutator(actx android.BottomUpMutatorContext) { ctx := &baseModuleContext{ - BaseContext: actx, + BaseModuleContext: actx, moduleContextImpl: moduleContextImpl{ mod: c, }, @@ -1578,6 +1591,13 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { llndkLibraries := llndkLibraries(ctx.Config()) vendorPublicLibraries := vendorPublicLibraries(ctx.Config()) + reexportExporter := func(exporter exportedFlagsProducer) { + depPaths.ReexportedDirs = append(depPaths.ReexportedDirs, exporter.exportedDirs()...) + depPaths.ReexportedSystemDirs = append(depPaths.ReexportedSystemDirs, exporter.exportedSystemDirs()...) + depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, exporter.exportedFlags()...) + depPaths.ReexportedDeps = append(depPaths.ReexportedDeps, exporter.exportedDeps()...) + } + ctx.VisitDirectDeps(func(dep android.Module) { depName := ctx.OtherModuleName(dep) depTag := ctx.OtherModuleDependencyTag(dep) @@ -1599,14 +1619,13 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { if genRule, ok := dep.(genrule.SourceFileGenerator); ok { depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, genRule.GeneratedDeps()...) - flags := includeDirsToFlags(genRule.GeneratedHeaderDirs()) - depPaths.Flags = append(depPaths.Flags, flags) + dirs := genRule.GeneratedHeaderDirs().Strings() + depPaths.IncludeDirs = append(depPaths.IncludeDirs, dirs...) if depTag == genHeaderExportDepTag { - depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags) - depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, - genRule.GeneratedDeps()...) + depPaths.ReexportedDirs = append(depPaths.ReexportedDirs, dirs...) + depPaths.ReexportedDeps = append(depPaths.ReexportedDeps, genRule.GeneratedDeps()...) // Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library. - c.sabi.Properties.ReexportedIncludeFlags = append(c.sabi.Properties.ReexportedIncludeFlags, flags) + c.sabi.Properties.ReexportedIncludes = append(c.sabi.Properties.ReexportedIncludes, dirs...) } } else { @@ -1644,10 +1663,9 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { if depTag == reuseObjTag { if l, ok := ccDep.compiler.(libraryInterface); ok { c.staticVariant = ccDep - objs, flags, deps := l.reuseObjs() + objs, exporter := l.reuseObjs() depPaths.Objs = depPaths.Objs.Append(objs) - depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...) - depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, deps...) + reexportExporter(exporter) return } } @@ -1710,18 +1728,20 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { } if i, ok := ccDep.linker.(exportedFlagsProducer); ok { - flags := i.exportedFlags() - deps := i.exportedFlagsDeps() - depPaths.Flags = append(depPaths.Flags, flags...) - depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, deps...) + depPaths.IncludeDirs = append(depPaths.IncludeDirs, i.exportedDirs()...) + depPaths.SystemIncludeDirs = append(depPaths.SystemIncludeDirs, i.exportedSystemDirs()...) + depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, i.exportedDeps()...) + depPaths.Flags = append(depPaths.Flags, i.exportedFlags()...) if t.reexportFlags { - depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...) - depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, deps...) + reexportExporter(i) // Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library. // Re-exported shared library headers must be included as well since they can help us with type information // about template instantiations (instantiated from their headers). - c.sabi.Properties.ReexportedIncludeFlags = append(c.sabi.Properties.ReexportedIncludeFlags, flags...) + // -isystem headers are not included since for bionic libraries, abi-filtering is taken care of by version + // scripts. + c.sabi.Properties.ReexportedIncludes = append( + c.sabi.Properties.ReexportedIncludes, i.exportedDirs()...) } } @@ -1883,12 +1903,16 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps { // Dedup exported flags from dependencies depPaths.Flags = android.FirstUniqueStrings(depPaths.Flags) + depPaths.IncludeDirs = android.FirstUniqueStrings(depPaths.IncludeDirs) + depPaths.SystemIncludeDirs = android.FirstUniqueStrings(depPaths.SystemIncludeDirs) depPaths.GeneratedHeaders = android.FirstUniquePaths(depPaths.GeneratedHeaders) + depPaths.ReexportedDirs = android.FirstUniqueStrings(depPaths.ReexportedDirs) + depPaths.ReexportedSystemDirs = android.FirstUniqueStrings(depPaths.ReexportedSystemDirs) depPaths.ReexportedFlags = android.FirstUniqueStrings(depPaths.ReexportedFlags) - depPaths.ReexportedFlagsDeps = android.FirstUniquePaths(depPaths.ReexportedFlagsDeps) + depPaths.ReexportedDeps = android.FirstUniquePaths(depPaths.ReexportedDeps) if c.sabi != nil { - c.sabi.Properties.ReexportedIncludeFlags = android.FirstUniqueStrings(c.sabi.Properties.ReexportedIncludeFlags) + c.sabi.Properties.ReexportedIncludes = android.FirstUniqueStrings(c.sabi.Properties.ReexportedIncludes) } return depPaths diff --git a/cc/compiler.go b/cc/compiler.go index 7667ae7ab..fd6184b3a 100644 --- a/cc/compiler.go +++ b/cc/compiler.go @@ -225,11 +225,6 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps { deps = protoDeps(ctx, deps, &compiler.Proto, Bool(compiler.Properties.Proto.Static)) } - if compiler.hasSrcExt(".sysprop") { - deps.HeaderLibs = append(deps.HeaderLibs, "libbase_headers") - deps.SharedLibs = append(deps.SharedLibs, "liblog") - } - if Bool(compiler.Properties.Openmp) { deps.StaticLibs = append(deps.StaticLibs, "libomp") } diff --git a/cc/kernel_headers.go b/cc/kernel_headers.go index c1da578b5..fff419e60 100644 --- a/cc/kernel_headers.go +++ b/cc/kernel_headers.go @@ -25,9 +25,7 @@ type kernelHeadersDecorator struct { func (stub *kernelHeadersDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path { if ctx.Device() { f := &stub.libraryDecorator.flagExporter - for _, dir := range ctx.DeviceConfig().DeviceKernelHeaderDirs() { - f.flags = append(f.flags, "-isystem "+dir) - } + f.reexportSystemDirs(ctx.DeviceConfig().DeviceKernelHeaderDirs()...) } return stub.libraryDecorator.linkStatic(ctx, flags, deps, objs) } diff --git a/cc/library.go b/cc/library.go index d9c00dc56..725208ac3 100644 --- a/cc/library.go +++ b/cc/library.go @@ -15,6 +15,7 @@ package cc import ( + "fmt" "io" "path/filepath" "regexp" @@ -207,8 +208,10 @@ func LibraryHeaderFactory() android.Module { type flagExporter struct { Properties FlagExporterProperties - flags []string - flagsDeps android.Paths + dirs []string + systemDirs []string + flags []string + deps android.Paths } func (f *flagExporter) exportedIncludes(ctx ModuleContext) android.Paths { @@ -219,32 +222,57 @@ func (f *flagExporter) exportedIncludes(ctx ModuleContext) android.Paths { } } -func (f *flagExporter) exportIncludes(ctx ModuleContext, inc string) { - includeDirs := f.exportedIncludes(ctx) - for _, dir := range includeDirs.Strings() { - f.flags = append(f.flags, inc+dir) - } +func (f *flagExporter) exportIncludes(ctx ModuleContext) { + f.dirs = append(f.dirs, f.exportedIncludes(ctx).Strings()...) +} + +func (f *flagExporter) exportIncludesAsSystem(ctx ModuleContext) { + f.systemDirs = append(f.systemDirs, f.exportedIncludes(ctx).Strings()...) +} + +func (f *flagExporter) reexportDirs(dirs ...string) { + f.dirs = append(f.dirs, dirs...) +} + +func (f *flagExporter) reexportSystemDirs(dirs ...string) { + f.systemDirs = append(f.systemDirs, dirs...) } -func (f *flagExporter) reexportFlags(flags []string) { +func (f *flagExporter) reexportFlags(flags ...string) { + for _, flag := range flags { + if strings.HasPrefix(flag, "-I") || strings.HasPrefix(flag, "-isystem") { + panic(fmt.Errorf("Exporting invalid flag %q: "+ + "use reexportDirs or reexportSystemDirs to export directories", flag)) + } + } f.flags = append(f.flags, flags...) } -func (f *flagExporter) reexportDeps(deps android.Paths) { - f.flagsDeps = append(f.flagsDeps, deps...) +func (f *flagExporter) reexportDeps(deps ...android.Path) { + f.deps = append(f.deps, deps...) +} + +func (f *flagExporter) exportedDirs() []string { + return f.dirs +} + +func (f *flagExporter) exportedSystemDirs() []string { + return f.systemDirs } func (f *flagExporter) exportedFlags() []string { return f.flags } -func (f *flagExporter) exportedFlagsDeps() android.Paths { - return f.flagsDeps +func (f *flagExporter) exportedDeps() android.Paths { + return f.deps } type exportedFlagsProducer interface { + exportedDirs() []string + exportedSystemDirs() []string exportedFlags() []string - exportedFlagsDeps() android.Paths + exportedDeps() android.Paths } var _ exportedFlagsProducer = (*flagExporter)(nil) @@ -256,9 +284,7 @@ type libraryDecorator struct { MutatedProperties LibraryMutatedProperties // For reusing static library objects for shared library - reuseObjects Objects - reuseExportedFlags []string - reuseExportedDeps android.Paths + reuseObjects Objects // table-of-contents file to optimize out relinking when possible tocFile android.OptionalPath @@ -360,9 +386,10 @@ func (library *libraryDecorator) linkerFlags(ctx ModuleContext, flags Flags) Fla ) } } else { - f = append(f, - "-shared", - "-Wl,-soname,"+libName+flags.Toolchain.ShlibSuffix()) + f = append(f, "-shared") + if !ctx.Windows() { + f = append(f, "-Wl,-soname,"+libName+flags.Toolchain.ShlibSuffix()) + } } flags.LdFlags = append(f, flags.LdFlags...) @@ -404,25 +431,6 @@ func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags, d return flags } -func extractExportIncludesFromFlags(flags []string) []string { - // This method is used in the generation of rules which produce - // abi-dumps for source files. Exported headers are needed to infer the - // abi exported by a library and filter out the rest of the abi dumped - // from a source. We extract the include flags exported by a library. - // This includes the flags exported which are re-exported from static - // library dependencies, exported header library dependencies and - // generated header dependencies. -isystem headers are not included - // since for bionic libraries, abi-filtering is taken care of by version - // scripts. - var exportedIncludes []string - for _, flag := range flags { - if strings.HasPrefix(flag, "-I") { - exportedIncludes = append(exportedIncludes, flag) - } - } - return exportedIncludes -} - func (library *libraryDecorator) shouldCreateVndkSourceAbiDump(ctx ModuleContext) bool { if library.Properties.Header_abi_checker.Enabled != nil { return Bool(library.Properties.Header_abi_checker.Enabled) @@ -455,8 +463,8 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa for _, dir := range exportIncludeDirs.Strings() { SourceAbiFlags = append(SourceAbiFlags, "-I"+dir) } - for _, reexportedInclude := range extractExportIncludesFromFlags(library.sabi.Properties.ReexportedIncludeFlags) { - SourceAbiFlags = append(SourceAbiFlags, reexportedInclude) + for _, reexportedInclude := range library.sabi.Properties.ReexportedIncludes { + SourceAbiFlags = append(SourceAbiFlags, "-I"+reexportedInclude) } flags.SAbiFlags = SourceAbiFlags total_length := len(library.baseCompiler.Properties.Srcs) + len(deps.GeneratedSources) + len(library.Properties.Shared.Srcs) + @@ -486,7 +494,7 @@ type libraryInterface interface { getWholeStaticMissingDeps() []string static() bool objs() Objects - reuseObjs() (Objects, []string, android.Paths) + reuseObjs() (Objects, exportedFlagsProducer) toc() android.OptionalPath // Returns true if the build options for the module have selected a static or shared build @@ -696,6 +704,14 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext, outputFile := android.PathForModuleOut(ctx, fileName) ret := outputFile + var implicitOutputs android.WritablePaths + if ctx.Windows() { + importLibraryPath := android.PathForModuleOut(ctx, pathtools.ReplaceExtension(fileName, "lib")) + + flags.LdFlags = append(flags.LdFlags, "-Wl,--out-implib="+importLibraryPath.String()) + implicitOutputs = append(implicitOutputs, importLibraryPath) + } + builderFlags := flagsToBuilderFlags(flags) // Optimize out relinking against shared libraries whose interface hasn't changed by @@ -747,7 +763,7 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext, TransformObjToDynamicBinary(ctx, objs.objFiles, sharedLibs, deps.StaticLibs, deps.LateStaticLibs, deps.WholeStaticLibs, - linkerDeps, deps.CrtBegin, deps.CrtEnd, false, builderFlags, outputFile) + linkerDeps, deps.CrtBegin, deps.CrtEnd, false, builderFlags, outputFile, implicitOutputs) objs.coverageFiles = append(objs.coverageFiles, deps.StaticLibObjs.coverageFiles...) objs.coverageFiles = append(objs.coverageFiles, deps.WholeStaticLibObjs.coverageFiles...) @@ -805,8 +821,8 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec for _, dir := range exportIncludeDirs.Strings() { SourceAbiFlags = append(SourceAbiFlags, "-I"+dir) } - for _, reexportedInclude := range extractExportIncludesFromFlags(library.sabi.Properties.ReexportedIncludeFlags) { - SourceAbiFlags = append(SourceAbiFlags, reexportedInclude) + for _, reexportedInclude := range library.sabi.Properties.ReexportedIncludes { + SourceAbiFlags = append(SourceAbiFlags, "-I"+reexportedInclude) } exportedHeaderFlags := strings.Join(SourceAbiFlags, " ") library.sAbiOutputFile = TransformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, fileName, exportedHeaderFlags, @@ -833,19 +849,17 @@ func (library *libraryDecorator) link(ctx ModuleContext, out = library.linkShared(ctx, flags, deps, objs) } - library.exportIncludes(ctx, "-I") - library.reexportFlags(deps.ReexportedFlags) - library.reexportDeps(deps.ReexportedFlagsDeps) + library.exportIncludes(ctx) + library.reexportDirs(deps.ReexportedDirs...) + library.reexportSystemDirs(deps.ReexportedSystemDirs...) + library.reexportFlags(deps.ReexportedFlags...) + library.reexportDeps(deps.ReexportedDeps...) if Bool(library.Properties.Aidl.Export_aidl_headers) { if library.baseCompiler.hasSrcExt(".aidl") { - flags := []string{ - "-I" + android.PathForModuleGen(ctx, "aidl").String(), - } - library.reexportFlags(flags) - library.reuseExportedFlags = append(library.reuseExportedFlags, flags...) - library.reexportDeps(library.baseCompiler.pathDeps) // TODO: restrict to aidl deps - library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.pathDeps...) + dir := android.PathForModuleGen(ctx, "aidl").String() + library.reexportDirs(dir) + library.reexportDeps(library.baseCompiler.pathDeps...) // TODO: restrict to aidl deps } } @@ -853,26 +867,16 @@ func (library *libraryDecorator) link(ctx ModuleContext, if library.baseCompiler.hasSrcExt(".proto") { includes := []string{} if flags.proto.CanonicalPathFromRoot { - includes = append(includes, "-I"+flags.proto.SubDir.String()) + includes = append(includes, flags.proto.SubDir.String()) } - includes = append(includes, "-I"+flags.proto.Dir.String()) - library.reexportFlags(includes) - library.reuseExportedFlags = append(library.reuseExportedFlags, includes...) - library.reexportDeps(library.baseCompiler.pathDeps) // TODO: restrict to proto deps - library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.pathDeps...) + includes = append(includes, flags.proto.Dir.String()) + library.reexportDirs(includes...) + library.reexportDeps(library.baseCompiler.pathDeps...) // TODO: restrict to proto deps } } if library.baseCompiler.hasSrcExt(".sysprop") { - internalFlags := []string{ - "-I" + android.PathForModuleGen(ctx, "sysprop", "include").String(), - } - systemFlags := []string{ - "-I" + android.PathForModuleGen(ctx, "sysprop/system", "include").String(), - } - - flags := internalFlags - + dir := android.PathForModuleGen(ctx, "sysprop", "include").String() if library.Properties.Sysprop.Platform != nil { isProduct := ctx.ProductSpecific() && !ctx.useVndk() isVendor := ctx.useVndk() @@ -881,17 +885,16 @@ func (library *libraryDecorator) link(ctx ModuleContext, useSystem := isProduct || (isOwnerPlatform == isVendor) if useSystem { - flags = systemFlags + dir = android.PathForModuleGen(ctx, "sysprop/system", "include").String() } } - library.reexportFlags(flags) - library.reexportDeps(library.baseCompiler.pathDeps) - library.reuseExportedFlags = append(library.reuseExportedFlags, flags...) + library.reexportDirs(dir) + library.reexportDeps(library.baseCompiler.pathDeps...) } if library.buildStubs() { - library.reexportFlags([]string{"-D" + versioningMacroName(ctx.ModuleName()) + "=" + library.stubsVersion()}) + library.reexportFlags("-D" + versioningMacroName(ctx.ModuleName()) + "=" + library.stubsVersion()) } return out @@ -913,8 +916,8 @@ func (library *libraryDecorator) objs() Objects { return library.objects } -func (library *libraryDecorator) reuseObjs() (Objects, []string, android.Paths) { - return library.reuseObjects, library.reuseExportedFlags, library.reuseExportedDeps +func (library *libraryDecorator) reuseObjs() (Objects, exportedFlagsProducer) { + return library.reuseObjects, &library.flagExporter } func (library *libraryDecorator) toc() android.OptionalPath { diff --git a/cc/linker.go b/cc/linker.go index fafefdc69..dda2fcb33 100644 --- a/cc/linker.go +++ b/cc/linker.go @@ -295,10 +295,6 @@ func (linker *baseLinker) useClangLld(ctx ModuleContext) bool { if ctx.Darwin() { return false } - // http://b/110800681 - lld cannot link Android's Windows modules yet. - if ctx.Windows() { - return false - } if linker.Properties.Use_clang_lld != nil { return Bool(linker.Properties.Use_clang_lld) } @@ -352,7 +348,7 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags { // darwin defaults to treating undefined symbols as errors flags.LdFlags = append(flags.LdFlags, "-Wl,-undefined,dynamic_lookup") } - } else if !ctx.Darwin() { + } else if !ctx.Darwin() && !ctx.Windows() { flags.LdFlags = append(flags.LdFlags, "-Wl,--no-undefined") } @@ -389,7 +385,7 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags { flags.LdFlags = append(flags.LdFlags, proptools.NinjaAndShellEscapeList(linker.Properties.Ldflags)...) - if ctx.Host() { + if ctx.Host() && !ctx.Windows() { rpath_prefix := `\$$ORIGIN/` if ctx.Darwin() { rpath_prefix = "@loader_path/" diff --git a/cc/llndk_library.go b/cc/llndk_library.go index 6cdf5c700..82901037b 100644 --- a/cc/llndk_library.go +++ b/cc/llndk_library.go @@ -134,6 +134,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.LdFlagsDeps = append(flags.LdFlagsDeps, stub.versionScriptPath) } if len(stub.Properties.Export_preprocessed_headers) > 0 { @@ -144,17 +145,17 @@ func (stub *llndkStubDecorator) link(ctx ModuleContext, flags Flags, deps PathDe timestampFiles = append(timestampFiles, stub.processHeaders(ctx, dir, genHeaderOutDir)) } - includePrefix := "-I" if Bool(stub.Properties.Export_headers_as_system) { - includePrefix = "-isystem " + stub.reexportSystemDirs(genHeaderOutDir.String()) + } else { + stub.reexportDirs(genHeaderOutDir.String()) } - stub.reexportFlags([]string{includePrefix + genHeaderOutDir.String()}) - stub.reexportDeps(timestampFiles) + stub.reexportDeps(timestampFiles...) } if Bool(stub.Properties.Export_headers_as_system) { - stub.exportIncludes(ctx, "-isystem ") + stub.exportIncludesAsSystem(ctx) stub.libraryDecorator.flagExporter.Properties.Export_include_dirs = []string{} } diff --git a/cc/ndk_library.go b/cc/ndk_library.go index ff990b5f7..969cb3fa7 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -121,7 +121,7 @@ func intMax(a int, b int) int { } } -func normalizeNdkApiLevel(ctx android.BaseContext, apiLevel string, +func normalizeNdkApiLevel(ctx android.BaseModuleContext, apiLevel string, arch android.Arch) (string, error) { if apiLevel == "current" { @@ -167,7 +167,7 @@ func getFirstGeneratedVersion(firstSupportedVersion string, platformVersion int) return strconv.Atoi(firstSupportedVersion) } -func shouldUseVersionScript(ctx android.BaseContext, stub *stubDecorator) (bool, error) { +func shouldUseVersionScript(ctx android.BaseModuleContext, stub *stubDecorator) (bool, error) { // unversioned_until is normally empty, in which case we should use the version script. if String(stub.properties.Unversioned_until) == "" { return true, nil @@ -337,6 +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.LdFlagsDeps = append(flags.LdFlagsDeps, stub.versionScriptPath) } return stub.libraryDecorator.link(ctx, flags, deps, objs) diff --git a/cc/ndk_prebuilt.go b/cc/ndk_prebuilt.go index fb168872b..4356732ef 100644 --- a/cc/ndk_prebuilt.go +++ b/cc/ndk_prebuilt.go @@ -151,7 +151,7 @@ func (ndk *ndkPrebuiltStlLinker) link(ctx ModuleContext, flags Flags, ctx.ModuleErrorf("NDK prebuilt libraries must have an ndk_lib prefixed name") } - ndk.exportIncludes(ctx, "-isystem ") + ndk.exportIncludesAsSystem(ctx) libName := strings.TrimPrefix(ctx.ModuleName(), "ndk_") libExt := flags.Toolchain.ShlibSuffix() diff --git a/cc/prebuilt.go b/cc/prebuilt.go index f92c50d1e..dc6c43a7c 100644 --- a/cc/prebuilt.go +++ b/cc/prebuilt.go @@ -85,9 +85,11 @@ func (p *prebuiltLibraryLinker) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path { // TODO(ccross): verify shared library dependencies if len(p.properties.Srcs) > 0 { - p.libraryDecorator.exportIncludes(ctx, "-I") - p.libraryDecorator.reexportFlags(deps.ReexportedFlags) - p.libraryDecorator.reexportDeps(deps.ReexportedFlagsDeps) + p.libraryDecorator.exportIncludes(ctx) + p.libraryDecorator.reexportDirs(deps.ReexportedDirs...) + p.libraryDecorator.reexportSystemDirs(deps.ReexportedSystemDirs...) + p.libraryDecorator.reexportFlags(deps.ReexportedFlags...) + p.libraryDecorator.reexportDeps(deps.ReexportedDeps...) builderFlags := flagsToBuilderFlags(flags) diff --git a/cc/sabi.go b/cc/sabi.go index 451176f1b..ae7b31d28 100644 --- a/cc/sabi.go +++ b/cc/sabi.go @@ -28,8 +28,8 @@ var ( ) type SAbiProperties struct { - CreateSAbiDumps bool `blueprint:"mutated"` - ReexportedIncludeFlags []string + CreateSAbiDumps bool `blueprint:"mutated"` + ReexportedIncludes []string `blueprint:"mutated"` } type sabi struct { diff --git a/cc/util.go b/cc/util.go index 3862728bb..2e1bb2590 100644 --- a/cc/util.go +++ b/cc/util.go @@ -29,10 +29,6 @@ func includeDirsToFlags(dirs android.Paths) string { return android.JoinWithPrefix(dirs.Strings(), "-I") } -func includeFilesToFlags(files android.Paths) string { - return android.JoinWithPrefix(files.Strings(), "-include ") -} - func ldDirsToFlags(dirs []string) string { return android.JoinWithPrefix(dirs, "-L") } diff --git a/cc/vendor_public_library.go b/cc/vendor_public_library.go index 5738d25ab..f0de267c1 100644 --- a/cc/vendor_public_library.go +++ b/cc/vendor_public_library.go @@ -125,6 +125,7 @@ func (stub *vendorPublicLibraryStubDecorator) link(ctx ModuleContext, flags Flag if !Bool(stub.Properties.Unversioned) { linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String() flags.LdFlags = append(flags.LdFlags, linkerScriptFlag) + flags.LdFlagsDeps = append(flags.LdFlagsDeps, stub.versionScriptPath) } return stub.libraryDecorator.link(ctx, flags, deps, objs) } |