botan icon indicating copy to clipboard operation
botan copied to clipboard

Unable to build Botan for android arm32

Open MisterPascal opened this issue 4 years ago • 9 comments

I'm able to build the libs for android x86 with:

python3 ./configure.py --os=android --cc=clang --cpu=x86 --link-method=copy sudo ANDROID_SDK_VER=23 ANDROID_ARCH=i686 src/scripts/docker-android.sh

As I unterstand I need to use "i686" as the script builds the commands to get the "i686-linux-android23-clang++" file.

I also dont have any problems to build the libs for aarch64. Works without any problem by replacing the i686.

But if I want to use the "armv7a-linux-androideabi23-clang++" I tried to configure with the following --cpu tags: -> armv7a: Unknown or unidentifiable processor "armv7a" -> arm32: Configure works fine but the make has the error: make: arm32-linux-android23-clang++: Command not found

So maybe the filenames or patterns are incorrect? I can't find any information about the 32bit cpu architecture in the docs.

MisterPascal avatar Dec 10 '20 23:12 MisterPascal

Building through Docker makes an implicit assumption that whatever Android calls the architecture is also a name we understand. Which is mostly but not entirely true...

Can you try this patch?

diff --git a/src/build-data/arch/arm32.txt b/src/build-data/arch/arm32.txt
index d2fe782b3..32b78f85e 100644
--- a/src/build-data/arch/arm32.txt
+++ b/src/build-data/arch/arm32.txt
@@ -10,6 +10,7 @@ evbarm # For NetBSD
 
 armv7
 armv7l
+arvm7a
 armv7-a
 
 armv8l # For AlpineLinux

Then ANDROID_ARCH=armv7a should work.

Sorry about all the hassles here I think the Docker build path is not really well tested at this point.

randombit avatar Dec 10 '20 23:12 randombit

Hei thank you! Unfortunately this patch does not quite work. With the added armv7a I got the message: armv7a-linux-android23-clang++: Command not found

I think this is because the needed file is: armv7a-linux-androideabi23-clang. All other architectures have a pattern like: ARCH-HOST_OS-ANDROID_VERSION-COMPILER. But armv7a uses anrdoideabi instead of just android and the file can't be found.

Hope this helps to find a solution.

MisterPascal avatar Dec 11 '20 11:12 MisterPascal

I think if you set ANDROID_TOOLCHAIN_SUF=eabi when invoking the script everything works. Kind of janky though considering there are practically only 4 Android target architectures.

randombit avatar Dec 11 '20 13:12 randombit

Then the compiler file is found but it tries to use the --ar-command=armv7a-linux-androideabi-ar wich results in

armv7a-linux-androideabi-ar: Command not found

MisterPascal avatar Dec 12 '20 19:12 MisterPascal

I finally could build the arm32 version by editing the Dockerfiele.android and set --ar-command=arm-linux-android${ANDROID_TOOLCHAIN_SUF}-ar but this will maybe not work with other android versions, not sure...

MisterPascal avatar Dec 12 '20 20:12 MisterPascal

Botan 2.18.1

./configure.py --enable-static-library --disable-shared-library --os=android --cc=clang --cpu=armv7-a --cc-bin=armv7a-linux-androideabi16-clang++ --ar-command=arm-linux-androideabi-ar
make
armv7a-linux-androideabi16-clang++  -fstack-protector -pthread -std=c++11 -D_REENTRANT  -O3 -DBOTAN_IS_BEING_BUILT -Wall -Wextra -Wpedantic -Wshadow -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align -Wmissing-declarations -Wpointer-arith -Wcast-qual  -Ibuild/include -Ibuild/include/external -c src/lib/utils/parsing.cpp -o build/obj/lib/utils_parsing.o
src/lib/utils/os_utils.cpp:112:11: error: no member named 'getauxval' in the global namespace; did you mean 'get_auxval'?
   return ::getauxval(id);
          ^~~~~~~~~~~
          get_auxval

found BOTAN_TARGET_OS_HAS_GETAUXVAL has been defined in build/build.h.

@randombit typo: arvm7a -> armv7a

snowyu avatar Jul 27 '21 02:07 snowyu

@snowyu getauxval was added in Android API 18 which we assume by default. If you need an older version pass --without-os-feature=getauxval to configure.py. This only affects 32-bit ARM since all 64-bit Android systems are API 18+.

Thanks for pointing out the typo, will fix.

randombit avatar Jul 27 '21 15:07 randombit

@randombit great thanks. Why can't I cross compile a Windows DLL on Linux using Mingw?

snowyu avatar Jul 28 '21 01:07 snowyu

Why can't I cross compile a Windows DLL on Linux using Mingw?

I thought this worked? In any case, if it doesn't please open a new issue rather than commenting in old unrelated issues, very easy for me to miss this.

randombit avatar Jul 28 '21 13:07 randombit

Closing this as stale, please open a new issue if some problem remains unresolved.

randombit avatar Dec 30 '22 21:12 randombit