Forums - Snapdragon LLVM for NDK r8e

17 posts / 0 new
Last post
Snapdragon LLVM for NDK r8e
jumper
Join Date: 25 May 13
Posts: 8
Posted: Sun, 2013-06-16 13:39

 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?

  • Up0
  • Down0
Raja Moderator
Join Date: 17 Apr 13
Posts: 42
Posted: Sun, 2013-06-16 22:04

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

  • Up0
  • Down0
jumper
Join Date: 25 May 13
Posts: 8
Posted: Mon, 2013-06-17 10:13

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

  • Up0
  • Down0
Raja Moderator
Join Date: 17 Apr 13
Posts: 42
Posted: Mon, 2013-06-17 11:13

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?

  • Up0
  • Down0
jumper
Join Date: 25 May 13
Posts: 8
Posted: Fri, 2013-06-21 01:03

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

  • Up0
  • Down0
jumper
Join Date: 25 May 13
Posts: 8
Posted: Fri, 2013-06-21 12:10

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?

  • Up0
  • Down0
Raja Moderator
Join Date: 17 Apr 13
Posts: 42
Posted: Fri, 2013-06-21 14:27

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

  • Up0
  • Down0
Raja Moderator
Join Date: 17 Apr 13
Posts: 42
Posted: Fri, 2013-06-21 15:32

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?

 

  • Up0
  • Down0
jumper
Join Date: 25 May 13
Posts: 8
Posted: Sat, 2013-06-22 01:01

I'm using Windows

Thanks for all of your help Raja

  • Up0
  • Down0
Raja Moderator
Join Date: 17 Apr 13
Posts: 42
Posted: Sat, 2013-06-29 07:42

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.

  • Up0
  • Down0
jumper
Join Date: 25 May 13
Posts: 8
Posted: Sat, 2013-06-29 19:15

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?

  • Up0
  • Down0
Raja Moderator
Join Date: 17 Apr 13
Posts: 42
Posted: Sat, 2013-06-29 19:40

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

  • Up0
  • Down0
jumper
Join Date: 25 May 13
Posts: 8
Posted: Sun, 2013-06-30 16:16

Thanks to you for not giving up on my problem

  • Up0
  • Down0
Raja Moderator
Join Date: 17 Apr 13
Posts: 42
Posted: Tue, 2013-07-02 16:40

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_VERSION := 4.7 
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

 

 

  • Up0
  • Down0
jumper
Join Date: 25 May 13
Posts: 8
Posted: Sat, 2013-07-06 02:04

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 ?

  • Up0
  • Down0
Raja Moderator
Join Date: 17 Apr 13
Posts: 42
Posted: Mon, 2013-07-08 16:51

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?

  • Up0
  • Down0
Mandeep
Join Date: 19 Jun 13
Posts: 6
Posted: Wed, 2013-08-07 15:14

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.

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.