Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build with latest AOSP #12

Closed
ao2 opened this issue Aug 7, 2024 · 7 comments
Closed

Build with latest AOSP #12

ao2 opened this issue Aug 7, 2024 · 7 comments

Comments

@ao2
Copy link
Contributor

ao2 commented Aug 7, 2024

Hi,

I am trying to build llvm (release_12.x as suggested by upstream mesa) with the latest AOSP tree, but I get these errors:

$ make libLLVM12
============================================
PLATFORM_VERSION_CODENAME=VanillaIceCream
PLATFORM_VERSION=VanillaIceCream
TARGET_PRODUCT=aosp_cf_x86_64_phone
TARGET_BUILD_VARIANT=eng
TARGET_ARCH=x86_64
TARGET_ARCH_VARIANT=silvermont
TARGET_2ND_ARCH=x86
TARGET_2ND_ARCH_VARIANT=silvermont
HOST_OS=linux
HOST_OS_EXTRA=Linux-6.10.3-amd64-x86_64-Debian-GNU/Linux-trixie/sid
HOST_CROSS_OS=windows
BUILD_ID=MAIN
OUT_DIR=out
============================================
[100% 95/95] analyzing Android.bp files and generating ninja file at out/soong/build.aosp_cf_x86_64_phone.ninja
FAILED: out/soong/build.aosp_cf_x86_64_phone.ninja
cd "$(dirname "out/host/linux-x86/bin/soong_build")" && BUILDER="$PWD/$(basename "out/host/linux-x86/bin/soong_build")" && cd / && env -i  "$BUILDER"     --top "$TOP"     --soong_out "out/soong"     --out "out"     --soong_variables out/soong/soong.aosp_cf_x86_64_phone.variables -o out/soong/build.aosp_cf_x86_64_phone.ninja --globListDir aosp_cf_x86_64_phone --globFile out/soong/globs-aosp_cf_x86_64_phone.ninja -l out/.module_paths/Android.bp.list --available_env out/soong/soong.environment.available --used_env out/soong/soong.environment.used.aosp_cf_x86_64_phone.build Android.bp
Warning: Module 'androidx.wear_wear' depends on non-existing optional_uses_libs 'wear-sdk'
Warning: Module 'androidx.wear.compose_compose-foundation' depends on non-existing optional_uses_libs 'wear-sdk'
error: external/llvm-project/llvm/lib/ExecutionEngine/MCJIT/Android.bp:1:1: module "libLLVM12MCJIT" variant "linux_glibc_x86_64_static": clang: property is deprecated, see Changes.md file
error: external/llvm-project/llvm/lib/ExecutionEngine/MCJIT/Android.bp:1:1: module "libLLVM12MCJIT" variant "linux_glibc_x86_64_static": clang_cflags: property is deprecated, see Changes.md file

Following Changes.md a change like this seems to fix that particular error:

diff --git a/llvm/Android.bp b/llvm/Android.bp
index d573484c30da..4869113ad00e 100644
--- a/llvm/Android.bp
+++ b/llvm/Android.bp
@@ -11,7 +11,6 @@ llvm_defaults {
     name: "llvm12-defaults-no-generated-headers",

     host_supported: true,
-    clang: true,

     cflags: [
         "-D_GNU_SOURCE",
@@ -28,14 +27,6 @@ llvm_defaults {
         "-Wwrite-strings",
         "-Werror",
         "-Dsprintf=sprintf",
-    ],
-
-    cppflags: [
-        "-Wno-sign-promo",
-        "-std=c++14",
-    ],
-
-    clang_cflags: [
         // Temporarily suppress the warnings http://b/37867503
         "-Wno-error=unused-lambda-capture",
         "-Wno-error=user-defined-warnings",
@@ -43,6 +34,11 @@ llvm_defaults {
         "-Wno-error=unreachable-code-loop-increment",
     ],

+    cppflags: [
+        "-Wno-sign-promo",
+        "-std=c++14",
+    ],
+
     header_libs: ["llvm12-headers-no-generated-headers"],

     target: {

However another error blocks the build:

internal error: New plugins are not supported; however ["soong-llvm12"] were found. Please reach out to the build team or use BUILD_BROKEN_PLUGIN_VALIDATION (see Changes.md for more info).
fatal errors encountered

Which can be worked around by adding this to BoardConfig.mk, as suggested in Changes.md:

BUILD_BROKEN_PLUGIN_VALIDATION := soong-llvm12

Are these changes and info worth integrating in the project?

@ao2
Copy link
Contributor Author

ao2 commented Aug 7, 2024

BTW even with the changes above, building libLLVM12 still does not complete for the cuttlefish device.

This is the device setup:

$ repo init -u https://android.googlesource.com/platform/manifest -b main
$ repo sync -c -j8 --optimize --no-tags
$ source build/envsetup.sh
$ lunch aosp_cf_x86_64_phone-trunk_staging-eng

which apparently also builds some windows artifacts, see HOST_CROSS_OS=windows below:

============================================
PLATFORM_VERSION_CODENAME=VanillaIceCream
PLATFORM_VERSION=VanillaIceCream
TARGET_PRODUCT=aosp_cf_x86_64_phone
TARGET_BUILD_VARIANT=eng
TARGET_ARCH=x86_64
TARGET_ARCH_VARIANT=silvermont
TARGET_2ND_ARCH=x86
TARGET_2ND_ARCH_VARIANT=silvermont
HOST_OS=linux
HOST_OS_EXTRA=Linux-6.10.3-amd64-x86_64-Debian-GNU/Linux-trixie/sid
HOST_CROSS_OS=windows
BUILD_ID=MAIN
OUT_DIR=out
============================================

And so I get this error:

[  7% 481/6798 54m41s remaining] //external/llvm-project/llvm/lib/LTO:libLLVM12LTO clang++ LTO.cpp [windows x86_64]
...
In file included from external/llvm-project/llvm/lib/LTO/LTO.cpp:13:
In file included from external/llvm-project/llvm/include/llvm/LTO/LTO.h:22:
external/llvm-project/llvm/include/llvm/LTO/Config.h:57:19: error: use of undeclared identifier 'LLVM_ENABLE_NEW_PASS_MANAGER'
   57 |   bool UseNewPM = LLVM_ENABLE_NEW_PASS_MANAGER;
      |                   ^

This seems to get fixed by applying the same changes as d922175 also to the #if defined(_WIN32) || defined(_WIN64) branch in llvm/include/llvm/Config/llvm-platform-config.h

However this is still not enough, and I get stuck on this error which I don't know how to fix:

[ 78% 5291/6722 13m39s remaining] //external/llvm-project/llvm/lib/Target/Mips:libLLVM12MipsCodeGen clang++ MipsSubtarget.cpp [windows x86_64]
...
In file included from external/llvm-project/llvm/lib/Target/Mips/MipsSubtarget.cpp:20:
external/llvm-project/llvm/lib/Target/Mips/MipsRegisterBankInfo.h:19:10: fatal error: 'MipsGenRegisterBank.inc' file not found
   19 | #include "MipsGenRegisterBank.inc"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~

@ao2
Copy link
Contributor Author

ao2 commented Aug 7, 2024

Ah, building the main target with make works, instead of make libLLVM12 which breaks, as the former is probably not building artifacts for the windows host.

So the issues about LLVM_ENABLE_NEW_PASS_MANAGER and MipsGenRegisterBank.inc are not urgent, but the comments in the first message still apply to be able to build with latest AOSP.

@ao2
Copy link
Contributor Author

ao2 commented Aug 14, 2024

@maurossi any comment on this? I can post a PR for the most basic changes to build with mainline AOSP.

@maurossi
Copy link
Owner

Thanks for your message, in this repo I do not process Pull Requests,
because I have the hack "DO NOT MERGE: android: translate soong build rules for libLLVM12" and I don't have a main branch

In building Android 14 had encountered the errors due to clang: property is deprecated clang_cflags: property is deprecated
but I could build with release_18.x branch

In order to be able to use updated libLLVM releases I am using commit [1] in mesa, which I preferred to not upstream because external/llvm-project is not guaranteed to be there, so I am taking it out-of-tree

If it is ok for you I will commit your proposed change in release_18.x to be able to build with Android 14,15 and keep it the next release_19.x

Could you please send me a .patch here in this thread, so that I will keep your name as author, test it and apply it in my branches?

NOTE: in release_19.x LLVM_VERSION_MAJOR was moved to cmake/Modules/LLVMVersion.cmake so [1] will not work anymore

[1] maurossi/mesa@1ca78ab
[2] llvm/llvm-project@81e2047

@ao2
Copy link
Contributor Author

ao2 commented Aug 14, 2024

Thanks @maurossi

About the llvm version, I am using https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30598 and I think it would make sense to upstream it, or some variation of it, since libLLVM* is needed anyway when building the llvmpipe gallium driver.

About the changes for building with upstream AOSP, please find attached the following patches for the branches I have tested:

I attached .txt files because for some reason github was not accepting the .patch extension

Ciao e grazie,
Antonio

@ao2
Copy link
Contributor Author

ao2 commented Aug 19, 2024

@maurossi I see that the changes have been integrated? We can probably close this issue.

Thanks a lot, Antonio

@maurossi
Copy link
Owner

maurossi commented Aug 20, 2024

Thanks to you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants