diff options
Diffstat (limited to 'cc')
-rw-r--r-- | cc/afdo.go | 5 | ||||
-rw-r--r-- | cc/androidmk.go | 5 | ||||
-rw-r--r-- | cc/binary.go | 2 | ||||
-rw-r--r-- | cc/bp2build.go | 7 | ||||
-rw-r--r-- | cc/cc.go | 12 | ||||
-rw-r--r-- | cc/fuzz.go | 8 | ||||
-rw-r--r-- | cc/genrule.go | 10 | ||||
-rw-r--r-- | cc/image.go | 2 | ||||
-rw-r--r-- | cc/library.go | 7 | ||||
-rw-r--r-- | cc/lto.go | 11 | ||||
-rw-r--r-- | cc/ndk_headers.go | 28 | ||||
-rw-r--r-- | cc/ndk_library.go | 11 | ||||
-rw-r--r-- | cc/prebuilt.go | 8 | ||||
-rw-r--r-- | cc/snapshot_prebuilt.go | 17 | ||||
-rw-r--r-- | cc/snapshot_utils.go | 2 | ||||
-rw-r--r-- | cc/test.go | 5 | ||||
-rw-r--r-- | cc/vendor_public_library.go | 21 | ||||
-rw-r--r-- | cc/vendor_snapshot.go | 2 | ||||
-rw-r--r-- | cc/vndk_prebuilt.go | 77 |
19 files changed, 132 insertions, 108 deletions
diff --git a/cc/afdo.go b/cc/afdo.go index 66e973284..fb66bbe52 100644 --- a/cc/afdo.go +++ b/cc/afdo.go @@ -66,8 +66,9 @@ func (afdo *afdo) AfdoEnabled() bool { } // Get list of profile file names, ordered by level of specialisation. For example: -// 1. libfoo_arm64.afdo -// 2. libfoo.afdo +// 1. libfoo_arm64.afdo +// 2. libfoo.afdo +// // Add more specialisation as needed. func getProfileFiles(ctx android.BaseModuleContext, moduleName string) []string { var files []string diff --git a/cc/androidmk.go b/cc/androidmk.go index 47fb919d0..779160c5d 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -411,14 +411,13 @@ func (test *testBinary) AndroidMkEntries(ctx AndroidMkContext, entries *android. entries.SetBool("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", true) } entries.AddStrings("LOCAL_TEST_MAINLINE_MODULES", test.Properties.Test_mainline_modules...) - if Bool(test.Properties.Test_options.Unit_test) { - entries.SetBool("LOCAL_IS_UNIT_TEST", true) - } entries.SetBoolIfTrue("LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY", Bool(test.Properties.Per_testcase_directory)) if len(test.Properties.Data_bins) > 0 { entries.AddStrings("LOCAL_TEST_DATA_BINS", test.Properties.Data_bins...) } + + test.Properties.Test_options.CommonTestOptions.SetAndroidMkEntries(entries) }) AndroidMkWriteTestData(test.data, entries) diff --git a/cc/binary.go b/cc/binary.go index b2f248282..849aafaaa 100644 --- a/cc/binary.go +++ b/cc/binary.go @@ -617,6 +617,7 @@ func binaryBp2build(ctx android.TopDownMutatorContext, m *Module, typ string) { Dynamic_deps: baseAttrs.implementationDynamicDeps, Whole_archive_deps: baseAttrs.wholeArchiveDeps, System_deps: baseAttrs.systemDynamicDeps, + Runtime_deps: baseAttrs.runtimeDeps, Local_includes: baseAttrs.localIncludes, Absolute_includes: baseAttrs.absoluteIncludes, @@ -667,6 +668,7 @@ type binaryAttributes struct { Dynamic_deps bazel.LabelListAttribute Whole_archive_deps bazel.LabelListAttribute System_deps bazel.LabelListAttribute + Runtime_deps bazel.LabelListAttribute Local_includes bazel.StringListAttribute Absolute_includes bazel.StringListAttribute diff --git a/cc/bp2build.go b/cc/bp2build.go index 61a55ee69..ba9343995 100644 --- a/cc/bp2build.go +++ b/cc/bp2build.go @@ -52,6 +52,7 @@ type staticOrSharedAttributes struct { Implementation_dynamic_deps bazel.LabelListAttribute Whole_archive_deps bazel.LabelListAttribute Implementation_whole_archive_deps bazel.LabelListAttribute + Runtime_deps bazel.LabelListAttribute System_dynamic_deps bazel.LabelListAttribute @@ -710,6 +711,7 @@ type linkerAttributes struct { implementationDeps bazel.LabelListAttribute dynamicDeps bazel.LabelListAttribute implementationDynamicDeps bazel.LabelListAttribute + runtimeDeps bazel.LabelListAttribute wholeArchiveDeps bazel.LabelListAttribute implementationWholeArchiveDeps bazel.LabelListAttribute systemDynamicDeps bazel.LabelListAttribute @@ -825,6 +827,11 @@ func (la *linkerAttributes) bp2buildForAxisAndConfig(ctx android.BazelConversion if axisFeatures != nil { la.features.SetSelectValue(axis, config, axisFeatures) } + + runtimeDeps := android.BazelLabelForModuleDepsExcludes(ctx, props.Runtime_libs, props.Exclude_runtime_libs) + if !runtimeDeps.IsEmpty() { + la.runtimeDeps.SetSelectValue(axis, config, runtimeDeps) + } } func (la *linkerAttributes) convertStripProps(ctx android.BazelConversionPathContext, module *Module) { @@ -514,6 +514,7 @@ type ModuleContextIntf interface { getVndkExtendsModuleName() string isAfdoCompile() bool isPgoCompile() bool + isCfi() bool isNDKStubLibrary() bool useClangLld(actx ModuleContext) bool isForPlatform() bool @@ -1314,6 +1315,13 @@ func (c *Module) isPgoCompile() bool { return false } +func (c *Module) isCfi() bool { + if sanitize := c.sanitize; sanitize != nil { + return Bool(sanitize.Properties.Sanitize.Cfi) + } + return false +} + func (c *Module) isNDKStubLibrary() bool { if _, ok := c.compiler.(*stubDecorator); ok { return true @@ -1592,6 +1600,10 @@ func (ctx *moduleContextImpl) isPgoCompile() bool { return ctx.mod.isPgoCompile() } +func (ctx *moduleContextImpl) isCfi() bool { + return ctx.mod.isCfi() +} + func (ctx *moduleContextImpl) isNDKStubLibrary() bool { return ctx.mod.isNDKStubLibrary() } diff --git a/cc/fuzz.go b/cc/fuzz.go index dfc718e85..8a8c10723 100644 --- a/cc/fuzz.go +++ b/cc/fuzz.go @@ -152,10 +152,10 @@ func UnstrippedOutputFile(module android.Module) android.Path { // IsValidSharedDependency takes a module and determines if it is a unique shared library // that should be installed in the fuzz target output directories. This function // returns true, unless: -// - The module is not an installable shared library, or -// - The module is a header or stub, or -// - The module is a prebuilt and its source is available, or -// - The module is a versioned member of an SDK snapshot. +// - The module is not an installable shared library, or +// - The module is a header or stub, or +// - The module is a prebuilt and its source is available, or +// - The module is a versioned member of an SDK snapshot. func IsValidSharedDependency(dependency android.Module) bool { // TODO(b/144090547): We should be parsing these modules using // ModuleDependencyTag instead of the current brute-force checking. diff --git a/cc/genrule.go b/cc/genrule.go index 239064f1c..4ef990c35 100644 --- a/cc/genrule.go +++ b/cc/genrule.go @@ -41,13 +41,13 @@ type GenruleExtraProperties struct { // variations. The following environment variables will be set when the command // execute: // -// CC_ARCH the name of the architecture the command is being executed for +// CC_ARCH the name of the architecture the command is being executed for // -// CC_MULTILIB "lib32" if the architecture the command is being executed for is 32-bit, -// "lib64" if it is 64-bit. +// CC_MULTILIB "lib32" if the architecture the command is being executed for is 32-bit, +// "lib64" if it is 64-bit. // -// CC_NATIVE_BRIDGE the name of the subdirectory that native bridge libraries are stored in if -// the architecture has native bridge enabled, empty if it is disabled. +// CC_NATIVE_BRIDGE the name of the subdirectory that native bridge libraries are stored in if +// the architecture has native bridge enabled, empty if it is disabled. func GenRuleFactory() android.Module { module := genrule.NewGenRule() diff --git a/cc/image.go b/cc/image.go index 921b2bb13..e65a9aadb 100644 --- a/cc/image.go +++ b/cc/image.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/cc/library.go b/cc/library.go index 897b57261..621b58c33 100644 --- a/cc/library.go +++ b/cc/library.go @@ -319,6 +319,7 @@ func libraryBp2Build(ctx android.TopDownMutatorContext, m *Module) { Implementation_whole_archive_deps: linkerAttrs.implementationWholeArchiveDeps, Whole_archive_deps: *linkerAttrs.wholeArchiveDeps.Clone().Append(staticAttrs.Whole_archive_deps), System_dynamic_deps: *linkerAttrs.systemDynamicDeps.Clone().Append(staticAttrs.System_dynamic_deps), + Runtime_deps: linkerAttrs.runtimeDeps, sdkAttributes: bp2BuildParseSdkAttributes(m), } @@ -335,6 +336,7 @@ func libraryBp2Build(ctx android.TopDownMutatorContext, m *Module) { Implementation_dynamic_deps: *linkerAttrs.implementationDynamicDeps.Clone().Append(sharedAttrs.Implementation_dynamic_deps), Whole_archive_deps: *linkerAttrs.wholeArchiveDeps.Clone().Append(sharedAttrs.Whole_archive_deps), System_dynamic_deps: *linkerAttrs.systemDynamicDeps.Clone().Append(sharedAttrs.System_dynamic_deps), + Runtime_deps: linkerAttrs.runtimeDeps, sdkAttributes: bp2BuildParseSdkAttributes(m), } @@ -1048,9 +1050,7 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa if ctx.Module().(android.ApexModule).NotInPlatform() { flag = "--apex" } else { - // TODO(b/239274367) drop --apex when #apex is replaced with #systemapi - // in the map.txt files of platform libraries - flag = "--systemapi --apex" + flag = "--systemapi" } nativeAbiResult := parseNativeAbiDefinition(ctx, symbolFile, android.ApiLevelOrPanic(ctx, library.MutatedProperties.StubsVersion), flag) @@ -2552,6 +2552,7 @@ func sharedOrStaticLibraryBp2Build(ctx android.TopDownMutatorContext, module *Mo Implementation_whole_archive_deps: linkerAttrs.implementationWholeArchiveDeps, System_dynamic_deps: linkerAttrs.systemDynamicDeps, sdkAttributes: bp2BuildParseSdkAttributes(module), + Runtime_deps: linkerAttrs.runtimeDeps, } var attrs interface{} @@ -136,9 +136,16 @@ func (lto *lto) LTO(ctx BaseModuleContext) bool { } func (lto *lto) DefaultThinLTO(ctx BaseModuleContext) bool { + // LP32 has many subtle issues and less test coverage. + lib32 := ctx.Arch().ArchType.Multilib == "lib32" + // CFI enables full LTO. + cfi := ctx.isCfi() + // Performance and binary size are less important for host binaries. host := ctx.Host() - vndk := ctx.isVndk() // b/169217596 - return GlobalThinLTO(ctx) && !lto.Never() && !host && !vndk + // FIXME: ThinLTO for VNDK produces different output. + // b/169217596 + vndk := ctx.isVndk() + return GlobalThinLTO(ctx) && !lto.Never() && !lib32 && !cfi && !host && !vndk } func (lto *lto) FullLTO() bool { diff --git a/cc/ndk_headers.go b/cc/ndk_headers.go index 56fd5fc81..ef38a064a 100644 --- a/cc/ndk_headers.go +++ b/cc/ndk_headers.go @@ -148,12 +148,12 @@ func (m *headerModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { // to the sysroot base + "usr/include" + to directory + directory component. // ndk_headers requires the license file to be specified. Example: // -// Given: -// sysroot base = "ndk/sysroot" -// from = "include/foo" -// to = "bar" -// header = "include/foo/woodly/doodly.h" -// output path = "ndk/sysroot/usr/include/bar/woodly/doodly.h" +// Given: +// sysroot base = "ndk/sysroot" +// from = "include/foo" +// to = "bar" +// header = "include/foo/woodly/doodly.h" +// output path = "ndk/sysroot/usr/include/bar/woodly/doodly.h" func ndkHeadersFactory() android.Module { module := &headerModule{} module.AddProperties(&module.properties) @@ -275,15 +275,17 @@ func versionedNdkHeadersFactory() android.Module { return module } -// preprocessed_ndk_header { -// name: "foo", -// preprocessor: "foo.sh", -// srcs: [...], -// to: "android", -// } +// preprocessed_ndk_header { +// name: "foo", +// preprocessor: "foo.sh", +// srcs: [...], +// to: "android", +// } // // Will invoke the preprocessor as: -// $preprocessor -o $SYSROOT/usr/include/android/needs_preproc.h $src +// +// $preprocessor -o $SYSROOT/usr/include/android/needs_preproc.h $src +// // For each src in srcs. type preprocessedHeadersProperties struct { // The preprocessor to run. Must be a program inside the source directory diff --git a/cc/ndk_library.go b/cc/ndk_library.go index 0879257a5..2bbfc4aee 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -84,12 +84,11 @@ var ( // // Example: // -// ndk_library { -// name: "libfoo", -// symbol_file: "libfoo.map.txt", -// first_version: "9", -// } -// +// ndk_library { +// name: "libfoo", +// symbol_file: "libfoo.map.txt", +// first_version: "9", +// } type libraryProperties struct { // Relative path to the symbol map. // An example file can be seen here: TODO(danalbert): Make an example. diff --git a/cc/prebuilt.go b/cc/prebuilt.go index 8c404d30f..a2d450332 100644 --- a/cc/prebuilt.go +++ b/cc/prebuilt.go @@ -348,10 +348,10 @@ type bazelPrebuiltLibraryStaticAttributes struct { // TODO(b/228623543): The below is not entirely true until the bug is fixed. For now, both targets are always generated // Implements bp2build for cc_prebuilt_library modules. This will generate: -// * Only a prebuilt_library_static if the shared.enabled property is set to false across all variants. -// * Only a prebuilt_library_shared if the static.enabled property is set to false across all variants -// * Both a prebuilt_library_static and prebuilt_library_shared if the aforementioned properties are not false across -// all variants +// - Only a prebuilt_library_static if the shared.enabled property is set to false across all variants. +// - Only a prebuilt_library_shared if the static.enabled property is set to false across all variants +// - Both a prebuilt_library_static and prebuilt_library_shared if the aforementioned properties are not false across +// all variants // // In all cases, prebuilt_library_static target names will be appended with "_bp2build_cc_library_static". func prebuiltLibraryBp2Build(ctx android.TopDownMutatorContext, module *Module) { diff --git a/cc/snapshot_prebuilt.go b/cc/snapshot_prebuilt.go index 9d40ad058..792ffe364 100644 --- a/cc/snapshot_prebuilt.go +++ b/cc/snapshot_prebuilt.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, @@ -263,12 +263,12 @@ type BaseSnapshotDecoratorProperties struct { // version, snapshot arch, etc. It also adds a special suffix to Soong module name, so it doesn't // collide with source modules. e.g. the following example module, // -// vendor_snapshot_static { -// name: "libbase", -// arch: "arm64", -// version: 30, -// ... -// } +// vendor_snapshot_static { +// name: "libbase", +// arch: "arm64", +// version: 30, +// ... +// } // // will be seen as "libbase.vendor_static.30.arm64" by Soong. type BaseSnapshotDecorator struct { @@ -370,7 +370,6 @@ func vendorSnapshotLoadHook(ctx android.LoadHookContext, p *BaseSnapshotDecorato } } -// // Module definitions for snapshots of libraries (shared, static, header). // // Modules (vendor|recovery)_snapshot_(shared|static|header) are defined here. Shared libraries and @@ -630,7 +629,6 @@ func RecoverySnapshotHeaderFactory() android.Module { var _ snapshotSanitizer = (*snapshotLibraryDecorator)(nil) -// // Module definitions for snapshots of executable binaries. // // Modules (vendor|recovery)_snapshot_binary are defined here. They have their prebuilt executable @@ -728,7 +726,6 @@ func snapshotBinaryFactory(image SnapshotImage, moduleSuffix string) android.Mod return module.Init() } -// // Module definitions for snapshots of object files (*.o). // // Modules (vendor|recovery)_snapshot_object are defined here. They have their prebuilt object diff --git a/cc/snapshot_utils.go b/cc/snapshot_utils.go index de50ef50f..cf4617da3 100644 --- a/cc/snapshot_utils.go +++ b/cc/snapshot_utils.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/cc/test.go b/cc/test.go index 57035711e..f5abc454d 100644 --- a/cc/test.go +++ b/cc/test.go @@ -43,6 +43,8 @@ type TestInstallerProperties struct { // Test option struct. type TestOptions struct { + android.CommonTestOptions + // The UID that you want to run the test as on a device. Run_test_as *string @@ -52,9 +54,6 @@ type TestOptions struct { // a list of extra test configuration files that should be installed with the module. Extra_test_configs []string `android:"path,arch_variant"` - // If the test is a hostside(no device required) unittest that shall be run during presubmit check. - Unit_test *bool - // Add ShippingApiLevelModuleController to auto generated test config. If the device properties // for the shipping api level is less than the min_shipping_api_level, skip this module. Min_shipping_api_level *int64 diff --git a/cc/vendor_public_library.go b/cc/vendor_public_library.go index 65a2b0c9e..f2c8545bc 100644 --- a/cc/vendor_public_library.go +++ b/cc/vendor_public_library.go @@ -28,17 +28,16 @@ var ( // // Example: // -// vendor_public_library { -// name: "libfoo", -// symbol_file: "libfoo.map.txt", -// export_public_headers: ["libfoo_headers"], -// } -// -// cc_headers { -// name: "libfoo_headers", -// export_include_dirs: ["include"], -// } -// +// vendor_public_library { +// name: "libfoo", +// symbol_file: "libfoo.map.txt", +// export_public_headers: ["libfoo_headers"], +// } +// +// cc_headers { +// name: "libfoo_headers", +// export_include_dirs: ["include"], +// } type vendorPublicLibraryProperties struct { // Relative path to the symbol map. Symbol_file *string diff --git a/cc/vendor_snapshot.go b/cc/vendor_snapshot.go index e7c05aca8..77e6f6ffe 100644 --- a/cc/vendor_snapshot.go +++ b/cc/vendor_snapshot.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/cc/vndk_prebuilt.go b/cc/vndk_prebuilt.go index 31b6d10dd..37819a4be 100644 --- a/cc/vndk_prebuilt.go +++ b/cc/vndk_prebuilt.go @@ -29,26 +29,25 @@ var ( // // Example: // -// vndk_prebuilt_shared { -// name: "libfoo", -// version: "27", -// target_arch: "arm64", -// vendor_available: true, -// product_available: true, -// vndk: { -// enabled: true, -// }, -// export_include_dirs: ["include/external/libfoo/vndk_include"], -// arch: { -// arm64: { -// srcs: ["arm/lib64/libfoo.so"], -// }, -// arm: { -// srcs: ["arm/lib/libfoo.so"], -// }, -// }, -// } -// +// vndk_prebuilt_shared { +// name: "libfoo", +// version: "27", +// target_arch: "arm64", +// vendor_available: true, +// product_available: true, +// vndk: { +// enabled: true, +// }, +// export_include_dirs: ["include/external/libfoo/vndk_include"], +// arch: { +// arm64: { +// srcs: ["arm/lib64/libfoo.so"], +// }, +// arm: { +// srcs: ["arm/lib/libfoo.so"], +// }, +// }, +// } type vndkPrebuiltProperties struct { // VNDK snapshot version. Version *string @@ -250,25 +249,25 @@ func vndkPrebuiltSharedLibrary() *Module { // vndk_prebuilt_shared installs Vendor Native Development kit (VNDK) snapshot // shared libraries for system build. Example: // -// vndk_prebuilt_shared { -// name: "libfoo", -// version: "27", -// target_arch: "arm64", -// vendor_available: true, -// product_available: true, -// vndk: { -// enabled: true, -// }, -// export_include_dirs: ["include/external/libfoo/vndk_include"], -// arch: { -// arm64: { -// srcs: ["arm/lib64/libfoo.so"], -// }, -// arm: { -// srcs: ["arm/lib/libfoo.so"], -// }, -// }, -// } +// vndk_prebuilt_shared { +// name: "libfoo", +// version: "27", +// target_arch: "arm64", +// vendor_available: true, +// product_available: true, +// vndk: { +// enabled: true, +// }, +// export_include_dirs: ["include/external/libfoo/vndk_include"], +// arch: { +// arm64: { +// srcs: ["arm/lib64/libfoo.so"], +// }, +// arm: { +// srcs: ["arm/lib/libfoo.so"], +// }, +// }, +// } func VndkPrebuiltSharedFactory() android.Module { module := vndkPrebuiltSharedLibrary() return module.Init() |