Repository navigation
Description
Describe the bug
Cannot build Android 11 AOSP on nixos without source modification
To Reproduce
As android is huge to download, the following could take a few hours to process, and you will need a solid machine to build android.
Steps to reproduce the behavior:
- Start android fhs
- Setup Android repository
mkdir AOSP_11 && cd AOSP_11repo init -u https://android.googlesource.com/platform/manifest -b android-11.0.0_r17repo sync⚠️ This take a lot of time, you are about to download 100GB
- Setup build
source build/envsetup.shlunch aosp_taimen-userdebug
- Build it
make -j11⚠️ to complete the build this require a good CPU with 16GB Ram and some space disk
- After some build process if fail for linking issue to shared library.
Expected behavior
Build success
Additional context
Since I am on nix I use this fhs to build android.
But it no longer work on AOSP 11.
This is the error that happen:
prebuilts/clang/host/linux-x86/clang-3289846/bin/clang.real:
error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
This is caused by the android build system creating his own environment without LD_LIBRARY_PATH.
I didn't find any nix tips to have it working without modifying source, so I post this issue to indicate the fhs is no longer suffisant.
Here is the dirty workaround that seems to work. I do not have encounter any issues yet.
In following repo: TOP/build/soong
diff --git a/ui/build/sandbox_linux.go b/ui/build/sandbox_linux.go
index 2de772b00..85be64946 100644
--- a/ui/build/sandbox_linux.go
+++ b/ui/build/sandbox_linux.go
@@ -175,5 +175,6 @@ func (c *Cmd) wrapSandbox() {
if _, hasUser := env.Get("USER"); hasUser {
env.Set("USER", "nobody")
}
+ env.Set("LD_LIBRARY_PATH", "/usr/lib:/usr/lib32")
c.Env = []string(env)
}
Notify maintainers
I have no idea who did the original FHS nor who trigger on this
Metadata
- system: `"x86_64-linux"`
- host os: `Linux 5.4.44, NixOS, 20.03.2102.e2bb73ce5f7 (Markhor)`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.3.5`
- channels(root): `"nixos-20.03.2102.e2bb73ce5f7, unstable-20.09pre228622.029a5de0839"`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
Maintainer information:
# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
Activity
danielfullmer commentedon Nov 13, 2020
The Android build system (as of Android 11) now ignores certain environment variables by default, including
LD_LIBRARY_PATH. You can runexport ALLOW_NINJA_ENV=truebefore building to disable this behavior.Also, in case you aren't aware of it, Robotnix can also be used to build AOSP using Nix.
wescande commentedon Nov 13, 2020
I wasn't aware of this ninja option. Thanks ! It way cleaner than what i did.
I will put
export ALLOW_NINJA_ENV=trueit my android FHS, but it could be something nice to add to the example fhs on nixos Wiki. Does someone know who trigger to do so ?I am aware of the Robotnix existence since i start searching for this issue, but i do not know how it work with local source tree, as I need to do heavy modification in multiple android repo(test it, build some debug code...).
Is there any possibility with Robotnix to do something like this
nix-build ./default.nix --build_tree [PATH]?danielfullmer commentedon Nov 13, 2020
Yeah, you're right that robotnix wouldn't help as much if you intend to do AOSP development (edit / test / debug cycles). It's most useful when you have something that works and want to allow end-users to easily build it using nix.
wescande commentedon Dec 21, 2020
I didn't see the commit that change it, but wiki has been update.
Thank you mysterious people 👍
He/She also add some other lines needed in new android build, that's nice !
I close this issue
bumps nixpkgs to 23.11 and android-nixpkgs, remove nixpkgsUnstable
bumps nixpkgs to 23.11 and android-nixpkgs, remove nixpkgsUnstable