question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[bug] Cross-compiling for armv8 but Clang uses --target=armv7-none-linux-androideabi22

See original GitHub issue

Hello,

I am trying to cross-compile a library to both Android armv7 and armv8 platforms. The first one builds correctly, but when compiling for arch armv8 I noticed clang calls -march=armv7-a and --target=armv7-none-linux-androideabi22 in its command line (see the full log below).

Here’s the profile I am using (Android NDK 23.0.7599858, api level 22)

include(default)
target_host=aarch64-linux-android
android_ndk=/Users/n-eq/Library/Android/sdk/ndk/23.0.7599858
api_level=22

[settings]
arch=armv8
build_type=Release
compiler=clang
compiler.libcxx=libc++
compiler.version=12
os=Android
os.api_level=$api_level
[build_requires]
[options]
[env]
PATH=[$android_ndk/toolchains/llvm/prebuilt/darwin-x86_64/bin]
CHOST=$target_host
AR=/Users/n-eq/Library/Android/sdk/ndk/23.0.7599858/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ar
AS=/Users/n-eq/Library/Android/sdk/ndk/23.0.7599858/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android-as
RANLIB=/Users/n-eq/Library/Android/sdk/ndk/23.0.7599858/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ranlib
CC=/Users/n-eq/Library/Android/sdk/ndk/23.0.7599858/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android22-clang
CXX=/Users/n-eq/Library/Android/sdk/ndk/23.0.7599858/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android22-clang++
LD=$target_host-ld
STRIP=/Users/n-eq/Library/Android/sdk/ndk/23.0.7599858/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-strip
CONAN_CMAKE_TOOLCHAIN_FILE=$android_ndk/build/cmake/android.toolchain.cmake

Environment Details (include every applicable attribute)

  • Operating System+version: MacOS Big Sur 11.4 (Darwin 20.5.0)
  • Compiler+version: Clang (aarch64-linux-android22) 12.0.5
  • Conan version: 1.36.0
  • Python version: 3.9.6

Steps to reproduce (Include if Applicable)

I am using the following command: $ conan create . koinbra/android_arm64-v8a -s build_type=Release -o shared=False -o log4c:shared=False --profile android_arm64-v8a -j /Users/n-eq/Dev/akl/log4c/__liv/pkg_info/pkg_info_3.00.09/arm64_Release_static.json -tf None

Logs (Executed commands with output) (Include/Attach if Applicable)

conan.log

Is there something I’m doing wrong? I appreciate your help.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
n-eqcommented, Sep 4, 2021

Hi @dmn-star, many thanks for the comments. I didn’t find the three lines you mention:

if(NOT ANDROID_ABI)
  set(ANDROID_ABI armeabi-v7a)
endif()

However, I solved the issue by adding ANDROID_ABI = "arm64-v8a" to CMake class’s definitions field before building.

0reactions
n-eqcommented, Sep 5, 2021

They are in android.toolchain.cmake.

Yes, but apparently they were removed in NDK version 23.0.7599858, which is the one I’m using.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cross-compilation using Clang
This document will guide you in choosing the right Clang options for cross-compiling your code to a different architecture. It assumes you already...
Read more >
not support armv7-a · Issue #811 · include-what-you-use ...
I wonder if it's possible to use the Clang API to do the resolution from cross-compiler name somehow. Thank you for sharing corrent...
Read more >
[llvm-dev] Cross compiling for ARMv7-m - Google Groups
Hi, I am trying to use LLVM/clang to build a binary for ARM Cortex M platforms. When I build my binary the linker...
Read more >
Cross-compiling ARM on Travis using clang and qemu
To select an ARM target on clang, one has to specify the following command line flags: clang++ -march=armv8-a -target aarch64-linux-gnueabi ... This will ......
Read more >
Cross compile clang for Android arm - Stack Overflow
The build folder is in the same directory with the llvm source code. I get the error: rm-linux-androideabi-g++: error: unrecognized command line option...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found