Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: unknown target CPU 'armv7-a' #1

Closed
shaders opened this issue Apr 6, 2013 · 13 comments
Closed

error: unknown target CPU 'armv7-a' #1

shaders opened this issue Apr 6, 2013 · 13 comments

Comments

@shaders
Copy link

shaders commented Apr 6, 2013

Hi,

I have a very simple script:
export ANDROID_NDK=/android-ndk-r8e
cmake -DCMAKE_TOOLCHAIN_FILE=
/android-cmake/android.toolchain.cmake

everything works fine at this point but trying to run make I always receive the same error:
error: unknown target CPU 'armv7-a'

I have tried different toolchains using ANDROID_TOOLCHAIN_NAME, but the error is always the same.

Any ideas what could be wrong?

Thanks!

@shaders
Copy link
Author

shaders commented Apr 6, 2013

I have clang selected by default:

/Users/User/android-ndk-r8e/toolchains/llvm-3.1/prebuilt/darwin-x86/bin/clang -fexceptions -Wno-psabi --sysroot=/Users/User/android-ndk-r8e/platforms/android-8/arch-arm -fpic -funwind-tables -finline-limit=64 -fsigned-char -no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fdata-sections -ffunction-sections -Wa,--noexecstack -isystem /Users/User/android-ndk-r8e/platforms/android-8/arch-arm/usr/include -isystem /Users/User/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/4.6/include -isystem /Users/User/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include -o CMakeFiles/libzip.dir/lib/mkstemp.c.o -c mkstemp.c

@taka-no-me
Copy link
Owner

@shaders, thanks for the report!

At the moment toolchain requires CMAKE_BUILD_TYPE to be set to Release or Debug for the clang compiler.

@dreamzor
Copy link

dreamzor commented Mar 4, 2014

Hi! I've got the same error with clang 3.3 and your toolchain :(

@chromaticbum
Copy link

The compiler needs a triplet, and there is code in there to set the triplet to get the proper CPU. Take a look at android.toolchain.cmake and look for the section where it talks about the ANDROID_ABI variable. You need to set this when you are running cmake. For example: "cmake -DCMAKE_TOOLCHAIN_FILE=$ANDTOOLCHAIN -DANDROID_TOOLCHAIN_NAME=$ANDROID_TOOLCHAIN_NAME -DANDROID_ABI=armeabi-v7a .." Here is a link: https://github.com/taka-no-me/android-cmake/blob/5db45cfb87fec180b74963d3680dd60d4d8d8c3a/android.toolchain.cmake#l74-91

@chromaticbum
Copy link

Or as taka suggested, add -DCMAKE_BUILD_TYPE=Release|Debug and this will set the triplet as well

@dreamzor
Copy link

dreamzor commented Mar 5, 2014

Thanks, but I already tried that... here's the complete list of relevant cmake options:

-DANDROID_ABI="armeabi-v7a with NEON"
-DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-clang3.3
-DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_DIR}/android.toolchain.cmake
-DCMAKE_BUILD_TYPE=Release 

I ended up compiling a standalone toolchain which worked (yay!) with this cmake toolchain (using make_standalone_toolchain.sh at android-ndk/build/tools, but it certainly would be so much better if 'out of the box' solution would work.

That's the clang instance being called:
android-ndk/toolchains/llvm-3.3/prebuilt/darwin-x86/bin/clang
Maybe it's not suitable for armeabi-v7a with NEON somehow?

@chromaticbum
Copy link

This worked for me:
export ANDTOOLCHAIN=/Users/hollin/ndk.workspace/android-cmake/android.toolchain.cmake
export ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-clang3.3
export ANDROID_NDK=~/Lib/Android/ndk # this is r9c

cmake -DCMAKE_TOOLCHAIN_FILE=$ANDTOOLCHAIN -DANDROID_TOOLCHAIN_NAME=$ANDROID_TOOLCHAIN_NAME -DANDROID_ABI="armeabi-v7a with NEON" -DCMAKE_BUILD_TYPE=Release ..

@dreamzor
Copy link

dreamzor commented Mar 5, 2014

Thanks! That's weird, it looks exactly the same..

Do you have the same clang instance being called? (make VERBOSE=1 will tell) Because when I'm trying to manually compile a int main() { return 0; } program with -march=armv7-a flag using that clang executable, it shows me the same 'unknown target cpu' error.

@chromaticbum
Copy link

Make sure to specify -target armv7-none-linux-androideabi
If you are manually invoking clang.

@dreamzor
Copy link

dreamzor commented Mar 6, 2014

Calling clang from this folder
android-ndk/toolchains/llvm-3.3/prebuilt/darwin-x86/bin
With these parameters
./clang++ -target armv7-none-linux-androideabi -march=armv7-a code.cpp
I'm getting this...
FATAL:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../libexec/as/x86_64/as: I don't understand 'm' flag! clang: error: assembler command failed with exit code 1 (use -v to see invocation)

I feel that something is really wrong..

@chromaticbum
Copy link

This is getting a bit off topic. But you would learn a lot by running ndk-build V=1 on one of the sample projects. You will see all of the options that need to be passed in. Of particular importance are compiling with -fPIC and using the proper gcc toolchain. Pretty much just look at the output of ndk-build and see what it's doing then adapt to your files.

@dreamzor
Copy link

dreamzor commented Mar 6, 2014

Ok, I'll take a look at that, thanks a lot!

@taka-no-me
Copy link
Owner

This problem should be gone with the latest update.

ewmailing pushed a commit to ewmailing/android-cmake that referenced this issue Mar 2, 2016
Add support for libc++, the LLVM C++ Standard Library.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants