Bug 440709

Summary: Broken Craft ARM cross compilation on Android Docker environment
Product: [Unmaintained] Craft Reporter: Javier O. Cordero Pérez (Cuperino) <javiercorderoperez>
Component: CoreAssignee: Hannah von Reth <vonreth>
Status: RESOLVED WORKSFORME    
Severity: normal CC: christoph, javiercorderoperez, kde-windows, nicolas.fella, vkrause
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Javier O. Cordero Pérez (Cuperino) 2021-08-07 20:11:58 UTC
SUMMARY
Attempts to cross compile ARM and ARM64 Android builds using the Android Docker environment, kdeorg/android-sdk, result in compilation failing with error:
> configure: error: Error! Cross compiling but no --with-cross-build option specified - please supply the path to an executable ICU's build root.

STEPS TO REPRODUCE
Follow steps at https://community.kde.org/Craft/Android

  These are:

1. Download KDE Android SDK
> docker pull kdeorg/android-sdk
2a. Setup Craft in the container with persistence. 
> docker run -ti --rm -v <your persistent craft path>:/home/user/CraftRoot kdeorg/android-sdk craft-bootstrap
2b. Select either ARM or ARM64 as target architecture.
3. Build any KDE project, kcoreaddons, kirigami, or ktrip. Do attempt to build, don't use the pretend flag `-p`. 
> docker run -ti --rm -v  <your persistent craft path>:/home/user/CraftRoot kdeorg/android-sdk craft ktrip

OBSERVED RESULT
Compilation fails while configuring ICU, the first of libraries to be built.
> configure: error: Error! Cross compiling but no --with-cross-build option specified - please supply the path to an executable ICU's build root

EXPECTED RESULT
A smooth Craft build, or a request to install required project dependencies.


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: KDE neon Testing Edition
KDE Plasma Version: 5.22.4
KDE Frameworks Version: 5.85.0
Qt Version: 5.15.13

ADDITIONAL INFORMATION
Kernel: Linux 5.11.0-25-lowlatency (64-bit)

While ICU attempts to compile, the following possibly related error is seen:

> *** Action: compile for libs/icu ***                      
> executing command: /home/user/CraftRoot/dev-utils/bin/python3 /opt/android-ndk/build/tools/make_standalone_toolchain.py --install-dir /home/user/CraftRoot/tmp/android-arm-toolchain --arch arm --api 21
> WARNING:__main__:make_standalone_toolchain.py is no longer necessary. The
> $NDK/toolchains/llvm/prebuilt/linux-x86_64/bin directory contains target-specific scripts that perform
> the same task. For example, instead of:
> 
>     $ python $NDK/build/tools/make_standalone_toolchain.py \
>         --arch arm --api 21 --install-dir toolchain
>     $ toolchain/bin/clang++ src.cpp
> 
> Instead use:
> 
>     $ $NDK/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang++ src.cpp
Comment 1 Nicolas Fella 2021-08-07 22:05:33 UTC
You can work around this by calling 'craft --set ignored=True icu'. It will also fail for some other libs which you can mark as ignored too.

we don't yet have a nice way to do that automatically unfortunately
Comment 2 Volker Krause 2021-08-08 10:10:45 UTC
Patches to address this for dependencies of Qt are in review: https://invent.kde.org/packaging/craft-blueprints-kde/-/merge_requests

Some dependencies of KArchive and Poppler and possibly others still need similar fixes/workarounds.
Comment 3 Javier O. Cordero Pérez (Cuperino) 2021-10-12 05:28:38 UTC
(In reply to Nicolas Fella from comment #1)
> You can work around this by calling 'craft --set ignored=True icu'. It will
> also fail for some other libs which you can mark as ignored too.
> 
> we don't yet have a nice way to do that automatically unfortunately

Thank you for the workaround. It worked and eventually I figured out how to make the build.

Speaking of finding a nicer way to do it automatic... Would it be possible to set this flag from a project's blueprint? As a condition when CraftCore.compiler.isAndroid I mean.
Comment 4 Volker Krause 2021-10-13 15:24:44 UTC
https://invent.kde.org/packaging/craft-blueprints-kde/-/merge_requests/212 did exactly that already I think.