sonyxperiadev/bug_tracker

[Build Tools] flex is too old for newer distributions

onitake opened this issue · 6 comments

Platform: Debian buster
Device: kugo
Kernel version: 4.4
Android version: 8.0.0

Description
The build fails with the following error:

[  2% 1921/83098] Lex: checkpolicy <= external/selinux/checkpolicy/policy_scan.l
FAILED: out/host/linux-x86/obj/EXECUTABLES/checkpolicy_intermediates/policy_scan.c 
/bin/bash -c "prebuilts/misc/linux-x86/flex/flex-2.5.39 -oout/host/linux-x86/obj/EXECUTABLES/checkpolicy_intermediates/policy_scan.c external/selinux/checkpolicy/policy_scan.l"
flex-2.5.39: loadlocale.c:130: _nl_intern_locale_data: Assertion `cnt < (sizeof (_nl_value_type_LC_TIME) / sizeof (_nl_value_type_LC_TIME[0]))' failed.

How to reproduce
Simply follow the instructions on https://developer.sony.com/develop/open-devices/guides/aosp-build-instructions/build-aosp-oreo-8-0-kernel-4-4
During make in step 5, the build fails.

Solution 1
This problem is well-known and can be fixed by replacing the prebuilt flex tool with a newer version, as mentioned here: https://groups.google.com/forum/#!topic/android-building/0kzPnw3akxg

Solution 2
Set the locale to C before executing make:

LC_ALL=C make

Solution 3
Use the host system's flex tool instead of the prebuilt one.

please send a pr with the commit that updates master to the repo_update git

it has been fixed in master

It lools like a patch to repo_update wasn't necessary after all:
I found out that android-8.0.0_r30 doesn't compile for ARMv8(A) devices anyway because the bionic sources are too old. By checking out android-8.0.0_r33 instead, I was able to build successfully.

Can I recommend that https://developer.sony.com/develop/open-devices/guides/aosp-build-instructions/build-aosp-oreo-8-0-kernel-4-4#tutorial-step-4 is updated to suggest building r33 instead of r30? It seems like this will also support other devices better.

Thanks!

it is important to backport the patch from r33 to r30
please open a PR to fix the issue

lss4 commented

It seems the problem persists on Pie when building according to the official guide.

I'm using Manjaro Linux, and by default, I'm having the error in the OP and with the prebuilt flex, I still get the error even after applying LC_ALL=C.

Cherry-picking this from LineageOS (which updates flex to the one that had eliminated the issue) would allow the build to proceed properly.

Off-topic: During the build process, there were a handful of warnings which I'm not sure what could have caused them, but the build process completed successfully.

I had the same problem on my gentoo, you can rebuild it manually.
cd prebuilts/misc/linux-x86/flex
rm flex-2.5.39
tar zxf flex-2.5.39.tar.gz
cd flex-2.5.39
./configure
make
mv flex ../
cd ../
rm -rf flex-2.5.39
mv flex flex-2.5.39

Can you clarify which release you are trying to build exactly?
If it's r30, then the build instructions should definitely be updated to point to r33 IMHO.

Other than that, please send a PR against r30, as requested by @jerpelea .
Thanks!