www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Crosscompiling LDC's druntime for Android on Windows

reply Fry <fry131313 gmail.com> writes:
I'm trying to cross compile LDC's druntime to enable more debug 
print statements but I'm having trouble getting it built 
correctly for aarch64.

I'm following the azure pipeline's commands for how it's being 
built here:
https://github.com/ldc-developers/ldc/blob/master/.azure-pipelines/2-posix-build_cross_android.yml#L64

It includes threadasm.S that does have an aarch64 version, it 
just isn't being selected for some reason.

I get the following errors when trying to link:

```
ld: error: C:/Program Files/LDC 
1.28/bin/../lib-android_aarch64\libdruntime-ldc-debug.a(threadasm.S.o) is
incompatible with aarch64linux
ld: error: C:/Program Files/LDC 
1.28/bin/../lib-android_aarch64\libphobos2-ldc-debug.a(adler32.c.o) is
incompatible with aarch64linux
ld: error: C:/Program Files/LDC 
1.28/bin/../lib-android_aarch64\libphobos2-ldc-debug.a(compress.c.o) is
incompatible with aarch64linux
ld: error: C:/Program Files/LDC 
1.28/bin/../lib-android_aarch64\libphobos2-ldc-debug.a(crc32.c.o) 
is incompatible with aarch64linux
ld: error: C:/Program Files/LDC 
1.28/bin/../lib-android_aarch64\libphobos2-ldc-debug.a(deflate.c.o) is
incompatible with aarch64linux
ld: error: C:/Program Files/LDC 
1.28/bin/../lib-android_aarch64\libphobos2-ldc-debug.a(infback.c.o) is
incompatible with aarch64linux
ld: error: C:/Program Files/LDC 
1.28/bin/../lib-android_aarch64\libphobos2-ldc-debug.a(inflate.c.o) is
incompatible with aarch64linux
```

I manually set the cflags to include -march=armv8-a instead of v7 
which it was by default I guess from the android cmake toolchain 
file. I don't see what else needs to be set in order to change 
what binary is being built. For d code, I just set the mtriple 
but it is using the ndk's clang for the c files.
Feb 20 2022
parent kinke <noone nowhere.com> writes:
On Monday, 21 February 2022 at 00:24:54 UTC, Fry wrote:
 I'm following the azure pipeline's commands for how it's being 
 built here:
 https://github.com/ldc-developers/ldc/blob/master/.azure-pipelines/2-posix-build_cross_android.yml#L64
You can check the CI logs for the expanded cmdlines, e.g., from https://dev.azure.com/ldc-developers/ldc/_build/results?buildId=3281&view=logs&jobId=0dd91bf4-5270-5f6c-2450-fbc036057a53&j=0dd91bf4-5270-5f6c-2450-fbc036057a53&t=c2436f57-6a96-592e-95de-a459be0e607b: ldc-build-runtime --ninja -j 2 '--dFlags=-fvisibility=hidden;-mtriple=aarch64--linux-android;-gcc=/home/vsts/work/1/android-ndk-r21e/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-li ux-android21-clang' '--targetSystem=Android;Linux;UNIX' --ldcSrcDir=/home/vsts/work/1/s ANDROID_ABI=arm64-v8a ANDROID_NATIVE_API_LEVEL=21 ANDROID_STL=c++_static CMAKE_CROSSCOMPILING=True LDC_INSTALL_LLVM_RUNTIME_LIBS_OS=android LDC_INSTALL_LLVM_RUNTIME_LIBS_ARCH=aarch64-android CMAKE_TOOLCHAIN_FILE=/home/vsts/work/1/android-ndk-r21e/build/cmake/android.toolchain.cmake
Feb 21 2022