summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--android/arch_list.go3
-rw-r--r--android/config.go56
-rw-r--r--android/neverallow.go10
-rw-r--r--android/neverallow_test.go15
-rw-r--r--android/variable.go94
-rw-r--r--apex/apex.go7
-rw-r--r--cc/androidmk.go25
-rw-r--r--cc/builder.go57
-rw-r--r--cc/cc.go98
-rw-r--r--cc/cc_test.go38
-rw-r--r--cc/compiler.go26
-rw-r--r--cc/config/global.go249
-rw-r--r--cc/config/vndk.go1
-rw-r--r--cc/config/x86_linux_host.go1
-rw-r--r--cc/genrule.go15
-rw-r--r--cc/image.go26
-rw-r--r--cc/library.go24
-rw-r--r--cc/linkable.go4
-rw-r--r--cc/linker.go15
-rw-r--r--cc/lto.go10
-rw-r--r--cc/makevars.go30
-rw-r--r--cc/sabi.go10
-rw-r--r--cc/sanitize.go36
-rw-r--r--cc/snapshot_prebuilt.go91
-rw-r--r--cc/snapshot_utils.go5
-rw-r--r--cc/testing.go16
-rw-r--r--cc/util.go1
-rw-r--r--cc/vendor_snapshot.go8
-rwxr-xr-xjava/app.go55
-rw-r--r--rust/rust.go38
-rwxr-xr-x[-rw-r--r--]rust/snapshot_prebuilt.go9
-rw-r--r--rust/snapshot_utils.go5
-rw-r--r--scripts/Android.bp6
-rw-r--r--scripts/check_boot_jars/package_allowed_list.txt8
-rw-r--r--snapshot/Android.bp1
-rw-r--r--snapshot/ramdisk_snapshot.go147
-rw-r--r--ui/build/paths/config.go78
-rw-r--r--ui/build/sandbox_linux.go4
-rw-r--r--ui/build/soong.go15
39 files changed, 1175 insertions, 162 deletions
diff --git a/android/arch_list.go b/android/arch_list.go
index cbf8e7a02..8665767d6 100644
--- a/android/arch_list.go
+++ b/android/arch_list.go
@@ -74,6 +74,7 @@ var cpuVariants = map[ArchType][]string{
"cortex-a76",
"krait",
"kryo",
+ "kryo300",
"kryo385",
"exynos-m1",
"exynos-m2",
@@ -86,7 +87,9 @@ var cpuVariants = map[ArchType][]string{
"cortex-a75",
"cortex-a76",
"kryo",
+ "kryo300",
"kryo385",
+ "kryo785",
"exynos-m1",
"exynos-m2",
},
diff --git a/android/config.go b/android/config.go
index 3c99659f9..fa704faac 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1182,6 +1182,10 @@ func (c *deviceConfig) RecoverySnapshotVersion() string {
return String(c.config.productVariables.RecoverySnapshotVersion)
}
+func (c *deviceConfig) RamdiskSnapshotVersion() string {
+ return String(c.config.productVariables.RamdiskSnapshotVersion)
+}
+
func (c *deviceConfig) CurrentApiLevelForVendorModules() string {
return StringDefault(c.config.productVariables.DeviceCurrentApiLevelForVendorModules, "current")
}
@@ -1375,6 +1379,27 @@ func (c *config) IntegerOverflowDisabledForPath(path string) bool {
return HasAnyPrefix(path, c.productVariables.IntegerOverflowExcludePaths)
}
+func (c *config) IntegerOverflowEnabledForPath(path string) bool {
+ if c.productVariables.IntegerOverflowIncludePaths == nil {
+ return false
+ }
+ return HasAnyPrefix(path, c.productVariables.IntegerOverflowIncludePaths)
+}
+
+func (c *config) BoundSanitizerEnabledForPath(path string) bool {
+ if c.productVariables.BoundSanitizerIncludePaths == nil {
+ return false
+ }
+ return HasAnyPrefix(path, c.productVariables.BoundSanitizerIncludePaths)
+}
+
+func (c *config) BoundSanitizerDisabledForPath(path string) bool {
+ if c.productVariables.BoundSanitizerExcludePaths == nil {
+ return false
+ }
+ return HasAnyPrefix(path, c.productVariables.BoundSanitizerExcludePaths)
+}
+
func (c *config) CFIDisabledForPath(path string) bool {
if len(c.productVariables.CFIExcludePaths) == 0 {
return false
@@ -1506,6 +1531,10 @@ func (c *deviceConfig) BoardUsesRecoveryAsBoot() bool {
return Bool(c.config.productVariables.BoardUsesRecoveryAsBoot)
}
+func (c *deviceConfig) BoardUsesRamdiskAsBoot() bool {
+ return Bool(c.config.productVariables.BoardUsesRamdiskAsBoot)
+}
+
func (c *deviceConfig) BoardKernelBinaries() []string {
return c.config.productVariables.BoardKernelBinaries
}
@@ -1518,6 +1547,10 @@ func (c *deviceConfig) BoardMoveRecoveryResourcesToVendorBoot() bool {
return Bool(c.config.productVariables.BoardMoveRecoveryResourcesToVendorBoot)
}
+func (c *deviceConfig) BoardMoveRamdiskResourcesToVendorBoot() bool {
+ return Bool(c.config.productVariables.BoardMoveRamdiskResourcesToVendorBoot)
+}
+
func (c *deviceConfig) PlatformSepolicyVersion() string {
return String(c.config.productVariables.PlatformSepolicyVersion)
}
@@ -1589,6 +1622,14 @@ func (c *deviceConfig) RecoverySnapshotModules() map[string]bool {
return c.config.productVariables.RecoverySnapshotModules
}
+func (c *deviceConfig) DirectedRamdiskSnapshot() bool {
+ return c.config.productVariables.DirectedRamdiskSnapshot
+}
+
+func (c *deviceConfig) RamdiskSnapshotModules() map[string]bool {
+ return c.config.productVariables.RamdiskSnapshotModules
+}
+
func createDirsMap(previous map[string]bool, dirs []string) (map[string]bool, error) {
var ret = make(map[string]bool)
for _, dir := range dirs {
@@ -1645,6 +1686,21 @@ func (c *deviceConfig) RecoverySnapshotDirsIncludedMap() map[string]bool {
c.config.productVariables.RecoverySnapshotDirsIncluded)
}
+var ramdiskSnapshotDirsExcludedKey = NewOnceKey("RamdiskSnapshotDirsExcludedMap")
+
+func (c *deviceConfig) RamdiskSnapshotDirsExcludedMap() map[string]bool {
+ return c.createDirsMapOnce(ramdiskSnapshotDirsExcludedKey, nil,
+ c.config.productVariables.RamdiskSnapshotDirsExcluded)
+}
+
+var ramdiskSnapshotDirsIncludedKey = NewOnceKey("RamdiskSnapshotDirsIncludedMap")
+
+func (c *deviceConfig) RamdiskSnapshotDirsIncludedMap() map[string]bool {
+ excludedMap := c.RamdiskSnapshotDirsExcludedMap()
+ return c.createDirsMapOnce(ramdiskSnapshotDirsIncludedKey, excludedMap,
+ c.config.productVariables.RamdiskSnapshotDirsIncluded)
+}
+
func (c *deviceConfig) HostFakeSnapshotEnabled() bool {
return c.config.productVariables.HostFakeSnapshotEnabled
}
diff --git a/android/neverallow.go b/android/neverallow.go
index 38d97224b..609b55a06 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -57,7 +57,6 @@ func init() {
AddNeverAllowRules(createUncompressDexRules()...)
AddNeverAllowRules(createMakefileGoalRules()...)
AddNeverAllowRules(createInitFirstStageRules()...)
- AddNeverAllowRules(createProhibitFrameworkAccessRules()...)
}
// Add a NeverAllow rule to the set of rules to apply.
@@ -231,15 +230,6 @@ func createInitFirstStageRules() []Rule {
}
}
-func createProhibitFrameworkAccessRules() []Rule {
- return []Rule{
- NeverAllow().
- With("libs", "framework").
- WithoutMatcher("sdk_version", Regexp("(core_.*|^$)")).
- Because("framework can't be used when building against SDK"),
- }
-}
-
func neverallowMutator(ctx BottomUpMutatorContext) {
m, ok := ctx.Module().(Module)
if !ok {
diff --git a/android/neverallow_test.go b/android/neverallow_test.go
index 86f1a378f..8afe9e046 100644
--- a/android/neverallow_test.go
+++ b/android/neverallow_test.go
@@ -327,21 +327,6 @@ var neverallowTests = []struct {
"Only boot images may be imported as a makefile goal.",
},
},
- // Tests for the rule prohibiting the use of framework
- {
- name: "prohibit framework",
- fs: map[string][]byte{
- "Android.bp": []byte(`
- java_library {
- name: "foo",
- libs: ["framework"],
- sdk_version: "current",
- }`),
- },
- expectedErrors: []string{
- "framework can't be used when building against SDK",
- },
- },
}
var prepareForNeverAllowTest = GroupFixturePreparers(
diff --git a/android/variable.go b/android/variable.go
index 442068423..2c7eded56 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -173,6 +173,34 @@ type variableProperties struct {
Srcs []string `android:"arch_variant"`
Exclude_srcs []string `android:"arch_variant"`
} `android:"arch_variant"`
+
+ Real_hal struct {
+ Cflags []string
+ Exclude_srcs []string
+ Include_dirs []string
+ Shared_libs []string
+ Static_libs []string
+ Srcs []string
+ }
+
+ Qmaa_hal struct {
+ Cflags []string
+ Exclude_srcs []string
+ Include_dirs []string
+ Shared_libs []string
+ Static_libs []string
+ Srcs []string
+ }
+
+ Device_support_hwfde struct {
+ Cflags []string
+ Header_libs []string
+ Shared_libs []string
+ }
+
+ Device_support_hwfde_perf struct {
+ Cflags []string
+ }
} `android:"arch_variant"`
}
@@ -212,6 +240,7 @@ type productVariables struct {
DeviceSystemSdkVersions []string `json:",omitempty"`
RecoverySnapshotVersion *string `json:",omitempty"`
+ RamdiskSnapshotVersion *string `json:",omitempty"`
DeviceSecondaryArch *string `json:",omitempty"`
DeviceSecondaryArchVariant *string `json:",omitempty"`
@@ -252,30 +281,36 @@ type productVariables struct {
AppsDefaultVersionName *string `json:",omitempty"`
- Allow_missing_dependencies *bool `json:",omitempty"`
- Unbundled_build *bool `json:",omitempty"`
- Unbundled_build_apps []string `json:",omitempty"`
- Unbundled_build_image *bool `json:",omitempty"`
- Always_use_prebuilt_sdks *bool `json:",omitempty"`
- Skip_boot_jars_check *bool `json:",omitempty"`
- Malloc_not_svelte *bool `json:",omitempty"`
- Malloc_zero_contents *bool `json:",omitempty"`
- Malloc_pattern_fill_contents *bool `json:",omitempty"`
- Safestack *bool `json:",omitempty"`
- HostStaticBinaries *bool `json:",omitempty"`
- Binder32bit *bool `json:",omitempty"`
- UseGoma *bool `json:",omitempty"`
- UseRBE *bool `json:",omitempty"`
- UseRBEJAVAC *bool `json:",omitempty"`
- UseRBER8 *bool `json:",omitempty"`
- UseRBED8 *bool `json:",omitempty"`
- Debuggable *bool `json:",omitempty"`
- Eng *bool `json:",omitempty"`
- Treble_linker_namespaces *bool `json:",omitempty"`
- Enforce_vintf_manifest *bool `json:",omitempty"`
- Uml *bool `json:",omitempty"`
- Arc *bool `json:",omitempty"`
- MinimizeJavaDebugInfo *bool `json:",omitempty"`
+ Real_hal *bool `json:",omitempty"`
+ Qmaa_hal *bool `json:",omitempty"`
+ Device_support_hwfde *bool `json:",omitempty"`
+ Device_support_hwfde_perf *bool `json:",omitempty"`
+ Allow_missing_dependencies *bool `json:",omitempty"`
+ Unbundled_build *bool `json:",omitempty"`
+ Unbundled_build_apps []string `json:",omitempty"`
+ Unbundled_build_image *bool `json:",omitempty"`
+ Unbundled_build_sdks_from_source *bool `json:",omitempty"`
+ Always_use_prebuilt_sdks *bool `json:",omitempty"`
+ Skip_boot_jars_check *bool `json:",omitempty"`
+ Malloc_not_svelte *bool `json:",omitempty"`
+ Malloc_zero_contents *bool `json:",omitempty"`
+ Malloc_pattern_fill_contents *bool `json:",omitempty"`
+ Safestack *bool `json:",omitempty"`
+ HostStaticBinaries *bool `json:",omitempty"`
+ Binder32bit *bool `json:",omitempty"`
+ UseGoma *bool `json:",omitempty"`
+ UseRBE *bool `json:",omitempty"`
+ UseRBEJAVAC *bool `json:",omitempty"`
+ UseRBER8 *bool `json:",omitempty"`
+ UseRBED8 *bool `json:",omitempty"`
+ Debuggable *bool `json:",omitempty"`
+ Eng *bool `json:",omitempty"`
+ Treble_linker_namespaces *bool `json:",omitempty"`
+ Enforce_vintf_manifest *bool `json:",omitempty"`
+ Pdk *bool `json:",omitempty"`
+ Uml *bool `json:",omitempty"`
+ Arc *bool `json:",omitempty"`
+ MinimizeJavaDebugInfo *bool `json:",omitempty"`
Check_elf_files *bool `json:",omitempty"`
@@ -286,6 +321,10 @@ type productVariables struct {
ApexBootJars ConfiguredJarList `json:",omitempty"`
IntegerOverflowExcludePaths []string `json:",omitempty"`
+ IntegerOverflowIncludePaths []string `json:",omitempty"`
+
+ BoundSanitizerExcludePaths []string `json:",omitempty"`
+ BoundSanitizerIncludePaths []string `json:",omitempty"`
EnableCFI *bool `json:",omitempty"`
CFIExcludePaths []string `json:",omitempty"`
@@ -346,10 +385,15 @@ type productVariables struct {
DirectedRecoverySnapshot bool `json:",omitempty"`
RecoverySnapshotModules map[string]bool `json:",omitempty"`
+ DirectedRamdiskSnapshot bool `json:",omitempty"`
+ RamdiskSnapshotModules map[string]bool `json:",omitempty"`
+
VendorSnapshotDirsIncluded []string `json:",omitempty"`
VendorSnapshotDirsExcluded []string `json:",omitempty"`
RecoverySnapshotDirsExcluded []string `json:",omitempty"`
RecoverySnapshotDirsIncluded []string `json:",omitempty"`
+ RamdiskSnapshotDirsExcluded []string `json:",omitempty"`
+ RamdiskSnapshotDirsIncluded []string `json:",omitempty"`
HostFakeSnapshotEnabled bool `json:",omitempty"`
BoardVendorSepolicyDirs []string `json:",omitempty"`
@@ -416,11 +460,13 @@ type productVariables struct {
InstallExtraFlattenedApexes *bool `json:",omitempty"`
BoardUsesRecoveryAsBoot *bool `json:",omitempty"`
+ BoardUsesRamdiskAsBoot *bool `json:",omitempty"`
BoardKernelBinaries []string `json:",omitempty"`
BoardKernelModuleInterfaceVersions []string `json:",omitempty"`
BoardMoveRecoveryResourcesToVendorBoot *bool `json:",omitempty"`
+ BoardMoveRamdiskResourcesToVendorBoot *bool `json:",omitempty"`
PrebuiltHiddenApiDir *string `json:",omitempty"`
diff --git a/apex/apex.go b/apex/apex.go
index f12c517e9..afb05d0ca 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -2961,6 +2961,13 @@ func makeApexAvailableBaseline() map[string][]string {
"android.hidl.manager-V1.0-java",
"android.hidl.manager-V1.1-java",
"android.hidl.manager-V1.2-java",
+ "vendor.qti.hardware.wifi.hostapd-V1.0-java",
+ "vendor.qti.hardware.wifi.hostapd-V1.1-java",
+ "vendor.qti.hardware.wifi.hostapd-V1.2-java",
+ "vendor.qti.hardware.wifi.supplicant-V2.0-java",
+ "vendor.qti.hardware.wifi.supplicant-V2.1-java",
+ "vendor.qti.hardware.wifi.supplicant-V2.2-java",
+ "vendor.qti.hardware.fstman-V1.0-java",
"bouncycastle-unbundled",
"dnsresolver_aidl_interface-V2-java",
"error_prone_annotations",
diff --git a/cc/androidmk.go b/cc/androidmk.go
index ff5ba4576..afaeb3408 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -111,6 +111,9 @@ func (c *Module) AndroidMkEntries() []android.AndroidMkEntries {
if len(c.Properties.AndroidMkRuntimeLibs) > 0 {
entries.AddStrings("LOCAL_RUNTIME_LIBRARIES", c.Properties.AndroidMkRuntimeLibs...)
}
+ if lib, ok := c.compiler.(*libraryDecorator); ok {
+ entries.AddStrings("LOCAL_SRC_FILES", lib.baseCompiler.srcsBeforeGen.Strings()...)
+ }
entries.SetString("LOCAL_SOONG_LINK_TYPE", c.makeLinkType)
if c.UseVndk() {
entries.SetBool("LOCAL_USE_VNDK", true)
@@ -227,15 +230,29 @@ func (library *libraryDecorator) androidMkWriteExportedFlags(entries *android.An
}
func (library *libraryDecorator) androidMkEntriesWriteAdditionalDependenciesForSourceAbiDiff(entries *android.AndroidMkEntries) {
- if library.sAbiDiff.Valid() && !library.static() {
- entries.AddStrings("LOCAL_ADDITIONAL_DEPENDENCIES", library.sAbiDiff.String())
+ if library.sAbiOutputFile.Valid() {
+ entries.SetString("LOCAL_ADDITIONAL_DEPENDENCIES",
+ "$(LOCAL_ADDITIONAL_DEPENDENCIES) "+library.sAbiOutputFile.String())
+ if library.sAbiDiff.Valid() && !library.static() {
+ entries.SetString("LOCAL_ADDITIONAL_DEPENDENCIES",
+ "$(LOCAL_ADDITIONAL_DEPENDENCIES) "+library.sAbiDiff.String())
+ entries.SetString("HEADER_ABI_DIFFS",
+ "$(HEADER_ABI_DIFFS) "+library.sAbiDiff.String())
+ }
}
}
// TODO(ccross): remove this once apex/androidmk.go is converted to AndroidMkEntries
func (library *libraryDecorator) androidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer) {
- if library.sAbiDiff.Valid() && !library.static() {
- fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES +=", library.sAbiDiff.String())
+ if library.sAbiOutputFile.Valid() {
+ fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_ADDITIONAL_DEPENDENCIES) ",
+ library.sAbiOutputFile.String())
+ if library.sAbiDiff.Valid() && !library.static() {
+ fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_ADDITIONAL_DEPENDENCIES) ",
+ library.sAbiDiff.String())
+ fmt.Fprintln(w, "HEADER_ABI_DIFFS := $(HEADER_ABI_DIFFS) ",
+ library.sAbiDiff.String())
+ }
}
}
diff --git a/cc/builder.go b/cc/builder.go
index ea06839a9..2170e8e85 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -396,11 +396,12 @@ type builderFlags struct {
toolchain config.Toolchain
// True if these extra features are enabled.
- tidy bool
+ sdclang bool
+ tidy bool
needTidyFiles bool
- gcovCoverage bool
- sAbiDump bool
- emitXrefs bool
+ gcovCoverage bool
+ sAbiDump bool
+ emitXrefs bool
assemblerWithCpp bool // True if .s files should be processed with the c preprocessor.
@@ -638,7 +639,13 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs
ccDesc := ccCmd
- ccCmd = "${config.ClangBin}/" + ccCmd
+ var extraFlags string
+ if flags.sdclang {
+ ccCmd = "${config.SDClangBin}/" + ccCmd
+ extraFlags = " ${config.SDClangFlags}"
+ } else {
+ ccCmd = "${config.ClangBin}/" + ccCmd
+ }
var implicitOutputs android.WritablePaths
if coverage {
@@ -656,7 +663,7 @@ func transformSourceToObj(ctx ModuleContext, subdir string, srcFiles, noTidySrcs
Implicits: cFlagsDeps,
OrderOnly: pathDeps,
Args: map[string]string{
- "cFlags": shareFlags("cFlags", moduleFlags),
+ "cFlags": shareFlags("cFlags", moduleFlags + extraFlags),
"ccCmd": ccCmd, // short and not shared
},
})
@@ -767,6 +774,9 @@ func transformObjToStaticLib(ctx android.ModuleContext,
flags builderFlags, outputFile android.ModuleOutPath, deps android.Paths, validations android.Paths) {
arCmd := "${config.ClangBin}/llvm-ar"
+ if flags.sdclang {
+ arCmd = "${config.SDClangBin}/llvm-ar"
+ }
arFlags := ""
if !ctx.Darwin() {
arFlags += " --format=gnu"
@@ -811,7 +821,14 @@ func transformObjToDynamicBinary(ctx android.ModuleContext,
groupLate bool, flags builderFlags, outputFile android.WritablePath,
implicitOutputs android.WritablePaths, validations android.Paths) {
- ldCmd := "${config.ClangBin}/clang++"
+ var ldCmd string
+ var extraFlags string
+ if flags.sdclang {
+ ldCmd = "${config.SDClangBin}/clang++"
+ extraFlags = " ${config.SDClangFlags}"
+ } else {
+ ldCmd = "${config.ClangBin}/clang++"
+ }
var libFlagsList []string
@@ -859,7 +876,7 @@ func transformObjToDynamicBinary(ctx android.ModuleContext,
"crtBegin": strings.Join(crtBegin.Strings(), " "),
"libFlags": strings.Join(libFlagsList, " "),
"extraLibFlags": flags.extraLibFlags,
- "ldFlags": flags.globalLdFlags + " " + flags.localLdFlags,
+ "ldFlags": flags.globalLdFlags + " " + flags.localLdFlags + " " + extraFlags,
"crtEnd": strings.Join(crtEnd.Strings(), " "),
}
if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_CXX_LINKS") {
@@ -978,6 +995,19 @@ func sourceAbiDiff(ctx android.ModuleContext, inputDump android.Path, referenceD
}
// TODO(b/232891473): Simplify the above logic with diffFlags.
extraFlags = append(extraFlags, diffFlags...)
+ var sdclangAbiCheckIgnoreList = []string{
+ "libbinder",
+ "libhwbinder",
+ "libprotobuf-cpp-lite",
+ "libprotobuf-cpp-full",
+ "libunwindstack",
+ "libvixl-arm64",
+ "libvixl-arm",
+ }
+ if config.SDClang && !inList("-advice-only", extraFlags) &&
+ inList(ctx.ModuleName(), sdclangAbiCheckIgnoreList) {
+ extraFlags = append(extraFlags, "-advice-only")
+ }
ctx.Build(pctx, android.BuildParams{
Rule: sAbiDiff,
@@ -1024,12 +1054,19 @@ func TransformSharedObjectToToc(ctx android.ModuleContext, inputFile android.Pat
func transformObjsToObj(ctx android.ModuleContext, objFiles android.Paths,
flags builderFlags, outputFile android.WritablePath, deps android.Paths) {
- ldCmd := "${config.ClangBin}/clang++"
+ var ldCmd string
+ var extraFlags string
+ if flags.sdclang {
+ ldCmd = "${config.SDClangBin}/clang++"
+ extraFlags = " ${config.SDClangFlags}"
+ } else {
+ ldCmd = "${config.ClangBin}/clang++"
+ }
rule := partialLd
args := map[string]string{
"ldCmd": ldCmd,
- "ldFlags": flags.globalLdFlags + " " + flags.localLdFlags,
+ "ldFlags": flags.globalLdFlags + " " + flags.localLdFlags + " " + extraFlags,
}
if ctx.Config().UseRBE() && ctx.Config().IsEnvTrue("RBE_CXX_LINKS") {
rule = partialLdRE
diff --git a/cc/cc.go b/cc/cc.go
index 456b73628..c96efba38 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -210,12 +210,13 @@ type Flags struct {
// These must be after any module include flags, which will be in CommonFlags.
SystemIncludeFlags []string
- Toolchain config.Toolchain
- Tidy bool // True if ninja .tidy rules should be generated.
+ Toolchain config.Toolchain
+ Sdclang bool
+ Tidy bool // True if clang-tidy is enabled.
NeedTidyFiles bool // True if module link should depend on .tidy files
- GcovCoverage bool // True if coverage files should be generated.
- SAbiDump bool // True if header abi dumps should be generated.
- EmitXrefs bool // If true, generate Ninja rules to generate emitXrefs input files for Kythe
+ GcovCoverage bool // True if coverage files should be generated.
+ SAbiDump bool // True if header abi dumps should be generated.
+ EmitXrefs bool // If true, generate Ninja rules to generate emitXrefs input files for Kythe
// The instruction set required for clang ("arm" or "thumb").
RequiredInstructionSet string
@@ -241,6 +242,9 @@ type BaseProperties struct {
// Deprecated. true is the default, false is invalid.
Clang *bool `android:"arch_variant"`
+ // compile module with SDLLVM instead of AOSP LLVM
+ Sdclang *bool `android:"arch_variant"`
+
// The API level that this module is built against. The APIs of this API level will be
// visible at build time, but use of any APIs newer than min_sdk_version will render the
// module unloadable on older devices. In the future it will be possible to weakly-link new
@@ -294,10 +298,6 @@ type BaseProperties struct {
Logtags []string
// Make this module available when building for ramdisk.
- // On device without a dedicated recovery partition, the module is only
- // available after switching root into
- // /first_stage_ramdisk. To expose the module before switching root, install
- // the recovery variant instead.
Ramdisk_available *bool
// Make this module available when building for vendor ramdisk.
@@ -359,6 +359,13 @@ type BaseProperties struct {
// framework module from the recovery snapshot.
Exclude_from_recovery_snapshot *bool
+ // Normally Soong uses the directory structure to decide which modules
+ // should be included (framework) or excluded (non-framework) from the
+ // different snapshots (vendor, recovery, etc.), but this property
+ // allows a partner to exclude a module normally thought of as a
+ // framework module from the ramdisk snapshot.
+ Exclude_from_ramdisk_snapshot *bool
+
// List of APEXes that this module has private access to for testing purpose. The module
// can depend on libraries that are not exported by the APEXes and use private symbols
// from the exported libraries.
@@ -1218,17 +1225,6 @@ func (c *Module) IsVendorPublicLibrary() bool {
return c.VendorProperties.IsVendorPublicLibrary
}
-func (c *Module) IsVndkPrebuiltLibrary() bool {
- if _, ok := c.linker.(*vndkPrebuiltLibraryDecorator); ok {
- return true
- }
- return false
-}
-
-func (c *Module) SdkAndPlatformVariantVisibleToMake() bool {
- return c.Properties.SdkAndPlatformVariantVisibleToMake
-}
-
func (c *Module) HasLlndkStubs() bool {
lib := moduleLibraryInterface(c)
return lib != nil && lib.hasLLNDKStubs()
@@ -1385,6 +1381,10 @@ func (c *Module) ExcludeFromRecoverySnapshot() bool {
return Bool(c.Properties.Exclude_from_recovery_snapshot)
}
+func (c *Module) ExcludeFromRamdiskSnapshot() bool {
+ return Bool(c.Properties.Exclude_from_ramdisk_snapshot)
+}
+
func isBionic(name string) bool {
switch name {
case "libc", "libm", "libdl", "libdl_android", "linker", "linkerconfig":
@@ -1710,7 +1710,7 @@ func (c *Module) DataPaths() []android.DataPath {
return nil
}
-func getNameSuffixWithVndkVersion(ctx android.ModuleContext, c LinkableInterface) string {
+func (c *Module) getNameSuffixWithVndkVersion(ctx android.ModuleContext) string {
// Returns the name suffix for product and vendor variants. If the VNDK version is not
// "current", it will append the VNDK version to the name suffix.
var vndkVersion string
@@ -1730,19 +1730,19 @@ func getNameSuffixWithVndkVersion(ctx android.ModuleContext, c LinkableInterface
if vndkVersion == "current" {
vndkVersion = ctx.DeviceConfig().PlatformVndkVersion()
}
- if c.VndkVersion() != vndkVersion && c.VndkVersion() != "" {
+ if c.Properties.VndkVersion != vndkVersion && c.Properties.VndkVersion != "" {
// add version suffix only if the module is using different vndk version than the
// version in product or vendor partition.
- nameSuffix += "." + c.VndkVersion()
+ nameSuffix += "." + c.Properties.VndkVersion
}
return nameSuffix
}
-func GetSubnameProperty(actx android.ModuleContext, c LinkableInterface) string {
- var subName = ""
+func (c *Module) setSubnameProperty(actx android.ModuleContext) {
+ c.Properties.SubName = ""
if c.Target().NativeBridge == android.NativeBridgeEnabled {
- subName += NativeBridgeSuffix
+ c.Properties.SubName += NativeBridgeSuffix
}
llndk := c.IsLlndk()
@@ -1750,27 +1750,25 @@ func GetSubnameProperty(actx android.ModuleContext, c LinkableInterface) string
// .vendor.{version} suffix is added for vendor variant or .product.{version} suffix is
// added for product variant only when we have vendor and product variants with core
// variant. The suffix is not added for vendor-only or product-only module.
- subName += getNameSuffixWithVndkVersion(actx, c)
+ c.Properties.SubName += c.getNameSuffixWithVndkVersion(actx)
} else if c.IsVendorPublicLibrary() {
- subName += vendorPublicLibrarySuffix
- } else if c.IsVndkPrebuiltLibrary() {
+ c.Properties.SubName += vendorPublicLibrarySuffix
+ } else if _, ok := c.linker.(*vndkPrebuiltLibraryDecorator); ok {
// .vendor suffix is added for backward compatibility with VNDK snapshot whose names with
// such suffixes are already hard-coded in prebuilts/vndk/.../Android.bp.
- subName += VendorSuffix
+ c.Properties.SubName += VendorSuffix
} else if c.InRamdisk() && !c.OnlyInRamdisk() {
- subName += RamdiskSuffix
+ c.Properties.SubName += RamdiskSuffix
} else if c.InVendorRamdisk() && !c.OnlyInVendorRamdisk() {
- subName += VendorRamdiskSuffix
+ c.Properties.SubName += VendorRamdiskSuffix
} else if c.InRecovery() && !c.OnlyInRecovery() {
- subName += RecoverySuffix
- } else if c.IsSdkVariant() && (c.SdkAndPlatformVariantVisibleToMake() || c.SplitPerApiLevel()) {
- subName += sdkSuffix
+ c.Properties.SubName += RecoverySuffix
+ } else if c.IsSdkVariant() && (c.Properties.SdkAndPlatformVariantVisibleToMake || c.SplitPerApiLevel()) {
+ c.Properties.SubName += sdkSuffix
if c.SplitPerApiLevel() {
- subName += "." + c.SdkVersion()
+ c.Properties.SubName += "." + c.SdkVersion()
}
}
-
- return subName
}
// Returns true if Bazel was successfully used for the analysis of this module.
@@ -1808,7 +1806,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
return
}
- c.Properties.SubName = GetSubnameProperty(actx, c)
+ c.setSubnameProperty(actx)
apexInfo := actx.Provider(android.ApexInfoProvider).(android.ApexInfo)
if !apexInfo.IsForPlatform() {
c.hideApexVariantFromMake = true
@@ -1841,6 +1839,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
flags := Flags{
Toolchain: c.toolchain(ctx),
EmitXrefs: ctx.Config().EmitXrefRules(),
+ Sdclang: c.sdclang(ctx),
}
if c.compiler != nil {
flags = c.compiler.compilerFlags(ctx, flags, deps)
@@ -1915,7 +1914,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
c.maybeUnhideFromMake()
// glob exported headers for snapshot, if BOARD_VNDK_VERSION is current or
- // RECOVERY_SNAPSHOT_VERSION is current.
+ // RECOVERY_SNAPSHOT_VERSION is current or RAMDISK_SNAPSHOT_VERSION is current.
if i, ok := c.linker.(snapshotLibraryInterface); ok {
if ShouldCollectHeadersForSnapshot(ctx, c, apexInfo) {
i.collectHeadersForSnapshot(ctx)
@@ -2144,6 +2143,8 @@ func GetSnapshot(c LinkableInterface, snapshotInfo **SnapshotInfo, actx android.
snapshotModule = actx.AddVariationDependencies(nil, nil, "vendor_snapshot")
} else if recoverySnapshotVersion := actx.DeviceConfig().RecoverySnapshotVersion(); recoverySnapshotVersion != "current" && recoverySnapshotVersion != "" && c.InRecovery() {
snapshotModule = actx.AddVariationDependencies(nil, nil, "recovery_snapshot")
+ } else if ramdiskSnapshotVersion := actx.DeviceConfig().RamdiskSnapshotVersion(); ramdiskSnapshotVersion != "current" && ramdiskSnapshotVersion != "" && c.InRamdisk() {
+ snapshotModule = actx.AddVariationDependencies(nil, nil, "ramdisk_snapshot")
}
if len(snapshotModule) > 0 && snapshotModule[0] != nil {
snapshot := actx.OtherModuleProvider(snapshotModule[0], SnapshotInfoProvider).(SnapshotInfo)
@@ -2189,6 +2190,8 @@ func RewriteLibs(c LinkableInterface, snapshotInfo **SnapshotInfo, actx android.
name, _ := StubsLibNameAndVersion(entry)
if c.InRecovery() {
nonvariantLibs = append(nonvariantLibs, RewriteSnapshotLib(entry, GetSnapshot(c, snapshotInfo, actx).SharedLibs))
+ } else if c.InRamdisk() {
+ nonvariantLibs = append(nonvariantLibs, RewriteSnapshotLib(entry, GetSnapshot(c, snapshotInfo, actx).SharedLibs))
} else if c.UseSdk() && inList(name, *getNDKKnownLibs(config)) {
variantLibs = append(variantLibs, name+ndkLibrarySuffix)
} else if c.UseVndk() {
@@ -2612,6 +2615,21 @@ func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) {
}
}
+func (c *Module) sdclang(ctx BaseModuleContext) bool {
+ sdclang := Bool(c.Properties.Sdclang)
+
+ // SDLLVM is not for host build
+ if ctx.Host() || config.ForceSDClangOff {
+ return false
+ }
+
+ if c.Properties.Sdclang == nil && config.SDClang {
+ return true
+ }
+
+ return sdclang
+}
+
// Convert dependencies to paths. Returns a PathDeps containing paths
func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
var depPaths PathDeps
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 09cc352a2..237d6e76a 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -141,6 +141,7 @@ const (
vendorVariant = "android_vendor.29_arm64_armv8-a_shared"
productVariant = "android_product.29_arm64_armv8-a_shared"
recoveryVariant = "android_recovery_arm64_armv8-a_shared"
+ ramdiskVariant = "android_ramdisk_arm64_armv8-a_shared"
)
// Test that the PrepareForTestWithCcDefaultModules provides all the files that it uses by
@@ -3135,6 +3136,41 @@ func TestRecovery(t *testing.T) {
}
}
+func TestRamdisk(t *testing.T) {
+ ctx := testCc(t, `
+ cc_library_shared {
+ name: "libramdisk",
+ ramdisk: true,
+ }
+ cc_library_shared {
+ name: "libramdisk32",
+ ramdisk: true,
+ compile_multilib:"32",
+ }
+ cc_library_shared {
+ name: "libHalInRamdisk",
+ ramdisk_available: true,
+ vendor: true,
+ }
+ `)
+
+ variants := ctx.ModuleVariantsForTests("libramdisk")
+ const arm64 = "android_ramdisk_arm64_armv8-a_shared"
+ if len(variants) != 1 || !android.InList(arm64, variants) {
+ t.Errorf("variants of libramdisk must be \"%s\" only, but was %#v", arm64, variants)
+ }
+
+ variants = ctx.ModuleVariantsForTests("libramdisk32")
+ if android.InList(arm64, variants) {
+ t.Errorf("multilib was set to 32 for libramdisk32, but its variants has %s.", arm64)
+ }
+
+ ramdiskModule := ctx.ModuleForTests("libHalInRamdisk", ramdiskVariant).Module().(*Module)
+ if !ramdiskModule.Platform() {
+ t.Errorf("ramdisk variant of libHalInRamdisk must not specific to device, soc, or product")
+ }
+}
+
func TestDataLibsPrebuiltSharedTestLibrary(t *testing.T) {
bp := `
cc_prebuilt_test_library_shared {
@@ -4186,6 +4222,8 @@ func TestIncludeDirectoryOrdering(t *testing.T) {
includes = append(includes, strings.TrimPrefix(flag, "-I"))
} else if flag == "-isystem" {
// skip isystem, include next
+ } else if flag == "${config.SDClangFlags}" {
+ // skip config.SDClangFlags when sdclang is set
} else if len(flag) > 0 {
includes = append(includes, flag)
}
diff --git a/cc/compiler.go b/cc/compiler.go
index eb5458fc6..87a537f3a 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -186,6 +186,23 @@ type BaseCompilerProperties struct {
// build the recovery variant of the C/C++ module.
Exclude_generated_sources []string
}
+ Ramdisk struct {
+ // list of source files that should only be used in the
+ // ramdisk variant of the C/C++ module.
+ Srcs []string `android:"path"`
+
+ // list of source files that should not be used to
+ // build the ramdisk variant of the C/C++ module.
+ Exclude_srcs []string `android:"path"`
+
+ // List of additional cflags that should be used to build the ramdisk
+ // variant of the C/C++ module.
+ Cflags []string
+
+ // list of generated sources that should not be used to
+ // build the ramdisk variant of the C/C++ module.
+ Exclude_generated_sources []string
+ }
Vendor_ramdisk struct {
// list of source files that should not be used to
// build the vendor ramdisk variant of the C/C++ module.
@@ -343,6 +360,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
CheckBadCompilerFlags(ctx, "vendor.cflags", compiler.Properties.Target.Vendor.Cflags)
CheckBadCompilerFlags(ctx, "product.cflags", compiler.Properties.Target.Product.Cflags)
CheckBadCompilerFlags(ctx, "recovery.cflags", compiler.Properties.Target.Recovery.Cflags)
+ CheckBadCompilerFlags(ctx, "ramdisk.cflags", compiler.Properties.Target.Ramdisk.Cflags)
CheckBadCompilerFlags(ctx, "vendor_ramdisk.cflags", compiler.Properties.Target.Vendor_ramdisk.Cflags)
CheckBadCompilerFlags(ctx, "platform.cflags", compiler.Properties.Target.Platform.Cflags)
@@ -410,6 +428,10 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_RAMDISK__")
}
+ if ctx.inRamdisk() {
+ flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_RAMDISK__")
+ }
+
if ctx.apexVariationName() != "" {
flags.Global.CommonFlags = append(flags.Global.CommonFlags, "-D__ANDROID_APEX__")
if ctx.Device() {
@@ -517,6 +539,10 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Recovery.Cflags)...)
}
+ if ctx.inRamdisk() {
+ flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Ramdisk.Cflags)...)
+ }
+
if ctx.inVendorRamdisk() {
flags.Local.CFlags = append(flags.Local.CFlags, esc(compiler.Properties.Target.Vendor_ramdisk.Cflags)...)
}
diff --git a/cc/config/global.go b/cc/config/global.go
index 3caf32792..1c5963eb8 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -15,13 +15,27 @@
package config
import (
+ "encoding/json"
+ "encoding/xml"
+ "fmt"
+ "io/ioutil"
+ "os"
+
+ //"path"
+ //"path/filepath"
"runtime"
+ "strconv"
"strings"
"android/soong/android"
"android/soong/remoteexec"
)
+type QiifaAbiLibs struct {
+ XMLName xml.Name `xml:"abilibs"`
+ Library []string `xml:"library"`
+}
+
var (
pctx = android.NewPackageContext("android/soong/cc/config")
exportedVars = android.NewExportedVariables(pctx)
@@ -80,6 +94,11 @@ var (
// TODO: can we remove this now?
"-Wno-reserved-id-macro",
+ // TODO(b/207393703): delete this line after failures resolved
+ // Workaround for ccache with clang.
+ // See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html.
+ "-Wno-unused-command-line-argument",
+
// Force clang to always output color diagnostics. Ninja will strip the ANSI
// color codes if it is not running in a terminal.
"-fcolor-diagnostics",
@@ -199,7 +218,9 @@ var (
"-Wno-void-pointer-to-int-cast",
// http://b/161386391 for -Wno-pointer-to-int-cast
"-Wno-pointer-to-int-cast",
- "-Werror=fortify-source",
+ // SDClang does not support -Werror=fortify-source.
+ // TODO: b/142476859
+ // "-Werror=fortify-source",
"-Werror=address-of-temporary",
// Bug: http://b/29823425 Disable -Wnull-dereference until the
@@ -234,6 +255,57 @@ var (
// New warnings to be fixed after clang-r433403
"-Wno-error=unused-but-set-variable", // http://b/197240255
"-Wno-error=unused-but-set-parameter", // http://b/197240255
+ //Android T Vendor Compilation
+ "-Wno-reorder-init-list",
+ "-Wno-implicit-fallthrough",
+ "-Wno-c99-designator",
+ "-Wno-implicit-int-float-conversion",
+ "-Wno-int-in-bool-context",
+ "-Wno-alloca",
+ "-Wno-dangling-gsl",
+ "-Wno-pointer-compare",
+ "-Wno-final-dtor-non-final-class",
+ "-Wno-incomplete-setjmp-declaration",
+ "-Wno-sizeof-array-div",
+ "-Wno-xor-used-as-pow",
+ //"-fsplit-lto-unit",
+ "-Wno-c++17-extensions",
+ "-flax-vector-conversions=all",
+ "-Wno-tautological-overlap-compare",
+ "-Wno-range-loop-analysis",
+ "-Wno-invalid-partial-specialization",
+ "-Wno-deprecated-copy",
+ "-Wno-misleading-indentation",
+ "-Wno-zero-as-null-pointer-constant",
+ "-Wno-deprecated-enum-enum-conversion",
+ "-Wno-deprecated-anon-enum-enum-conversion",
+ "-Wno-bool-operation",
+ "-Wno-unused-comparison",
+ "-Wno-string-compare",
+ "-Wno-wrong-info",
+ "-Wno-thread-safety-analysis",
+ "-Wno-unsequenced",
+ "-Wno-unknown-warning-option",
+ "-Wno-unused-variable",
+ "-Wno-unused-value",
+ "-Wno-unused-parameter",
+ "-Wno-non-c-typedef-for-linkage",
+ "-Wno-typedef-redefinition",
+ "-Wno-format",
+ "-Wno-void-pointer-to-int-cast",
+ "-Wno-pointer-to-int-cast",
+ "-Wno-string-concatenation",
+ "-Wno-void-pointer-to-enum-cast",
+ "-Wno-incompatible-pointer-types",
+ "-Wno-format-invalid-specifier-fcommon",
+ " -Wno-self-assign",
+ "-Wno-format",
+ "-Wno-unused-label",
+ "-Wno-pointer-sign",
+ "-Wno-writable-strings",
+ "-Wno-missing-declarations",
+ "-Wno-reorder-ctor",
+ "-Wno-unused-function",
}
noOverrideExternalGlobalCflags = []string{
@@ -284,6 +356,10 @@ var (
ExperimentalCStdVersion = "gnu11"
ExperimentalCppStdVersion = "gnu++2a"
+ SDClang = false
+ SDClangPath = ""
+ ForceSDClangOff = false
+
// prebuilts/clang default settings.
ClangDefaultBase = "prebuilts/clang/host"
ClangDefaultVersion = "clang-r450784d"
@@ -297,6 +373,7 @@ var (
// Directories with warnings from Android.mk files.
WarningAllowedOldProjects = []string{}
+ QiifaAbiLibraryList = []string{}
)
// BazelCcToolchainVars generates bzl file content containing variables for
@@ -313,6 +390,16 @@ func init() {
if runtime.GOOS == "linux" {
commonGlobalCflags = append(commonGlobalCflags, "-fdebug-prefix-map=/proc/self/cwd=")
}
+ qiifaBuildConfig := os.Getenv("QIIFA_BUILD_CONFIG")
+ if _, err := os.Stat(qiifaBuildConfig); !os.IsNotExist(err) {
+ data, _ := ioutil.ReadFile(qiifaBuildConfig)
+ var qiifalibs QiifaAbiLibs
+ _ = xml.Unmarshal([]byte(data), &qiifalibs)
+ for i := 0; i < len(qiifalibs.Library); i++ {
+ QiifaAbiLibraryList = append(QiifaAbiLibraryList, qiifalibs.Library[i])
+
+ }
+ }
exportedVars.ExportStringListStaticVariable("CommonGlobalConlyflags", commonGlobalConlyflags)
exportedVars.ExportStringListStaticVariable("DeviceGlobalCppflags", deviceGlobalCppflags)
@@ -325,7 +412,7 @@ func init() {
// Export the static default CommonGlobalCflags to Bazel.
// TODO(187086342): handle cflags that are set in VariableFuncs.
bazelCommonGlobalCflags := append(
- commonGlobalCflags,
+ ClangFilterUnknownCflags(commonGlobalCflags),
[]string{
// Default to zero initialization.
"-ftrivial-auto-var-init=zero",
@@ -350,11 +437,14 @@ func init() {
flags = append(flags, "-ftrivial-auto-var-init=zero -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang")
}
- // Workaround for ccache with clang.
- // See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html.
- if ctx.Config().IsEnvTrue("USE_CCACHE") {
- flags = append(flags, "-Wno-unused-command-line-argument")
- }
+ // TODO(b/207393703): Re-enable -Wno-unused-command-line-argument after failures are resolved.
+ /*
+ // Workaround for ccache with clang.
+ // See http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html.
+ if ctx.Config().IsEnvTrue("USE_CCACHE") {
+ flags = append(flags, "-Wno-unused-command-line-argument")
+ }
+ */
return strings.Join(flags, " ")
})
@@ -388,6 +478,8 @@ func init() {
exportedVars.ExportStringList("CommonGlobalIncludes", commonGlobalIncludes)
pctx.PrefixedExistentPathsForSourcesVariable("CommonGlobalIncludes", "-I", commonGlobalIncludes)
+ setSdclangVars()
+
exportedVars.ExportStringStaticVariable("CLANG_DEFAULT_VERSION", ClangDefaultVersion)
exportedVars.ExportStringStaticVariable("CLANG_DEFAULT_SHORT_VERSION", ClangDefaultShortVersion)
@@ -429,6 +521,149 @@ func init() {
pctx.StaticVariableWithEnvOverride("REAbiLinkerExecStrategy", "RBE_ABI_LINKER_EXEC_STRATEGY", remoteexec.LocalExecStrategy)
}
+func setSdclangVars() {
+ sdclangPath := ""
+ sdclangAEFlag := ""
+ sdclangFlags := ""
+
+ product := os.Getenv("TARGET_BOARD_PLATFORM")
+ aeConfigPath := os.Getenv("SDCLANG_AE_CONFIG")
+ sdclangConfigPath := os.Getenv("SDCLANG_CONFIG")
+ sdclangSA := os.Getenv("SDCLANG_SA_ENABLED")
+
+ type sdclangAEConfig struct {
+ SDCLANG_AE_FLAG string
+ }
+
+ // Load AE config file and set AE flag
+ if file, err := os.Open(aeConfigPath); err == nil {
+ decoder := json.NewDecoder(file)
+ aeConfig := sdclangAEConfig{}
+ if err := decoder.Decode(&aeConfig); err == nil {
+ sdclangAEFlag = aeConfig.SDCLANG_AE_FLAG
+ } else {
+ panic(err)
+ }
+ }
+
+ // Load SD Clang config file and set SD Clang variables
+ var sdclangConfig interface{}
+ if file, err := os.Open(sdclangConfigPath); err == nil {
+ decoder := json.NewDecoder(file)
+ // Parse the config file
+ if err := decoder.Decode(&sdclangConfig); err == nil {
+ config := sdclangConfig.(map[string]interface{})
+ // Retrieve the default block
+ if dev, ok := config["default"]; ok {
+ devConfig := dev.(map[string]interface{})
+ // FORCE_SDCLANG_OFF is required in the default block
+ if _, ok := devConfig["FORCE_SDCLANG_OFF"]; ok {
+ ForceSDClangOff = devConfig["FORCE_SDCLANG_OFF"].(bool)
+ }
+ // SDCLANG is optional in the default block
+ if _, ok := devConfig["SDCLANG"]; ok {
+ SDClang = devConfig["SDCLANG"].(bool)
+ }
+ // SDCLANG_PATH is required in the default block
+ if _, ok := devConfig["SDCLANG_PATH"]; ok {
+ sdclangPath = devConfig["SDCLANG_PATH"].(string)
+ } else {
+ panic("SDCLANG_PATH is required in the default block")
+ }
+ // SDCLANG_FLAGS is optional in the default block
+ if _, ok := devConfig["SDCLANG_FLAGS"]; ok {
+ sdclangFlags = devConfig["SDCLANG_FLAGS"].(string)
+ }
+ } else {
+ panic("Default block is required in the SD Clang config file")
+ }
+ // Retrieve the device specific block if it exists in the config file
+ if dev, ok := config[product]; ok {
+ devConfig := dev.(map[string]interface{})
+ // SDCLANG is optional in the device specific block
+ if _, ok := devConfig["SDCLANG"]; ok {
+ SDClang = devConfig["SDCLANG"].(bool)
+ }
+ // SDCLANG_PATH is optional in the device specific block
+ if _, ok := devConfig["SDCLANG_PATH"]; ok {
+ sdclangPath = devConfig["SDCLANG_PATH"].(string)
+ }
+ // SDCLANG_FLAGS is optional in the device specific block
+ if _, ok := devConfig["SDCLANG_FLAGS"]; ok {
+ sdclangFlags = devConfig["SDCLANG_FLAGS"].(string)
+ }
+ }
+ b, _ := strconv.ParseBool(sdclangSA)
+ if b {
+ llvmsa_loc := "llvmsa"
+ s := []string{sdclangFlags, "--compile-and-analyze", llvmsa_loc}
+ sdclangFlags = strings.Join(s, " ")
+ fmt.Println("Clang SA is enabled: ", sdclangFlags)
+ } else {
+ fmt.Println("Clang SA is not enabled")
+ }
+ } else {
+ panic(err)
+ }
+ } else {
+ fmt.Println(err)
+ }
+
+ // Override SDCLANG if the varialbe is set in the environment
+ if sdclang := os.Getenv("SDCLANG"); sdclang != "" {
+ if override, err := strconv.ParseBool(sdclang); err == nil {
+ SDClang = override
+ }
+ }
+
+ // Sanity check SDCLANG_PATH
+ if envPath := os.Getenv("SDCLANG_PATH"); sdclangPath == "" && envPath == "" {
+ panic("SDCLANG_PATH can not be empty")
+ }
+
+ // Override SDCLANG_PATH if the variable is set in the environment
+ pctx.VariableFunc("SDClangBin", func(ctx android.PackageVarContext) string {
+ if override := ctx.Config().Getenv("SDCLANG_PATH"); override != "" {
+ return override
+ }
+ return sdclangPath
+ })
+
+ // Override SDCLANG_COMMON_FLAGS if the variable is set in the environment
+ pctx.VariableFunc("SDClangFlags", func(ctx android.PackageVarContext) string {
+ if override := ctx.Config().Getenv("SDCLANG_COMMON_FLAGS"); override != "" {
+ return override
+ }
+ return sdclangAEFlag + " " + sdclangFlags
+ })
+
+ SDClangPath = sdclangPath
+ // Find the path to SDLLVM's ASan libraries
+ // TODO (b/117846004): Disable setting SDClangAsanLibDir due to unit test path issues
+ //absPath := sdclangPath
+ //if envPath := android.SdclangEnv["SDCLANG_PATH"]; envPath != "" {
+ // absPath = envPath
+ //}
+ //if !filepath.IsAbs(absPath) {
+ // absPath = path.Join(androidRoot, absPath)
+ //}
+ //
+ //libDirPrefix := "../lib/clang"
+ //libDir, err := ioutil.ReadDir(path.Join(absPath, libDirPrefix))
+ //if err != nil {
+ // libDirPrefix = "../lib64/clang"
+ // libDir, err = ioutil.ReadDir(path.Join(absPath, libDirPrefix))
+ //}
+ //if err != nil {
+ // panic(err)
+ //}
+ //if len(libDir) != 1 || !libDir[0].IsDir() {
+ // panic("Failed to find sanitizer libraries")
+ //}
+ //
+ //pctx.StaticVariable("SDClangAsanLibDir", path.Join(absPath, libDirPrefix, libDir[0].Name(), "lib/linux"))
+}
+
var HostPrebuiltTag = exportedVars.ExportVariableConfigMethod("HostPrebuiltTag", android.Config.PrebuiltOS)
func ClangPath(ctx android.PathContext, file string) android.SourcePath {
diff --git a/cc/config/vndk.go b/cc/config/vndk.go
index db69ce785..420e65307 100644
--- a/cc/config/vndk.go
+++ b/cc/config/vndk.go
@@ -142,4 +142,5 @@ var VndkMustUseVendorVariantList = []string{
"libstagefright_xmlparser",
"libui",
"libxml2",
+ "libmedia_helper",//Remove it from the list once the workaround patch is cleared in S
}
diff --git a/cc/config/x86_linux_host.go b/cc/config/x86_linux_host.go
index 4e8fd7752..6ed25d5d2 100644
--- a/cc/config/x86_linux_host.go
+++ b/cc/config/x86_linux_host.go
@@ -106,6 +106,7 @@ var (
"resolv",
"rt",
"util",
+ "supc++",
}, "-l")
muslCrtBeginStaticBinary, muslCrtEndStaticBinary = []string{"libc_musl_crtbegin_static"}, []string{"libc_musl_crtend"}
diff --git a/cc/genrule.go b/cc/genrule.go
index 239064f1c..b5e1abefa 100644
--- a/cc/genrule.go
+++ b/cc/genrule.go
@@ -88,9 +88,6 @@ func (g *GenruleExtraProperties) CoreVariantNeeded(ctx android.BaseModuleContext
return !(ctx.SocSpecific() || ctx.DeviceSpecific())
}
-func (g *GenruleExtraProperties) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
- return Bool(g.Ramdisk_available)
-}
func (g *GenruleExtraProperties) VendorRamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
return Bool(g.Vendor_ramdisk_available)
@@ -112,6 +109,18 @@ func (g *GenruleExtraProperties) RecoveryVariantNeeded(ctx android.BaseModuleCon
}
}
+func (g *GenruleExtraProperties) RamdiskVariantNeeded(ctx android.BaseModuleContext) bool {
+ // If the build is using a snapshot, the ramdisk variant under AOSP directories
+ // is not needed.
+ ramdiskSnapshotVersion := ctx.DeviceConfig().RamdiskSnapshotVersion()
+ if ramdiskSnapshotVersion != "current" && ramdiskSnapshotVersion != "" &&
+ !snapshot.IsRamdiskProprietaryModule(ctx) {
+ return false
+ } else {
+ return Bool(g.Ramdisk_available)
+ }
+}
+
func (g *GenruleExtraProperties) ExtraImageVariations(ctx android.BaseModuleContext) []string {
if ctx.DeviceConfig().VndkVersion() == "" {
return nil
diff --git a/cc/image.go b/cc/image.go
index 3a0857b21..d99fc62aa 100644
--- a/cc/image.go
+++ b/cc/image.go
@@ -431,6 +431,9 @@ func MutateImage(mctx android.BaseModuleContext, m ImageMutatableModule) {
recoverySnapshotVersion := mctx.DeviceConfig().RecoverySnapshotVersion()
usingRecoverySnapshot := recoverySnapshotVersion != "current" &&
recoverySnapshotVersion != ""
+ ramdiskSnapshotVersion := mctx.DeviceConfig().RamdiskSnapshotVersion()
+ usingRamdiskSnapshot := ramdiskSnapshotVersion != "current" &&
+ ramdiskSnapshotVersion != ""
needVndkVersionVendorVariantForLlndk := false
if boardVndkVersion != "" {
boardVndkApiLevel, err := android.ApiLevelFromUser(mctx, boardVndkVersion)
@@ -485,6 +488,8 @@ func MutateImage(mctx android.BaseModuleContext, m ImageMutatableModule) {
// PRODUCT_EXTRA_VNDK_VERSIONS.
if m.InstallInRecovery() {
recoveryVariantNeeded = true
+ } else if m.InstallInRamdisk() {
+ ramdiskVariantNeeded = true
} else {
vendorVariants = append(vendorVariants, m.SnapshotVersion(mctx))
}
@@ -587,6 +592,13 @@ func MutateImage(mctx android.BaseModuleContext, m ImageMutatableModule) {
recoveryVariantNeeded = false
}
+ if !m.KernelHeadersDecorator() &&
+ !m.IsSnapshotPrebuilt() &&
+ usingRamdiskSnapshot &&
+ !snapshot.IsRamdiskProprietaryModule(mctx) {
+ ramdiskVariantNeeded = false
+ }
+
for _, variant := range android.FirstUniqueStrings(vendorVariants) {
m.AppendExtraVariant(VendorVariationPrefix + variant)
}
@@ -672,6 +684,19 @@ func squashRecoverySrcs(m *Module) {
}
}
+func squashRamdiskSrcs(m *Module) {
+ if lib, ok := m.compiler.(*libraryDecorator); ok {
+ lib.baseCompiler.Properties.Srcs = append(lib.baseCompiler.Properties.Srcs,
+ lib.baseCompiler.Properties.Target.Ramdisk.Srcs...)
+
+ lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs,
+ lib.baseCompiler.Properties.Target.Ramdisk.Exclude_srcs...)
+
+ lib.baseCompiler.Properties.Exclude_generated_sources = append(lib.baseCompiler.Properties.Exclude_generated_sources,
+ lib.baseCompiler.Properties.Target.Ramdisk.Exclude_generated_sources...)
+ }
+}
+
func squashVendorRamdiskSrcs(m *Module) {
if lib, ok := m.compiler.(*libraryDecorator); ok {
lib.baseCompiler.Properties.Exclude_srcs = append(lib.baseCompiler.Properties.Exclude_srcs, lib.baseCompiler.Properties.Target.Vendor_ramdisk.Exclude_srcs...)
@@ -682,6 +707,7 @@ func (c *Module) SetImageVariation(ctx android.BaseModuleContext, variant string
m := module.(*Module)
if variant == android.RamdiskVariation {
m.MakeAsPlatform()
+ squashRamdiskSrcs(m)
} else if variant == android.VendorRamdiskVariation {
m.MakeAsPlatform()
squashVendorRamdiskSrcs(m)
diff --git a/cc/library.go b/cc/library.go
index f9bef6c5e..8406ec975 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -640,6 +640,7 @@ type libraryDecorator struct {
*baseInstaller
collectedSnapshotHeaders android.Paths
+ isQiifaLibrary bool
apiListCoverageXmlPath android.ModuleOutPath
}
@@ -992,6 +993,17 @@ func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags, d
return flags
}
+func loadQiifaLibraryMetadata(library *libraryDecorator,ctx android.BaseModuleContext){
+ m := ctx.Module().(*Module)
+ libName := m.BaseModuleName()
+ for i := 0; i < len(config.QiifaAbiLibraryList); i++ {
+ if(config.QiifaAbiLibraryList[i] == libName ){
+ library.isQiifaLibrary = true
+ break
+ }
+ }
+}
+
func (library *libraryDecorator) headerAbiCheckerEnabled() bool {
return Bool(library.Properties.Header_abi_checker.Enabled)
}
@@ -1126,6 +1138,8 @@ type libraryInterface interface {
androidMkWriteAdditionalDependenciesForSourceAbiDiff(w io.Writer)
availableFor(string) bool
+ isLibraryQiifaEnabled() bool
+ loadQiifaMetadata(ctx android.BaseModuleContext)
getAPIListCoverageXMLPath() android.ModuleOutPath
@@ -1638,7 +1652,7 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec
addLsdumpPath(classifySourceAbiDump(ctx) + ":" + library.sAbiOutputFile.String())
refAbiDumpFile := getRefAbiDumpFile(ctx, vndkVersion, fileName)
- if refAbiDumpFile != nil {
+ if refAbiDumpFile != nil && !library.isQiifaLibrary {
library.sAbiDiff = sourceAbiDiff(ctx, library.sAbiOutputFile.Path(),
refAbiDumpFile, fileName, exportedHeaderFlags,
library.Properties.Header_abi_checker.Diff_flags,
@@ -1832,6 +1846,14 @@ func (library *libraryDecorator) toc() android.OptionalPath {
return library.tocFile
}
+func (library *libraryDecorator) isLibraryQiifaEnabled() bool {
+ return library.isQiifaLibrary
+}
+
+func (library *libraryDecorator) loadQiifaMetadata(ctx android.BaseModuleContext) {
+ loadQiifaLibraryMetadata(library,ctx)
+}
+
func (library *libraryDecorator) installSymlinkToRuntimeApex(ctx ModuleContext, file android.Path) {
dir := library.baseInstaller.installDir(ctx)
dirOnDevice := android.InstallPathToOnDevicePath(ctx, dir)
diff --git a/cc/linkable.go b/cc/linkable.go
index 6bec30c54..d4b477060 100644
--- a/cc/linkable.go
+++ b/cc/linkable.go
@@ -176,14 +176,10 @@ type LinkableInterface interface {
IsVndk() bool
IsVndkExt() bool
IsVndkPrivate() bool
- IsVendorPublicLibrary() bool
- IsVndkPrebuiltLibrary() bool
HasVendorVariant() bool
HasProductVariant() bool
HasNonSystemVariants() bool
- ProductSpecific() bool
InProduct() bool
- SdkAndPlatformVariantVisibleToMake() bool
// SubName returns the modules SubName, used for image and NDK/SDK variations.
SubName() string
diff --git a/cc/linker.go b/cc/linker.go
index bea65d441..366c4ab76 100644
--- a/cc/linker.go
+++ b/cc/linker.go
@@ -160,7 +160,11 @@ type BaseLinkerProperties struct {
Exclude_runtime_libs []string
}
Ramdisk struct {
- // list of static libs that only should be used to build the recovery
+ // list of shared libs that only should be used to build the ramdisk
+ // variant of the C/C++ module.
+ Shared_libs []string
+
+ // list of static libs that only should be used to build the ramdisk
// variant of the C/C++ module.
Static_libs []string
@@ -172,13 +176,17 @@ type BaseLinkerProperties struct {
// the ramdisk variant of the C/C++ module.
Exclude_static_libs []string
+ // list of header libs that should not be used to build the ramdisk variant
+ // of the C/C++ module.
+ Exclude_header_libs []string
+
// list of runtime libs that should not be installed along with the
// ramdisk variant of the C/C++ module.
Exclude_runtime_libs []string
}
Vendor_ramdisk struct {
// list of shared libs that should not be used to build
- // the recovery variant of the C/C++ module.
+ // the vendor ramdisk variant of the C/C++ module.
Exclude_shared_libs []string
// list of static libs that should not be used to build
@@ -361,10 +369,13 @@ func (linker *baseLinker) linkerDeps(ctx DepsContext, deps Deps) Deps {
}
if ctx.inRamdisk() {
+ deps.SharedLibs = append(deps.SharedLibs, linker.Properties.Target.Ramdisk.Shared_libs...)
deps.SharedLibs = removeListFromList(deps.SharedLibs, linker.Properties.Target.Ramdisk.Exclude_shared_libs)
deps.ReexportSharedLibHeaders = removeListFromList(deps.ReexportSharedLibHeaders, linker.Properties.Target.Ramdisk.Exclude_shared_libs)
deps.StaticLibs = append(deps.StaticLibs, linker.Properties.Target.Ramdisk.Static_libs...)
deps.StaticLibs = removeListFromList(deps.StaticLibs, linker.Properties.Target.Ramdisk.Exclude_static_libs)
+ deps.HeaderLibs = removeListFromList(deps.HeaderLibs, linker.Properties.Target.Ramdisk.Exclude_header_libs)
+ deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Ramdisk.Exclude_static_libs)
deps.ReexportStaticLibHeaders = removeListFromList(deps.ReexportStaticLibHeaders, linker.Properties.Target.Ramdisk.Exclude_static_libs)
deps.WholeStaticLibs = removeListFromList(deps.WholeStaticLibs, linker.Properties.Target.Ramdisk.Exclude_static_libs)
deps.RuntimeLibs = removeListFromList(deps.RuntimeLibs, linker.Properties.Target.Ramdisk.Exclude_runtime_libs)
diff --git a/cc/lto.go b/cc/lto.go
index 2c274bd3f..ed3b5e694 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -18,6 +18,8 @@ import (
"github.com/google/blueprint/proptools"
"android/soong/android"
+ "android/soong/cc/config"
+ "strings"
)
// LTO (link-time optimization) allows the compiler to optimize and generate
@@ -92,7 +94,13 @@ func (lto *lto) flags(ctx BaseModuleContext, flags Flags) Flags {
var ltoCFlag string
var ltoLdFlag string
if lto.ThinLTO() {
- ltoCFlag = "-flto=thin -fsplit-lto-unit"
+ // TODO(b/129607781) sdclang does not currently support
+ // the "-fsplit-lto-unit" option
+ if flags.Sdclang && !strings.Contains(config.SDClangPath, "9.0") {
+ ltoCFlag = "-flto=thin"
+ } else {
+ ltoCFlag = "-flto=thin -fsplit-lto-unit"
+ }
} else if lto.FullLTO() {
ltoCFlag = "-flto"
} else {
diff --git a/cc/makevars.go b/cc/makevars.go
index 6752f8cde..e2d814dff 100644
--- a/cc/makevars.go
+++ b/cc/makevars.go
@@ -17,6 +17,7 @@ package cc
import (
"fmt"
"sort"
+ "strconv"
"strings"
"sync"
@@ -71,6 +72,8 @@ func (c *notOnHostContext) Host() bool {
}
func makeVarsProvider(ctx android.MakeVarsContext) {
+ sdclangMakeVars(ctx)
+
ctx.Strict("LLVM_RELEASE_VERSION", "${config.ClangShortVersion}")
ctx.Strict("LLVM_PREBUILTS_VERSION", "${config.ClangVersion}")
ctx.Strict("LLVM_PREBUILTS_BASE", "${config.ClangBase}")
@@ -99,6 +102,7 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
ctx.Strict("BOARD_VNDK_VERSION", ctx.DeviceConfig().VndkVersion())
ctx.Strict("RECOVERY_SNAPSHOT_VERSION", ctx.DeviceConfig().RecoverySnapshotVersion())
+ ctx.Strict("RAMDISK_SNAPSHOT_VERSION", ctx.DeviceConfig().RamdiskSnapshotVersion())
// Filter vendor_public_library that are exported to make
exportedVendorPublicLibraries := []string{}
@@ -179,6 +183,17 @@ func makeVarsProvider(ctx android.MakeVarsContext) {
}
}
+func sdclangMakeVars(ctx android.MakeVarsContext) {
+ if config.ForceSDClangOff {
+ ctx.Strict("FORCE_SDCLANG_OFF", strconv.FormatBool(config.ForceSDClangOff))
+ }
+ if config.SDClang {
+ ctx.Strict("SDCLANG", strconv.FormatBool(config.SDClang))
+ }
+ ctx.Strict("SDCLANG_PATH", "${config.SDClangBin}")
+ ctx.Strict("SDCLANG_COMMON_FLAGS", "${config.SDClangFlags}")
+}
+
func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
target android.Target) {
var typePrefix string
@@ -304,10 +319,17 @@ func makeVarsToolchain(ctx android.MakeVarsContext, secondPrefix string,
ctx.Strict(makePrefix+"OTOOL", "${config.MacToolPath}/otool")
ctx.Strict(makePrefix+"STRIP", "${config.MacStripPath}")
} else {
- ctx.Strict(makePrefix+"AR", "${config.ClangBin}/llvm-ar")
- ctx.Strict(makePrefix+"READELF", "${config.ClangBin}/llvm-readelf")
- ctx.Strict(makePrefix+"NM", "${config.ClangBin}/llvm-nm")
- ctx.Strict(makePrefix+"STRIP", "${config.ClangBin}/llvm-strip")
+ if config.SDClang {
+ ctx.Strict(makePrefix+"AR", "${config.SDClangBin}/llvm-ar")
+ ctx.Strict(makePrefix+"READELF", "${config.SDClangBin}/llvm-readelf")
+ ctx.Strict(makePrefix+"NM", "${config.SDClangBin}/llvm-nm")
+ ctx.Strict(makePrefix+"STRIP", "${config.SDClangBin}/llvm-strip")
+ } else {
+ ctx.Strict(makePrefix+"AR", "${config.ClangBin}/llvm-ar")
+ ctx.Strict(makePrefix+"READELF", "${config.ClangBin}/llvm-readelf")
+ ctx.Strict(makePrefix+"NM", "${config.ClangBin}/llvm-nm")
+ ctx.Strict(makePrefix+"STRIP", "${config.ClangBin}/llvm-strip")
+ }
}
if target.Os.Class == android.Device {
diff --git a/cc/sabi.go b/cc/sabi.go
index e62ca6622..e9aff58c3 100644
--- a/cc/sabi.go
+++ b/cc/sabi.go
@@ -16,7 +16,6 @@ package cc
import (
"sync"
-
"android/soong/android"
"android/soong/cc/config"
)
@@ -170,8 +169,15 @@ func shouldCreateSourceAbiDumpForLibrary(ctx android.BaseModuleContext) bool {
// Mark the direct and transitive dependencies of libraries that need ABI check, so that ABI dumps
// of their dependencies would be generated.
func sabiDepsMutator(mctx android.TopDownMutatorContext) {
+ isQiifaLibrary := false
+ if m, ok := mctx.Module().(*Module); ok && m.library != nil {
+ m.library.loadQiifaMetadata(mctx)
+ if (m.library.isLibraryQiifaEnabled()){
+ isQiifaLibrary = true
+ }
+ }
// Escape hatch to not check any ABI dump.
- if mctx.Config().IsEnvTrue("SKIP_ABI_CHECKS") {
+ if mctx.Config().IsEnvTrue("SKIP_ABI_CHECKS") && !isQiifaLibrary {
return
}
// Only create ABI dump for native shared libraries and their static library dependencies.
diff --git a/cc/sanitize.go b/cc/sanitize.go
index 814fef6a9..7b4abf05e 100644
--- a/cc/sanitize.go
+++ b/cc/sanitize.go
@@ -445,6 +445,35 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
}
}
+ if s.Integer_overflow == nil && ctx.Config().IntegerOverflowEnabledForPath(ctx.ModuleDir()) && ctx.Arch().ArchType == android.Arm64 {
+ s.Integer_overflow = proptools.BoolPtr(true)
+ }
+
+ if ctx.Config().BoundSanitizerEnabledForPath(ctx.ModuleDir()) && ctx.Arch().ArchType == android.Arm64 {
+ s.Misc_undefined = append(s.Misc_undefined, "bounds")
+ }
+
+ if ctx.Config().BoundSanitizerDisabledForPath(ctx.ModuleDir()) && ctx.Arch().ArchType == android.Arm64 {
+ indx := indexList("bounds", s.Misc_undefined)
+ if (indexList("bounds", s.Misc_undefined) != -1) {
+ s.Misc_undefined = append(s.Misc_undefined[0:indx], s.Misc_undefined[indx+1:]...)
+ }
+ }
+
+ // Disable integer-overflow in exclude path
+ if ctx.Config().IntegerOverflowDisabledForPath(ctx.ModuleDir()) && ctx.Arch().ArchType == android.Arm64 {
+ indx := indexList("signed-integer-overflow", s.Misc_undefined)
+ if (indexList("signed-integer-overflow", s.Misc_undefined) != -1) {
+ s.Misc_undefined = append(s.Misc_undefined[0:indx], s.Misc_undefined[indx+1:]...)
+ }
+
+ indx = indexList("unsigned-integer-overflow", s.Misc_undefined)
+ if (indexList("unsigned-integer-overflow", s.Misc_undefined) != -1) {
+ s.Misc_undefined = append(s.Misc_undefined[0:indx], s.Misc_undefined[indx+1:]...)
+ }
+ s.Integer_overflow = nil
+ }
+
// Enable CFI for non-host components in the include paths
if s.Cfi == nil && ctx.Config().CFIEnabledForPath(ctx.ModuleDir()) && !ctx.Host() {
s.Cfi = proptools.BoolPtr(true)
@@ -452,6 +481,13 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
s.Diag.Cfi = proptools.BoolPtr(true)
}
}
+ // Disable CFI for all component in the exclude path (for Aarch64 only)
+ if ctx.Config().CFIDisabledForPath(ctx.ModuleDir()) && ctx.Arch().ArchType == android.Arm64 {
+ s.Cfi = nil
+ if inList("cfi", ctx.Config().SanitizeDeviceDiag()) {
+ s.Diag.Cfi = nil
+ }
+ }
// Is CFI actually enabled?
if !ctx.Config().EnableCFI() {
diff --git a/cc/snapshot_prebuilt.go b/cc/snapshot_prebuilt.go
index 9d40ad058..95d07a38f 100644
--- a/cc/snapshot_prebuilt.go
+++ b/cc/snapshot_prebuilt.go
@@ -13,7 +13,7 @@
// limitations under the License.
package cc
-// This file defines snapshot prebuilt modules, e.g. vendor snapshot and recovery snapshot. Such
+// This file defines snapshot prebuilt modules, e.g. vendor snapshot , ramdisk snapshot and recovery snapshot. Such
// snapshot modules will override original source modules with setting BOARD_VNDK_VERSION, with
// snapshot mutators and snapshot information maps which are also defined in this file.
@@ -48,6 +48,10 @@ type recoverySnapshotImage struct {
*snapshot.RecoverySnapshotImage
}
+type ramdiskSnapshotImage struct {
+ *snapshot.RamdiskSnapshotImage
+}
+
func (vendorSnapshotImage) imageVariantName(cfg android.DeviceConfig) string {
return VendorVariationPrefix + cfg.VndkVersion()
}
@@ -64,9 +68,18 @@ func (recoverySnapshotImage) moduleNameSuffix() string {
return RecoverySuffix
}
-// Override existing vendor and recovery snapshot for cc module specific extra functions
+func (ramdiskSnapshotImage) imageVariantName(cfg android.DeviceConfig) string {
+ return android.RamdiskVariation
+}
+
+func (ramdiskSnapshotImage) moduleNameSuffix() string {
+ return RamdiskSuffix
+}
+
+// Override existing vendor, recovery and ramdisk snapshot for cc module specific extra functions
var VendorSnapshotImageSingleton vendorSnapshotImage = vendorSnapshotImage{&snapshot.VendorSnapshotImageSingleton}
var RecoverySnapshotImageSingleton recoverySnapshotImage = recoverySnapshotImage{&snapshot.RecoverySnapshotImageSingleton}
+var RamdiskSnapshotImageSingleton ramdiskSnapshotImage = ramdiskSnapshotImage{&snapshot.RamdiskSnapshotImageSingleton}
func RegisterVendorSnapshotModules(ctx android.RegistrationContext) {
ctx.RegisterModuleType("vendor_snapshot", vendorSnapshotFactory)
@@ -86,9 +99,19 @@ func RegisterRecoverySnapshotModules(ctx android.RegistrationContext) {
ctx.RegisterModuleType("recovery_snapshot_object", RecoverySnapshotObjectFactory)
}
+func RegisterRamdiskSnapshotModules(ctx android.RegistrationContext) {
+ ctx.RegisterModuleType("ramdisk_snapshot", ramdiskSnapshotFactory)
+ ctx.RegisterModuleType("ramdisk_snapshot_shared", RamdiskSnapshotSharedFactory)
+ ctx.RegisterModuleType("ramdisk_snapshot_static", RamdiskSnapshotStaticFactory)
+ ctx.RegisterModuleType("ramdisk_snapshot_header", RamdiskSnapshotHeaderFactory)
+ ctx.RegisterModuleType("ramdisk_snapshot_binary", RamdiskSnapshotBinaryFactory)
+ ctx.RegisterModuleType("ramdisk_snapshot_object", RamdiskSnapshotObjectFactory)
+}
+
func init() {
RegisterVendorSnapshotModules(android.InitRegistrationContext)
RegisterRecoverySnapshotModules(android.InitRegistrationContext)
+ RegisterRamdiskSnapshotModules(android.InitRegistrationContext)
android.RegisterMakeVarsProvider(pctx, snapshotMakeVarsProvider)
}
@@ -110,6 +133,7 @@ type SnapshotProperties struct {
Binaries []string `android:"arch_variant"`
Objects []string `android:"arch_variant"`
}
+
type snapshotModule struct {
android.ModuleBase
@@ -234,6 +258,10 @@ func recoverySnapshotFactory() android.Module {
return snapshotFactory(RecoverySnapshotImageSingleton)
}
+func ramdiskSnapshotFactory() android.Module {
+ return snapshotFactory(RamdiskSnapshotImageSingleton)
+}
+
func snapshotFactory(image SnapshotImage) android.Module {
snapshotModule := &snapshotModule{}
snapshotModule.image = image
@@ -321,12 +349,12 @@ func (p *BaseSnapshotDecorator) SetSnapshotAndroidMkSuffix(ctx android.ModuleCon
Mutator: "image",
Variation: ProductVariationPrefix + ctx.DeviceConfig().PlatformVndkVersion()})
- if ctx.OtherModuleFarDependencyVariantExists(variations, ctx.Module().(LinkableInterface).BaseModuleName()) {
+ if ctx.OtherModuleFarDependencyVariantExists(variations, ctx.Module().(*Module).BaseModuleName()) {
p.baseProperties.Androidmk_suffix = p.Image.moduleNameSuffix()
return
}
- images := []SnapshotImage{VendorSnapshotImageSingleton, RecoverySnapshotImageSingleton}
+ images := []SnapshotImage{VendorSnapshotImageSingleton, RecoverySnapshotImageSingleton, RamdiskSnapshotImageSingleton}
for _, image := range images {
if p.Image == image {
@@ -588,6 +616,16 @@ func RecoverySnapshotSharedFactory() android.Module {
return module.Init()
}
+// ramdisk_snapshot_shared is a special prebuilt shared library which is auto-generated by
+// development/vendor_snapshot/update.py. As a part of ramdisk snapshot, ramdisk_snapshot_shared
+// overrides the ramdisk variant of the cc shared library with the same name, if BOARD_VNDK_VERSION
+// is set.
+func RamdiskSnapshotSharedFactory() android.Module {
+ module, prebuilt := snapshotLibraryFactory(RamdiskSnapshotImageSingleton, SnapshotSharedSuffix)
+ prebuilt.libraryDecorator.BuildOnlyShared()
+ return module.Init()
+}
+
// vendor_snapshot_static is a special prebuilt static library which is auto-generated by
// development/vendor_snapshot/update.py. As a part of vendor snapshot, vendor_snapshot_static
// overrides the vendor variant of the cc static library with the same name, if BOARD_VNDK_VERSION
@@ -608,6 +646,16 @@ func RecoverySnapshotStaticFactory() android.Module {
return module.Init()
}
+// ramdisk_snapshot_static is a special prebuilt static library which is auto-generated by
+// development/vendor_snapshot/update.py. As a part of ramdisk snapshot, ramdisk_snapshot_static
+// overrides the ramdisk variant of the cc static library with the same name, if BOARD_VNDK_VERSION
+// is set.
+func RamdiskSnapshotStaticFactory() android.Module {
+ module, prebuilt := snapshotLibraryFactory(RamdiskSnapshotImageSingleton, SnapshotStaticSuffix)
+ prebuilt.libraryDecorator.BuildOnlyStatic()
+ return module.Init()
+}
+
// vendor_snapshot_header is a special header library which is auto-generated by
// development/vendor_snapshot/update.py. As a part of vendor snapshot, vendor_snapshot_header
// overrides the vendor variant of the cc header library with the same name, if BOARD_VNDK_VERSION
@@ -628,6 +676,16 @@ func RecoverySnapshotHeaderFactory() android.Module {
return module.Init()
}
+// ramdisk_snapshot_header is a special header library which is auto-generated by
+// development/vendor_snapshot/update.py. As a part of ramdisk snapshot, ramdisk_snapshot_header
+// overrides the ramdisk variant of the cc header library with the same name, if BOARD_VNDK_VERSION
+// is set.
+func RamdiskSnapshotHeaderFactory() android.Module {
+ module, prebuilt := snapshotLibraryFactory(RamdiskSnapshotImageSingleton, snapshotHeaderSuffix)
+ prebuilt.libraryDecorator.HeaderOnly()
+ return module.Init()
+}
+
var _ snapshotSanitizer = (*snapshotLibraryDecorator)(nil)
//
@@ -704,6 +762,13 @@ func RecoverySnapshotBinaryFactory() android.Module {
return snapshotBinaryFactory(RecoverySnapshotImageSingleton, snapshotBinarySuffix)
}
+// ramdisk_snapshot_binary is a special prebuilt executable binary which is auto-generated by
+// development/vendor_snapshot/update.py. As a part of ramdisk snapshot, ramdisk_snapshot_binary
+// overrides the ramdisk variant of the cc binary with the same name, if BOARD_VNDK_VERSION is set.
+func RamdiskSnapshotBinaryFactory() android.Module {
+ return snapshotBinaryFactory(RamdiskSnapshotImageSingleton, snapshotBinarySuffix)
+}
+
func snapshotBinaryFactory(image SnapshotImage, moduleSuffix string) android.Module {
module, binary := NewBinary(android.DeviceSupported)
binary.baseLinker.Properties.No_libcrt = BoolPtr(true)
@@ -808,6 +873,24 @@ func RecoverySnapshotObjectFactory() android.Module {
return module.Init()
}
+// ramdisk_snapshot_object is a special prebuilt compiled object file which is auto-generated by
+// development/vendor_snapshot/update.py. As a part of ramdisk snapshot, ramdisk_snapshot_object
+// overrides the ramdisk variant of the cc object with the same name, if BOARD_VNDK_VERSION is set.
+func RamdiskSnapshotObjectFactory() android.Module {
+ module := newObject(android.DeviceSupported)
+
+ prebuilt := &snapshotObjectLinker{
+ objectLinker: objectLinker{
+ baseLinker: NewBaseLinker(nil),
+ },
+ }
+ module.linker = prebuilt
+
+ prebuilt.Init(module, RamdiskSnapshotImageSingleton, snapshotObjectSuffix)
+ module.AddProperties(&prebuilt.properties)
+ return module.Init()
+}
+
type SnapshotInterface interface {
MatchesWithDevice(config android.DeviceConfig) bool
IsSnapshotPrebuilt() bool
diff --git a/cc/snapshot_utils.go b/cc/snapshot_utils.go
index de50ef50f..ac45baeaa 100644
--- a/cc/snapshot_utils.go
+++ b/cc/snapshot_utils.go
@@ -106,14 +106,15 @@ func (s *snapshotMap) get(name string, arch android.ArchType) (snapshot string,
// If it's true, collectHeadersForSnapshot will be called in GenerateAndroidBuildActions.
func ShouldCollectHeadersForSnapshot(ctx android.ModuleContext, m LinkableInterface, apexInfo android.ApexInfo) bool {
if ctx.DeviceConfig().VndkVersion() != "current" &&
- ctx.DeviceConfig().RecoverySnapshotVersion() != "current" {
+ ctx.DeviceConfig().RecoverySnapshotVersion() != "current" &&
+ ctx.DeviceConfig().RamdiskSnapshotVersion() != "current" {
return false
}
if _, ok := isVndkSnapshotAware(ctx.DeviceConfig(), m, apexInfo); ok {
return ctx.Config().VndkSnapshotBuildArtifacts()
}
- for _, image := range []SnapshotImage{VendorSnapshotImageSingleton, RecoverySnapshotImageSingleton} {
+ for _, image := range []SnapshotImage{VendorSnapshotImageSingleton, RecoverySnapshotImageSingleton, RamdiskSnapshotImageSingleton} {
if isSnapshotAware(ctx.DeviceConfig(), m, image.IsProprietaryPath(ctx.ModuleDir(), ctx.DeviceConfig()), apexInfo, image) {
return true
}
diff --git a/cc/testing.go b/cc/testing.go
index 32f7c6080..b8d6a3d41 100644
--- a/cc/testing.go
+++ b/cc/testing.go
@@ -67,6 +67,7 @@ func commonDefaultModules() string {
vendor_available: true,
product_available: true,
recovery_available: true,
+ ramdisk_available: true,
no_libcrt: true,
sdk_version: "minimum",
nocrt: true,
@@ -136,6 +137,7 @@ func commonDefaultModules() string {
stl: "none",
system_shared_libs: [],
recovery_available: true,
+ ramdisk_available: true,
stubs: {
versions: ["27", "28", "29"],
},
@@ -151,6 +153,7 @@ func commonDefaultModules() string {
stl: "none",
system_shared_libs: [],
recovery_available: true,
+ ramdisk_available: true,
stubs: {
versions: ["27", "28", "29"],
},
@@ -170,6 +173,7 @@ func commonDefaultModules() string {
vendor_ramdisk_available: true,
product_available: true,
recovery_available: true,
+ ramdisk_available: true,
native_coverage: false,
system_shared_libs: [],
stl: "none",
@@ -181,6 +185,7 @@ func commonDefaultModules() string {
vendor_ramdisk_available: true,
product_available: true,
recovery_available: true,
+ ramdisk_available: true,
native_coverage: false,
system_shared_libs: [],
stl: "none",
@@ -215,6 +220,7 @@ func commonDefaultModules() string {
stl: "none",
system_shared_libs: [],
recovery_available: true,
+ ramdisk_available: true,
stubs: {
versions: ["27", "28", "29"],
},
@@ -232,6 +238,7 @@ func commonDefaultModules() string {
nocrt: true,
system_shared_libs: [],
recovery_available: true,
+ ramdisk_available: true,
llndk: {
symbol_file: "libft2.map.txt",
private: true,
@@ -247,6 +254,7 @@ func commonDefaultModules() string {
vendor_ramdisk_available: true,
product_available: true,
recovery_available: true,
+ ramdisk_available: true,
host_supported: true,
min_sdk_version: "29",
apex_available: [
@@ -263,6 +271,7 @@ func commonDefaultModules() string {
vendor_available: true,
product_available: true,
recovery_available: true,
+ ramdisk_available: true,
host_supported: true,
min_sdk_version: "29",
vndk: {
@@ -285,6 +294,7 @@ func commonDefaultModules() string {
vendor_ramdisk_available: true,
product_available: true,
recovery_available: true,
+ ramdisk_available: true,
min_sdk_version: "29",
apex_available: [
"//apex_available:platform",
@@ -296,6 +306,7 @@ func commonDefaultModules() string {
name: "crt_defaults",
defaults: ["linux_bionic_supported"],
recovery_available: true,
+ ramdisk_available: true,
vendor_available: true,
vendor_ramdisk_available: true,
product_available: true,
@@ -439,6 +450,7 @@ func withLinuxBionic() string {
name: "linker",
defaults: ["linux_bionic_supported"],
recovery_available: true,
+ ramdisk_available: true,
stl: "none",
nocrt: true,
static_executable: true,
@@ -586,8 +598,10 @@ var PrepareForTestWithCcIncludeVndk = android.GroupFixturePreparers(
android.FixtureRegisterWithContext(func(ctx android.RegistrationContext) {
snapshot.VendorSnapshotImageSingleton.Init(ctx)
snapshot.RecoverySnapshotImageSingleton.Init(ctx)
+ snapshot.RamdiskSnapshotImageSingleton.Init(ctx)
RegisterVendorSnapshotModules(ctx)
RegisterRecoverySnapshotModules(ctx)
+ RegisterRamdiskSnapshotModules(ctx)
ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
}),
)
@@ -630,8 +644,10 @@ func CreateTestContext(config android.Config) *android.TestContext {
snapshot.VendorSnapshotImageSingleton.Init(ctx)
snapshot.RecoverySnapshotImageSingleton.Init(ctx)
+ snapshot.RamdiskSnapshotImageSingleton.Init(ctx)
RegisterVendorSnapshotModules(ctx)
RegisterRecoverySnapshotModules(ctx)
+ RegisterRamdiskSnapshotModules(ctx)
ctx.RegisterSingletonType("vndk-snapshot", VndkSnapshotSingleton)
RegisterVndkLibraryTxtTypes(ctx)
diff --git a/cc/util.go b/cc/util.go
index b256b9ada..c5fd30084 100644
--- a/cc/util.go
+++ b/cc/util.go
@@ -83,6 +83,7 @@ func flagsToBuilderFlags(in Flags) builderFlags {
tidyFlags: strings.Join(in.TidyFlags, " "),
sAbiFlags: strings.Join(in.SAbiFlags, " "),
toolchain: in.Toolchain,
+ sdclang: in.Sdclang,
gcovCoverage: in.GcovCoverage,
tidy: in.Tidy,
needTidyFiles: in.NeedTidyFiles,
diff --git a/cc/vendor_snapshot.go b/cc/vendor_snapshot.go
index e7c05aca8..18cb0551e 100644
--- a/cc/vendor_snapshot.go
+++ b/cc/vendor_snapshot.go
@@ -13,6 +13,10 @@
// limitations under the License.
package cc
+// This file contains singletons to capture vendor, ramdisk and recovery snapshot. They consist of prebuilt
+// modules under AOSP so older vendor, ramdisk and recovery can be built with a newer system in a single
+// source tree.
+
import (
"encoding/json"
"path/filepath"
@@ -22,8 +26,6 @@ import (
"android/soong/snapshot"
)
-// This file defines how to capture cc modules into snapshot package.
-
// Checks if the target image would contain VNDK
func includeVndk(image snapshot.SnapshotImage) bool {
if image.ImageName() == snapshot.VendorSnapshotImageName {
@@ -407,7 +409,7 @@ var ccSnapshotAction snapshot.GenerateSnapshotAction = func(s snapshot.SnapshotS
for _, header := range android.FirstUniquePaths(headers) {
snapshotOutputs = append(snapshotOutputs, copyFile(ctx, header, filepath.Join(includeDir, header.String()), s.Fake))
}
-
+
return snapshotOutputs
}
diff --git a/java/app.go b/java/app.go
index 41419ba78..f161f14bb 100755
--- a/java/app.go
+++ b/java/app.go
@@ -18,6 +18,8 @@ package java
// related module types, including their override variants.
import (
+ "fmt"
+ "os"
"path/filepath"
"strings"
@@ -723,6 +725,59 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
}
a.buildAppDependencyInfo(ctx)
+
+ config := ctx.Config().VendorConfig("vendor_clean_up_java")
+ if ctx.SocSpecific() || ctx.DeviceSpecific() {
+ output := filepath.Join(config.String("output"),
+ os.Getenv("TARGET_PRODUCT"),
+ config.String("file"))
+ split,_ := filepath.Split(output)
+ if config.String("config") == "warning" {
+ os.MkdirAll(split, os.ModePerm)
+ if outputs, err := os.OpenFile(output,
+ os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666); err == nil {
+ defer outputs.Close()
+ fmt.Fprintf(outputs,
+ "Module %s in %s hit the violation because it compile " +
+ "the java in vendor. Only prebuilt for Java Apk and Jar" +
+ " is allowed in vendor. for detail instruction, pls " +
+ "refer to go/JavaCleanUpInVendor \n",
+ ctx.ModuleName(),
+ ctx.ModuleDir())
+ } else {
+ fmt.Println("Err: ",err)
+ }
+ } else if config.String("config") == "enforcing"{
+ config_list := false
+ for _, splitstr:= range strings.Split(config.String("allowlist"), " "){
+ if strings.TrimSpace(splitstr) == ctx.ModuleName() {
+ config_list = true
+ }
+ }
+ if config_list == true {
+ os.MkdirAll(split, os.ModePerm)
+ if outputs_enforce, err := os.OpenFile(output,
+ os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666); err == nil {
+ defer outputs_enforce.Close()
+ fmt.Fprintf(outputs_enforce,
+ "Module %s in %s hit the violation because it compile " +
+ "the java in vendor. Only prebuilt for Java Apk and Jar" +
+ " is allowed in vendor. for detail instruction, pls " +
+ "refer to go/JavaCleanUpInVendor \n",
+ ctx.ModuleName(),
+ ctx.ModuleDir())
+ } else {
+ fmt.Println("Err: ",err)
+ }
+ } else {
+ ctx.PropertyErrorf("ERR", "Module " + ctx.ModuleName() +
+ " in " + ctx.ModuleDir() + " hit the violation because it " +
+ "compile the java in vendor. Only prebuilt for Java Apk and" +
+ " Jar is allowed in vendor. for detail instruction, pls" +
+ " refer to go/JavaCleanUpInVendor")
+ }
+ }
+ }
}
type appDepsInterface interface {
diff --git a/rust/rust.go b/rust/rust.go
index c4fd14859..1579e6115 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -35,11 +35,12 @@ var pctx = android.NewPackageContext("android/soong/rust")
func init() {
// Only allow rust modules to be defined for certain projects
- android.AddNeverAllowRules(
+ // Temporarily disable allow list
+ /* android.AddNeverAllowRules(
android.NeverAllow().
NotIn(append(config.RustAllowedPaths, config.DownstreamRustAllowedPaths...)...).
ModuleType(config.RustModuleTypes...))
-
+ */
android.RegisterModuleType("rust_defaults", defaultsFactory)
android.PreDepsMutators(func(ctx android.RegisterMutatorsContext) {
ctx.BottomUp("rust_libraries", LibraryMutator).Parallel()
@@ -332,20 +333,6 @@ func (mod *Module) IsVndkSp() bool {
return false
}
-func (mod *Module) IsVndkPrebuiltLibrary() bool {
- // Rust modules do not provide VNDK prebuilts
- return false
-}
-
-func (mod *Module) IsVendorPublicLibrary() bool {
- return mod.VendorProperties.IsVendorPublicLibrary
-}
-
-func (mod *Module) SdkAndPlatformVariantVisibleToMake() bool {
- // Rust modules to not provide Sdk variants
- return false
-}
-
func (c *Module) IsVndkPrivate() bool {
return false
}
@@ -855,7 +842,24 @@ func (mod *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
toolchain := mod.toolchain(ctx)
mod.makeLinkType = cc.GetMakeLinkType(actx, mod)
- mod.Properties.SubName = cc.GetSubnameProperty(actx, mod)
+ // Differentiate static libraries that are vendor available
+ if mod.UseVndk() {
+ if mod.InProduct() && !mod.OnlyInProduct() {
+ mod.Properties.SubName += cc.ProductSuffix
+ } else {
+ mod.Properties.SubName += cc.VendorSuffix
+ }
+ } else if mod.InRamdisk() && !mod.OnlyInRamdisk() {
+ mod.Properties.SubName += cc.RamdiskSuffix
+ } else if mod.InVendorRamdisk() && !mod.OnlyInVendorRamdisk() {
+ mod.Properties.SubName += cc.VendorRamdiskSuffix
+ } else if mod.InRecovery() && !mod.OnlyInRecovery() {
+ mod.Properties.SubName += cc.RecoverySuffix
+ }
+
+ if mod.Target().NativeBridge == android.NativeBridgeEnabled {
+ mod.Properties.SubName += cc.NativeBridgeSuffix
+ }
if !toolchain.Supported() {
// This toolchain's unsupported, there's nothing to do for this mod.
diff --git a/rust/snapshot_prebuilt.go b/rust/snapshot_prebuilt.go
index dfbc1d1e7..158568b25 100644..100755
--- a/rust/snapshot_prebuilt.go
+++ b/rust/snapshot_prebuilt.go
@@ -46,6 +46,8 @@ func registerRustSnapshotModules(ctx android.RegistrationContext) {
"vendor_snapshot_rlib", VendorSnapshotRlibFactory)
cc.RecoverySnapshotImageSingleton.RegisterAdditionalModule(ctx,
"recovery_snapshot_rlib", RecoverySnapshotRlibFactory)
+ cc.RamdiskSnapshotImageSingleton.RegisterAdditionalModule(ctx,
+ "ramdisk_snapshot_rlib", RamdiskSnapshotRlibFactory)
}
func snapshotLibraryFactory(image cc.SnapshotImage, moduleSuffix string) (*Module, *snapshotLibraryDecorator) {
@@ -114,6 +116,13 @@ func RecoverySnapshotRlibFactory() android.Module {
return module.Init()
}
+func RamdiskSnapshotRlibFactory() android.Module {
+ module, prebuilt := snapshotLibraryFactory(cc.RamdiskSnapshotImageSingleton, cc.SnapshotRlibSuffix)
+ prebuilt.libraryDecorator.BuildOnlyRlib()
+ prebuilt.libraryDecorator.setNoStdlibs()
+ return module.Init()
+}
+
func (library *snapshotLibraryDecorator) MatchesWithDevice(config android.DeviceConfig) bool {
arches := config.Arches()
if len(arches) == 0 || arches[0].ArchType.String() != library.Arch() {
diff --git a/rust/snapshot_utils.go b/rust/snapshot_utils.go
index 8dabd9bf6..52b4b6acf 100644
--- a/rust/snapshot_utils.go
+++ b/rust/snapshot_utils.go
@@ -40,6 +40,11 @@ func (mod *Module) ExcludeFromRecoverySnapshot() bool {
return Bool(mod.Properties.Exclude_from_recovery_snapshot)
}
+func (mod *Module) ExcludeFromRamdiskSnapshot() bool {
+ // TODO Rust does not yet support snapshotting
+ return false
+}
+
func (mod *Module) IsSnapshotLibrary() bool {
if lib, ok := mod.compiler.(libraryInterface); ok {
// Rust-native dylibs are not snapshot supported yet. Only snapshot the rlib-std variants of rlibs.
diff --git a/scripts/Android.bp b/scripts/Android.bp
index 4773579e3..73cd7818c 100644
--- a/scripts/Android.bp
+++ b/scripts/Android.bp
@@ -1,6 +1,10 @@
package {
default_applicable_licenses: ["Android-Apache-2.0"],
- default_visibility: ["//build/soong:__subpackages__"],
+ default_visibility: [
+ "//build/soong:__subpackages__",
+ "//device/qcom/qssi/vsdk_tools:__subpackages__",
+ "//vendor:__subpackages__"
+ ],
}
python_binary_host {
diff --git a/scripts/check_boot_jars/package_allowed_list.txt b/scripts/check_boot_jars/package_allowed_list.txt
index a02c19560..a2d4773a8 100644
--- a/scripts/check_boot_jars/package_allowed_list.txt
+++ b/scripts/check_boot_jars/package_allowed_list.txt
@@ -251,3 +251,11 @@ com\.google\.i18n\.phonenumbers
# Packages used for Android in Chrome OS
org\.chromium\.arc
org\.chromium\.arc\..*
+
+# QC adds
+com.qualcomm.qti
+com.quicinc.tcmiface
+com.qualcomm.wfd
+com.qualcomm.wfd.service
+org.codeaurora.internal
+qcom.fmradio
diff --git a/snapshot/Android.bp b/snapshot/Android.bp
index 335499306..2ea6aaf99 100644
--- a/snapshot/Android.bp
+++ b/snapshot/Android.bp
@@ -16,6 +16,7 @@ bootstrap_go_package {
srcs: [
"host_fake_snapshot.go",
"host_snapshot.go",
+ "ramdisk_snapshot.go",
"recovery_snapshot.go",
"snapshot.go",
"snapshot_base.go",
diff --git a/snapshot/ramdisk_snapshot.go b/snapshot/ramdisk_snapshot.go
new file mode 100644
index 000000000..adf6901d2
--- /dev/null
+++ b/snapshot/ramdisk_snapshot.go
@@ -0,0 +1,147 @@
+// Copyright 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// 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
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package snapshot
+
+import "android/soong/android"
+
+// Interface for modules which can be captured in the ramdisk snapshot.
+type RamdiskSnapshotModuleInterface interface {
+ SnapshotModuleInterfaceBase
+ InRamdisk() bool
+ ExcludeFromRamdiskSnapshot() bool
+}
+
+var ramdiskSnapshotSingleton = SnapshotSingleton{
+ "ramdisk", // name
+ "SOONG_RAMDISK_SNAPSHOT_ZIP", // makeVar
+ android.OptionalPath{}, // snapshotZipFile
+ RamdiskSnapshotImageSingleton, // Image
+ false, // Fake
+}
+
+var ramdiskFakeSnapshotSingleton = SnapshotSingleton{
+ "ramdisk", // name
+ "SOONG_RAMDISK_FAKE_SNAPSHOT_ZIP", // makeVar
+ android.OptionalPath{}, // snapshotZipFile
+ RamdiskSnapshotImageSingleton, // Image
+ true, // Fake
+}
+
+func RamdiskSnapshotSingleton() android.Singleton {
+ return &ramdiskSnapshotSingleton
+}
+
+func RamdiskFakeSnapshotSingleton() android.Singleton {
+ return &ramdiskFakeSnapshotSingleton
+}
+
+// Determine if a dir under source tree is an SoC-owned proprietary directory based
+// on ramdisk snapshot configuration
+// Examples: device/, ramdisk/
+func isRamdiskProprietaryPath(dir string, deviceConfig android.DeviceConfig) bool {
+ return RamdiskSnapshotSingleton().(*SnapshotSingleton).Image.IsProprietaryPath(dir, deviceConfig)
+}
+
+func IsRamdiskProprietaryModule(ctx android.BaseModuleContext) bool {
+ // Any module in a ramdisk proprietary path is a ramdisk proprietary
+ // module.
+ if isRamdiskProprietaryPath(ctx.ModuleDir(), ctx.DeviceConfig()) {
+ return true
+ }
+
+ // However if the module is not in a ramdisk proprietary path, it may
+ // still be a ramdisk proprietary module. This happens for cc modules
+ // that are excluded from the ramdisk snapshot, and it means that the
+ // ramdisk has assumed control of the framework-provided module.
+ if c, ok := ctx.Module().(RamdiskSnapshotModuleInterface); ok {
+ if c.ExcludeFromRamdiskSnapshot() {
+ return true
+ }
+ }
+
+ return false
+}
+
+var RamdiskSnapshotImageName = "ramdisk"
+
+type RamdiskSnapshotImage struct{}
+
+func (RamdiskSnapshotImage) Init(ctx android.RegistrationContext) {
+ ctx.RegisterSingletonType("ramdisk-snapshot", RamdiskSnapshotSingleton)
+ ctx.RegisterSingletonType("ramdisk-fake-snapshot", RamdiskFakeSnapshotSingleton)
+}
+
+func (RamdiskSnapshotImage) RegisterAdditionalModule(ctx android.RegistrationContext, name string, factory android.ModuleFactory) {
+ ctx.RegisterModuleType(name, factory)
+}
+
+func (RamdiskSnapshotImage) shouldGenerateSnapshot(ctx android.SingletonContext) bool {
+ // BOARD_VNDK_VERSION must be set to 'current' in order to generate a snapshot.
+ return ctx.DeviceConfig().VndkVersion() == "current"
+}
+
+func (RamdiskSnapshotImage) InImage(m SnapshotModuleInterfaceBase) func() bool {
+ v, ok := m.(RamdiskSnapshotModuleInterface)
+
+ if !ok {
+ // This module does not support Ramdisk snapshot
+ return func() bool { return false }
+ }
+
+ return v.InRamdisk
+}
+
+func (RamdiskSnapshotImage) IsProprietaryPath(dir string, deviceConfig android.DeviceConfig) bool {
+ return isDirectoryExcluded(dir, deviceConfig.RamdiskSnapshotDirsExcludedMap(), deviceConfig.RamdiskSnapshotDirsIncludedMap())
+}
+
+func (RamdiskSnapshotImage) ExcludeFromSnapshot(m SnapshotModuleInterfaceBase) bool {
+ v, ok := m.(RamdiskSnapshotModuleInterface)
+
+ if !ok {
+ // This module does not support Ramdisk snapshot
+ return true
+ }
+
+ return v.ExcludeFromRamdiskSnapshot()
+}
+
+func (RamdiskSnapshotImage) IsUsingSnapshot(cfg android.DeviceConfig) bool {
+ vndkVersion := cfg.VndkVersion()
+ return vndkVersion != "current" && vndkVersion != ""
+}
+
+func (RamdiskSnapshotImage) TargetSnapshotVersion(cfg android.DeviceConfig) string {
+ return cfg.VndkVersion()
+}
+
+// returns true iff a given module SHOULD BE EXCLUDED, false if included
+func (RamdiskSnapshotImage) ExcludeFromDirectedSnapshot(cfg android.DeviceConfig, name string) bool {
+ // If we're using full snapshot, not directed snapshot, capture every module
+ if !cfg.DirectedRamdiskSnapshot() {
+ return false
+ }
+ // Else, checks if name is in RAMDISK_SNAPSHOT_MODULES.
+ return !cfg.RamdiskSnapshotModules()[name]
+}
+
+func (RamdiskSnapshotImage) ImageName() string {
+ return RamdiskSnapshotImageName
+}
+
+var RamdiskSnapshotImageSingleton RamdiskSnapshotImage
+
+func init() {
+ RamdiskSnapshotImageSingleton.Init(android.InitRegistrationContext)
+}
diff --git a/ui/build/paths/config.go b/ui/build/paths/config.go
index 831a80f97..1197c4816 100644
--- a/ui/build/paths/config.go
+++ b/ui/build/paths/config.go
@@ -74,6 +74,12 @@ func GetConfig(name string) PathConfig {
}
var Configuration = map[string]PathConfig{
+ "aarch64-linux-android-ar": Log,
+ "aarch64-linux-android-gcc": Log,
+ "aarch64-linux-android-ld": Log,
+ "aarch64-linux-android-nm": Log,
+ "aarch64-linux-android-objcopy": Log,
+ "aarch64-linux-android-objdump": Log,
"bash": Allowed,
"dd": Allowed,
"diff": Allowed,
@@ -88,6 +94,8 @@ var Configuration = map[string]PathConfig{
"javap": Allowed,
"lsof": Allowed,
"openssl": Allowed,
+ "perl": Log,
+ "printf": Log,
"pstree": Allowed,
"rsync": Allowed,
"sh": Allowed,
@@ -110,10 +118,72 @@ var Configuration = map[string]PathConfig{
"ld.gold": Forbidden,
"pkg-config": Forbidden,
- // These are toybox tools that only work on Linux.
- "pgrep": LinuxOnlyPrebuilt,
- "pkill": LinuxOnlyPrebuilt,
- "ps": LinuxOnlyPrebuilt,
+ // On Linux we'll use the toybox versions of these instead.
+ "basename": LinuxOnlyPrebuilt,
+ "cat": LinuxOnlyPrebuilt,
+ "chmod": LinuxOnlyPrebuilt,
+ // TODO (b/121282416): switch back to LinuxOnlyPrebuilt when build is hermetic
+ "cmp": Log,
+ // TODO (b/121282416): switch back to LinuxOnlyPrebuilt when build is hermetic
+ "cp": Log,
+ "comm": LinuxOnlyPrebuilt,
+ "cut": LinuxOnlyPrebuilt,
+ "date": LinuxOnlyPrebuilt,
+ // TODO (b/121282416): switch back to LinuxOnlyPrebuilt when build is hermetic
+ "dirname": Log,
+ "du": LinuxOnlyPrebuilt,
+ "echo": LinuxOnlyPrebuilt,
+ "egrep": LinuxOnlyPrebuilt,
+ "env": LinuxOnlyPrebuilt,
+ "getconf": LinuxOnlyPrebuilt,
+ "grep": LinuxOnlyPrebuilt,
+ "head": LinuxOnlyPrebuilt,
+ "hostname": LinuxOnlyPrebuilt,
+ "id": LinuxOnlyPrebuilt,
+ "ln": LinuxOnlyPrebuilt,
+ "ls": LinuxOnlyPrebuilt,
+ "md5sum": LinuxOnlyPrebuilt,
+ // TODO (b/121282416): switch back to LinuxOnlyPrebuilt when build is hermetic
+ "mkdir": Log,
+ "mktemp": LinuxOnlyPrebuilt,
+ "mv": LinuxOnlyPrebuilt,
+ "od": LinuxOnlyPrebuilt,
+ // TODO (b/121282416): switch back to LinuxOnlyPrebuilt when build is hermetic
+ "paste": Log,
+ "pgrep": LinuxOnlyPrebuilt,
+ "pkill": LinuxOnlyPrebuilt,
+ "ps": LinuxOnlyPrebuilt,
+ // TODO (b/121282416): switch back to LinuxOnlyPrebuilt when build is hermetic
+ "pwd": Log,
+ "readlink": LinuxOnlyPrebuilt,
+ "rm": LinuxOnlyPrebuilt,
+ // TODO (b/121282416): switch back to LinuxOnlyPrebuilt when build is hermetic
+ "rmdir": Log,
+ "sed": LinuxOnlyPrebuilt,
+ "seq": LinuxOnlyPrebuilt,
+ "setsid": LinuxOnlyPrebuilt,
+ "sha1sum": LinuxOnlyPrebuilt,
+ "sha256sum": LinuxOnlyPrebuilt,
+ "sha512sum": LinuxOnlyPrebuilt,
+ "sleep": LinuxOnlyPrebuilt,
+ "sort": LinuxOnlyPrebuilt,
+ "stat": LinuxOnlyPrebuilt,
+ // TODO (b/121282416): switch back to LinuxOnlyPrebuilt when build is hermetic
+ "tail": Log,
+ "tar": LinuxOnlyPrebuilt,
+ "tee": LinuxOnlyPrebuilt,
+ "timeout": LinuxOnlyPrebuilt,
+ // TODO (b/121282416): switch back to LinuxOnlyPrebuilt when build is hermetic
+ "touch": Log,
+ "true": LinuxOnlyPrebuilt,
+ "uname": LinuxOnlyPrebuilt,
+ "uniq": LinuxOnlyPrebuilt,
+ "unix2dos": LinuxOnlyPrebuilt,
+ "wc": LinuxOnlyPrebuilt,
+ "whoami": LinuxOnlyPrebuilt,
+ "which": LinuxOnlyPrebuilt,
+ // TODO (b/121282416): switch back to LinuxOnlyPrebuilt when build is hermetic
+ "xxd": Log,
}
func init() {
diff --git a/ui/build/sandbox_linux.go b/ui/build/sandbox_linux.go
index 5b2046e54..d9f2ae72c 100644
--- a/ui/build/sandbox_linux.go
+++ b/ui/build/sandbox_linux.go
@@ -34,14 +34,14 @@ type Sandbox struct {
var (
noSandbox = Sandbox{}
basicSandbox = Sandbox{
- Enabled: true,
+ Enabled: false,
}
dumpvarsSandbox = basicSandbox
katiSandbox = basicSandbox
soongSandbox = basicSandbox
ninjaSandbox = Sandbox{
- Enabled: true,
+ Enabled: false,
DisableWhenUsingGoma: true,
AllowBuildBrokenUsesNetwork: true,
diff --git a/ui/build/soong.go b/ui/build/soong.go
index c7f22f946..ab9bc66b5 100644
--- a/ui/build/soong.go
+++ b/ui/build/soong.go
@@ -444,8 +444,8 @@ func runSoong(ctx Context, config Config) {
"-o", "usesphonyoutputs=yes",
"-o", "preremoveoutputs=yes",
"-w", "dupbuild=err",
- "-w", "outputdir=err",
- "-w", "missingoutfile=err",
+ "-w", "outputdir=warn",
+ "-w", "missingoutfile=warn",
"-j", strconv.Itoa(config.Parallel()),
"--frontend_file", fifo,
"-f", filepath.Join(config.SoongOutDir(), ninjaFile),
@@ -461,6 +461,17 @@ func runSoong(ctx Context, config Config) {
// root of the source tree and the output root
ninjaEnv.Set("TOP", os.Getenv("TOP"))
+ qcEnvVars := []string{
+ "TARGET_BOARD_PLATFORM",
+ "SDCLANG_AE_CONFIG",
+ "SDCLANG_CONFIG",
+ "SDCLANG_SA_ENABLED",
+ "QIIFA_BUILD_CONFIG",
+ }
+ for _, qcVar := range qcEnvVars {
+ ninjaEnv.Set(qcVar, os.Getenv(qcVar))
+ }
+
cmd.Environment = &ninjaEnv
cmd.Sandbox = soongSandbox
cmd.RunAndStreamOrFatal()