From 8bfedda18bcf5b272547cbaaa885526e7ad2442b Mon Sep 17 00:00:00 2001 From: Tad Date: Thu, 10 Nov 2022 16:50:18 -0500 Subject: [PATCH] 14/15/16: Fix compile failure with modern kernels https://android-review.googlesource.com/c/platform/art/+/2226578 https://groups.google.com/g/Android-building/c/ZfUQQWt_ABI Signed-off-by: Tad --- .../Common/android_art/0001-mmap_fix.patch | 31 +++++++++++++++++++ Scripts/LineageOS-14.1/Patch.sh | 4 +++ Scripts/LineageOS-15.1/Patch.sh | 4 +++ Scripts/LineageOS-16.0/Patch.sh | 1 + Scripts/LineageOS-17.1/Functions.sh | 3 +- Scripts/init.sh | 2 +- 6 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 Patches/Common/android_art/0001-mmap_fix.patch diff --git a/Patches/Common/android_art/0001-mmap_fix.patch b/Patches/Common/android_art/0001-mmap_fix.patch new file mode 100644 index 00000000..fa2b62c0 --- /dev/null +++ b/Patches/Common/android_art/0001-mmap_fix.patch @@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Ryo Hashimoto +Date: Wed, 14 Sep 2022 17:28:03 +0900 +Subject: [PATCH] DO NOT MERGE: Workaround for mmap error when building + +To fix errors which happen when building Android P on a workstation +running Linux kernel 5.18. + +Bug: 235181357 +Test: build +Change-Id: I92e5a7b84c8018d50c38ec386428e3191cd5600c +--- + runtime/mem_map.cc | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/runtime/mem_map.cc b/runtime/mem_map.cc +index b9d51c1125..f034a3db4f 100644 +--- a/runtime/mem_map.cc ++++ b/runtime/mem_map.cc +@@ -504,6 +504,11 @@ MemMap* MemMap::MapFileAtAddress(uint8_t* expected_ptr, + DCHECK(ContainedWithinExistingMap(expected_ptr, byte_count, error_msg)) + << ((error_msg != nullptr) ? *error_msg : std::string()); + flags |= MAP_FIXED; ++#if !defined(ART_TARGET) ++ } else if (expected_ptr) { ++#define MAP_FIXED_NOREPLACE 0x100000 ++ flags |= MAP_FIXED_NOREPLACE; ++#endif + } else { + CHECK_EQ(0, flags & MAP_FIXED); + // Don't bother checking for an overlapping region here. We'll diff --git a/Scripts/LineageOS-14.1/Patch.sh b/Scripts/LineageOS-14.1/Patch.sh index 71083c1c..0181c4dd 100644 --- a/Scripts/LineageOS-14.1/Patch.sh +++ b/Scripts/LineageOS-14.1/Patch.sh @@ -55,6 +55,10 @@ gpgVerifyDirectory "$DOS_PREBUILT_APPS""android_vendor_FDroid_PrebuiltApps/packa cp -r "$DOS_PREBUILT_APPS""android_vendor_FDroid_PrebuiltApps/." "$DOS_BUILD_BASE""vendor/fdroid_prebuilt/"; #Add the prebuilt apps cp -r "$DOS_PATCHES_COMMON""android_vendor_divested/." "$DOS_BUILD_BASE""vendor/divested/"; #Add our vendor files +if enterAndClear "art"; then +applyPatch "$DOS_PATCHES_COMMON/android_art/0001-mmap_fix.patch"; #Workaround for mmap error when building (AOSP) +fi; + if enterAndClear "bionic"; then applyPatch "$DOS_PATCHES_COMMON/android_bionic/0001-Wildcard_Hosts.patch"; #Support wildcards in cached hosts file (backport from 16.0+) (tdm) fi; diff --git a/Scripts/LineageOS-15.1/Patch.sh b/Scripts/LineageOS-15.1/Patch.sh index 41d579ed..4805cc57 100644 --- a/Scripts/LineageOS-15.1/Patch.sh +++ b/Scripts/LineageOS-15.1/Patch.sh @@ -55,6 +55,10 @@ gpgVerifyDirectory "$DOS_PREBUILT_APPS""android_vendor_FDroid_PrebuiltApps/packa cp -r "$DOS_PREBUILT_APPS""android_vendor_FDroid_PrebuiltApps/." "$DOS_BUILD_BASE""vendor/fdroid_prebuilt/"; #Add the prebuilt apps cp -r "$DOS_PATCHES_COMMON""android_vendor_divested/." "$DOS_BUILD_BASE""vendor/divested/"; #Add our vendor files +if enterAndClear "art"; then +applyPatch "$DOS_PATCHES_COMMON/android_art/0001-mmap_fix.patch"; #Workaround for mmap error when building (AOSP) +fi; + if enterAndClear "bionic"; then applyPatch "$DOS_PATCHES_COMMON/android_bionic/0001-Wildcard_Hosts.patch"; #Support wildcards in cached hosts file (backport from 16.0+) (tdm) #if [ "$DOS_GRAPHENE_MALLOC_BROKEN" = true ]; then applyPatch "$DOS_PATCHES/android_bionic/0001-HM-Use_HM.patch"; fi; #(GrapheneOS) diff --git a/Scripts/LineageOS-16.0/Patch.sh b/Scripts/LineageOS-16.0/Patch.sh index a3366ae8..cb99f97b 100644 --- a/Scripts/LineageOS-16.0/Patch.sh +++ b/Scripts/LineageOS-16.0/Patch.sh @@ -56,6 +56,7 @@ cp -r "$DOS_PREBUILT_APPS""android_vendor_FDroid_PrebuiltApps/." "$DOS_BUILD_BAS cp -r "$DOS_PATCHES_COMMON""android_vendor_divested/." "$DOS_BUILD_BASE""vendor/divested/"; #Add our vendor files if enterAndClear "art"; then +applyPatch "$DOS_PATCHES_COMMON/android_art/0001-mmap_fix.patch"; #Workaround for mmap error when building (AOSP) if [ "$DOS_GRAPHENE_CONSTIFY" = true ]; then applyPatch "$DOS_PATCHES/android_art/0001-constify_JNINativeMethod.patch"; fi; #Constify JNINativeMethod tables (GrapheneOS) fi; diff --git a/Scripts/LineageOS-17.1/Functions.sh b/Scripts/LineageOS-17.1/Functions.sh index ac884cf5..bcb70fa0 100644 --- a/Scripts/LineageOS-17.1/Functions.sh +++ b/Scripts/LineageOS-17.1/Functions.sh @@ -81,8 +81,9 @@ patchWorkspace() { gpgVerifyGitTag "$DOS_BUILD_BASE/external/hardened_malloc"; gpgVerifyGitHead "$DOS_BUILD_BASE/external/chromium-webview"; - #source build/envsetup.sh; + source build/envsetup.sh; #repopick -it ten-firewall; + repopick -it Q_asb_2022-11; sh "$DOS_SCRIPTS/Patch.sh"; sh "$DOS_SCRIPTS_COMMON/Enable_Verity.sh"; diff --git a/Scripts/init.sh b/Scripts/init.sh index d0c018ab..8b334997 100644 --- a/Scripts/init.sh +++ b/Scripts/init.sh @@ -167,7 +167,7 @@ export KBUILD_BUILD_HOST="dosbm"; export BUILD_USERNAME="emy"; export BUILD_HOSTNAME="dosbm"; -export ANDROID_JACK_VM_ARGS="-Xmx12288m -Xms512m -Dfile.encoding=UTF-8 -XX:+TieredCompilation"; +export ANDROID_JACK_VM_ARGS="-Xmx8192m -Xms512m -Dfile.encoding=UTF-8 -XX:+TieredCompilation"; export JACK_SERVER_VM_ARGUMENTS="${ANDROID_JACK_VM_ARGS}"; export EXPERIMENTAL_USE_JAVA8=true; export GRADLE_OPTS="-Xmx2048m";