Hi all
i'm trying to testing out your Snapdragon LLVM compiler,but i don't understand how to setup things
i tried adding NDK_TOOLCHAIN_VERSION=clang3.2 to my .mk file, but i suppose this isn't right. it can't see your optimizations (eg. -mcpu=krait2 ) i guess "clang3.2" value doesn't point to Snapdragon LLVM.can you help me?
If you are using the Linux versions, please make sure that the Snapdragon LLVM compiler is in your PATH by adding the install dir as below (in sh or bash)
export PATH=$INSTALL_DIR/bin:$PATH
where INSTALL_DIR is the directory where you untarred the Linux release.
If you are using windows, please make sure <install-dir>/Snapdragon LLVM for Android 3.2.01/bin is added to your PATH variable.
After either of these setup, please invoke clang from you command shell as
clang --version
and you should see output as
Target: arm-unknown-linux-androideabi
Thread model: posix
Snapdragon LLVM Compiler for Android 3.2.01
If you get the above output, you are correctly setup to use the Snapdragon LLVM version 3.2.01
Hope this helps. If you have installed the Snapdragon LLVM compiler inside an existing NDK toolchain at the appropriate level, you may be able to set NDK_TOOLCHAIN_VERSION to point to the subdirectory where you installed the Snapdragon version and may be able to build with your application. Please let us know if you have any further questions
Thanks for your help
i'm on Windows,already added Snapdragon LLVM for Android 3.2.01/bin to my PATH variable, and output (clang --version) is right
i also tried copying Snapdragon LLVM for Android 3.2.01 directory contents inside <my ndk folder>/toolchains/llvm-3.2/prebuilt/windows-x86_64 and tried to build using NDK_TOOLCHAIN_VERSION=clang3.2, but it still can't see optimizations like "-mcpu=krait2" (saying krait2 is a bad value) i guess i'm still not using Snapdragon LLVM
Yes, looks like the Snapdragon LLVM compiler is not taking effect. It is possible that the NDK_TOOLCHAIN_VERSION=clang3.2 is adding the Android NDK LLVM 3.2 compiler to that top of the path thus rendering the Snapdragon LLVM ineffective. Can you try removing/disabling the "NDK_TOOLCHAIN_VERSION=clang3.2" line to see if it fixes the issue?
Sorry for my late reply.
removing NDK_TOOLCHAIN_VERSION just tells ndk to use default compiler (gcc 4.6)
anyway, as i was able to compile my code with normal clang3.2 before moving Snapdragon LLVM directory contents inside llvm clang3.2,overwriting everything, i think i finally engaged yours compiler because now it doesn't complain about bad value optimizations (eg mcpu=krait2) but unfortunately i can't fully compile because of a wrong assertion (Assertion failed),i just wanted to test so it doesn't matter if i cannot compile right now, knowing if i'm finally using it would be cool
Seems like i'm still not using it , or maybe things are setted wrong again..this is what i tried :
as far as i understand, NDK can see and discover a new toolchain folder inside its "toolchains" directory by checking two files (inside our compiler's subdirectory) : setup.mk and config.mk. i used original clang3.2's files (both setup and config) so i copy/pasted them into my Snapdragon LLVM folder. editing setup.mk we can also choose a new/original NDK_TOOLCHAIN_VERSION value for Snapdragon LLVM (so that NDK can finally see it). unfortunately this doesn't seem to work either, can you maybe create/provide these setup.mk and config.mk files for making things more easy?
I will work on providing you a setup.mk and config.mk that would enable you to use the Snapdragon compiler with the Android NDK r8e release, along with instructions.
Thanks
--Raja
Can you let us know which platform Snapdragon LLVM you are using (Windows or Linux) so that we can provide the appropriate setup.mk and config.mk?
I'm using Windows
Thanks for all of your help Raja
Below are the instructions for using the Snapdragon LLVM compiler with Android NDK r8e. I will email you the attachments as well as a copy of the instructions below directly.
Here are the steps needed to use Snapdragon LLVM with Android NDK on Windows:
1. We assume that the user already has Android NDK version r8e for 32 bit Windows installed from the following link and has the required Cygwin setup as required by the Android NDK instructions
http://dl.google.com/android/ndk/android-ndk-r8e-windows-x86.zip
2. Extract the attached zipped archive “arm-linux-androideabi-snapdragonclang3.2.01” under <NDK_ROOT>/toolchains/
Note: After extracting you should have the following directory structure:
<NDK_ROOT>/toolchains/arm-linux-androideabi-snapdragonclang3.2.01/
3. Invoke your compilation line as follows:
NDK_TOOLCHAIN_VERSION=snapdragonclang3.2.01 SNAPDRAGON_LLVM_PATH=<path_to_llvm_root> ndk-build –C <some_project>
Where <path_to_llvm_root> points to the top of the Snapdragon LLVM compiler install and should have the "bin" directory underneath it.
Hi Raja, i did everything you said in your post, but seems like NDK still complains. this is what i got :
"Android NDK : ERROR: D:/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/Android.mk: gnustl_static: LOCAL_SRC_FILES points to a missing file
Android NDK : Check that D:/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/Files/SnapdragonLLVM/libs/armeabi-v7a/libgnustl_static.a exists or that its path is correct ".
(as you can see "D:/android-ndk-r8e" is my NDK folder, and "D:\Program Files\SnapdragonLLVM" is my Snapdragon LLVM compiler root directory)
Note: I think this is important ,actually i'm using Eclipse to build my projects, so i only used "NDK_TOOLCHAIN_VERSION=snapdragonclang3.2.01 SNAPDRAGON_LLVM_PATH=D:\Program Files\SnapdragonLLVM" in my Application.mk without "ndk-build –C <some_project>" command, to invoke compilation. am i doing anything wrong?
Thanks for trying our fix Jumper. We tested our change against the examples that came with Android NDK and they worked fine. Looks like there are further parameterization in Android NDK build system based on toolchain that we are missing. I will look into this and get back by Monday
Thanks to you for not giving up on my problem
Looks like the build system for your software is overriding some key makefile variables. Please make the following changes to setup.mk that I sent you.
Prepend the following lines with "override" in setup.mk
TOOLCHAIN_VERSION := 4.7
TOOLCHAIN_NAME := arm-linux-androideabi-$(TOOLCHAIN_VERSION)
TOOLCHAIN_ROOT := $(NDK_ROOT)/toolchains/$(TOOLCHAIN_NAME)
TOOLCHAIN_PREBUILT_ROOT := $(call host-prebuilt-tag,$(TOOLCHAIN_ROOT))
TOOLCHAIN_PREFIX := $(TOOLCHAIN_PREBUILT_ROOT)/bin/arm-linux-androideabi-
SNAPDRAGON_CLANG_ROOT := $(NDK_ROOT)/toolchains/arm-linux-androideabi-$(NDK_TOOLCHAIN_VERSION)
TARGET_CC := $(SNAPDRAGON_CLANG_ROOT)/snapdragon-clang
TARGET_CXX := $(SNAPDRAGON_CLANG_ROOT)/snapdragon-clang++
These should now look like
override TOOLCHAIN_NAME := arm-linux-androideabi-$(TOOLCHAIN_VERSION)
override TOOLCHAIN_ROOT := $(NDK_ROOT)/toolchains/$(TOOLCHAIN_NAME)
override TOOLCHAIN_PREBUILT_ROOT := $(call host-prebuilt-tag,$(TOOLCHAIN_ROOT))
override TOOLCHAIN_PREFIX := $(TOOLCHAIN_PREBUILT_ROOT)/bin/arm-linux-androideabi-
override SNAPDRAGON_CLANG_ROOT := $(NDK_ROOT)/toolchains/arm-linux-androideabi-$(NDK_TOOLCHAIN_VERSION)
override TARGET_CC := $(SNAPDRAGON_CLANG_ROOT)/snapdragon-clang
override TARGET_CXX := $(SNAPDRAGON_CLANG_ROOT)/snapdragon-clang++
This will make sure that any of these variables coming in from environment is overriden by their definition in setup.mk. Hope this helps
unfortunately same error as before.why does it keep searching for D:/android-ndk-r8e/sources/cxx-stl/gnu-libstdc++/Files/<Snapdragon LLVM root>/libs/armeabi-v7a/libgnustl_static.a ?
To help further with your issue, we would need access to your build system/make files. Without gaining access to your project build/make files, it is not possible to determine if there are other makefiles involved in setting up the environment or why our setup.mk and config.mk changes are not taking effect. As I mentioned, we were able to successfully build the example projects that are distributed with the Android NDK. Can you kindly look at your makefiles to see if any of the variables set by the Snapdragon clang setup.mk and config.mk files are being overridden?
If you are using Snapdragon LLVM Compiler 3.2.5 with the Android NDK and if you are getting the following linker error:
clang++: error: unable to execute command: No such file or directory
clang++: error: linker (via gcc) command failed due to signal (use -v to see invocation)
Then in the current shell manually set path to <android_ndk_root>/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86_64/bin.