title: how to compile and link rust code into an android apk packed application
body: <p>I'm trying to add Rust code to an android NDK sample (native-activity);
  Whenever I link Rust code (compiled as a .a) into the .so , it fails to run.</p>
  
  <p>I went on information from here to get an android aware rust compiler and 'standalone toolchain'
  <a href="https://github.com/mozilla/rust/wiki/Doc-building-for-android" rel="noreferrer">https://github.com/mozilla/rust/wiki/Doc-building-for-android</a></p>
  
  <p>Someone was suggesting on the Rust IRC channel that I need to mention 'thumb' somewhere;
  is there an option to pass to rustc, or did I have to build it all differently in the first place?</p>
  
  <p>I've certainly been able to call rust &amp; c from eachother on desktop builds.</p>
  
  <p>Is there a sample where someone has rust code working in a .apk;   it would have to be simple.. its very hard to decipher makefiles for complex projects. (I think it would be very hard to figure this out from reading Servo source)</p>
  
  <p>I've verified this process generates a useable package <em>without</em> adding rust; it only fails to run if I  <em>link</em> unstripped rust code - even if it isn't reached (even though the linking doesn't tell me anything is wrong). 
  If i remove the call to 'rusty_android()', it works. If i move the call to rusty_android to a point that isn't reached, it still doesn't work. I can verify with 'nm' that 'rusty_android' is in the .so ... unmangled.</p>
  
  <p>This is my current build process: its taken from the android native-activity sample; i've added a  rust source file with a single extern functin returning a value, and tried to debug print that from the samples' C main</p>
  
  <pre><code>ANDROID_CXX  = /opt/ndk_standalone/bin/arm-linux-androideabi-gcc
  
  android:
      $(ANDROID_CXX) -I/home/ME/android-ndk-r9b/sources/android/native_app_glue -c jni/main.c  -o obj/local/armeabi/objs/native-activity/main.o
      rustc --target=arm-linux-androideabi hello_android.rs -C android-cross-path=/opt/ndk_standalone --crate-type=staticlib -o rusty_android.a
      $(ANDROID_CXX) -shared -o libs/armeabi/libnative-activity.so obj/local/armeabi/objs/native-activity/main.o obj/local/armeabi/libandroid_native_app_glue.a another.o rusty_android.a -llog -landroid -lEGL -lGLESv1_CM
     ant debug
     adb install -r bin/NativeActivity-debug.apk
     adb shell am start -n com.example.native_activity/android.app.NativeActivity
  
  
  
  
  hello_android.rs:-
  
  use std::libc;
  #[no_mangle]
  pub extern fn   rusty_android()-&gt;libc::c_int {
  99 as libc::c_int
  }
  
  in main.c, inserted in android_main(..):-
      { extern int rusty_android(); LOGI("****rust says %d****", rusty_android()); }
  </code></pre>
  
  <p>The suspicion that something to specificy 'thumb' might be needed arose from comparing LLVM IR and asm sources, but it seems strange that it would be an additional option required over and above 'arm-linux-androideabi'</p>