title: Can't get CUDA working on Tango, or: how do I mangle code for another ARM EABI?
body: <p>First of all, sorry for the probably misleading title, but I can't think of a better short description. </p>
  
  <p>For my Bachelor thesis I write a Tango app that requires CUDA for performance reasons. Unfortunately, I'm not a experienced Android dev, so 90% of all tutorials and guides regarding CUDA, JNI or Tango are not quite basic enough. </p>
  
  <p>From what I gather, NVCC always generates code for the armeabi-v7a-hard ABI. Therefore, from what I understand, my "normal" C++ code must be compiled for this ABI as well. Although I then can't debug my C++ code, I can live with that and also got that working after many hours of reading and trial and error. </p>
  
  <p>However, today I ran into this issue: <a href="https://stackoverflow.com/questions/35399927/how-can-i-use-armeabi-v7a-hard-in-my-tango-jni-app">https://stackoverflow.com/questions/35399927/how-can-i-use-armeabi-v7a-hard-in-my-tango-jni-app</a>. libtango_client_api.so is not compiled for armeabi-v7a-hard. I don't understand why my linking process doesn't fail, but it is what it is. </p>
  
  <p>From my point of view, I have several options now: </p>
  
  <ol>
  <li><p>Compile the entire project for armeabi-v7a. I believe this would be the best solution but requires that NVCC provides matching code. There seems to be the possibility to pass a <code>-mfloat-abi=hard</code>-switch to g++ but I can't find any documentation about what that does and causes and if it would work. </p></li>
  <li><p>In the mentioned StackOverflow-article they mentioned "mangling" the tango_client_api.h. I found two hints: <a href="http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0491i/CJAJBCCD.html" rel="nofollow noreferrer">1</a> and <a href="http://orangetide.com/ARM/IHI0043C_rtabi.pdf" rel="nofollow noreferrer">2, section 3.10, p. 12</a>, so I tried changing each function declaration in the header from (e.g.)</p>
  
  <pre><code>void TangoConfig_free(TangoConfig config)
  </code></pre>
  
  <p>to</p>
  
  <pre><code>void TangoConfig_free(TangoConfig config) __attribute__((pcs("aapcs-vpf"))) ;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>__hardfp void TangoConfig_free(TangoConfig config);
  </code></pre>
  
  <p>The former crashes with <code>Error:error: 'pcs' attribute ignored [-Werror=attributes]</code>, the latter doesn't compile at all (<code>Error:error: '__hardfp' does not name a type</code>). So, either I'm doing something wrong or this is an attribute that is ignored by g++ and only honored by armcc. </p></li>
  <li><p>Recompile libtango_client_api.so. I can't find any source code on Google's website though. </p></li>
  <li><p>Not use the <code>TangoService_getPoseAtTime</code>-function. That wouldn't be a big issue, but I am afraid that I might find additional broken functions or get weird behaviour because it's apparently only working accidentally. </p></li>
  <li><p>Use a Java Wrapper for CUDA. Can't imagine that's a good idea, though...</p></li>
  </ol>
  
  <p>Any help is much appreciated!</p>