Hey Amit,<div><br></div><div>For the gettid issue, we were considering adding a #ifndef __ANDROID__ (all mentions of gettid in urcu) #endif type of solution (which seems to work for us at the moment), which also brings us to the last point: __ANDROID__ should be defined by default whenever you compile with the NDK's toolchain (we have not added this variable anywhere ourselves and so far, it's been very useful in all the projects). As for the patch itself, I personally have no clue if this would break any convention already in place for liburcu/LTTng in general; we have not been pushing any part of our progression so far as nothing as been tested, and some changes we made locally are extremely device/version specific (and would most likely break functionalities in other environments).</div>
<div><br></div><div>For the syscall.h issue, we avoided including directly "$<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13.333333969116211px;background-color:rgb(255,255,255)">SYSROOT/usr/include/sys", since some files in that folder are not safe to use directly (see errno.h and statfs.h for example). This seems to be the 'agreed-upon' logic used in the AOSP source tree; possible alternatives are setting up new Android #ifdef barriers in liburcu itself, or trying to push an empty, logically linked  syscall.h file (identical the above errno.h and statfs.h) to "</span>$<span style="font-size:13.333333969116211px;color:rgb(34,34,34);font-family:arial,sans-serif;background-color:rgb(255,255,255)">SYSROOT/usr/include" (which would probably not be accepted in the AOSP source).</span></div>
<div><font color="#222222" face="arial, sans-serif"><br></font></div><div><font color="#222222" face="arial, sans-serif">If your next plan after liburcu is porting the LTTng modules to Android, you'll most likely hit the missing kernel config options (syscall/hook related) in 3.0.x like we did; this will require some specific patching we have yet to complete. This work has been done in Torvalds's kernel (post-3.5 I believe, see his git for more info), but considering how different the current Android device kernels still are from the official ones, we might still have a lot to do.</font></div>
<div><font color="#222222" face="arial, sans-serif"><br></font></div><div><font color="#222222" face="arial, sans-serif">On another note, we peeked a little bit into porting UST to Android, but here again, replacing the SysV shmem implementation by Android's ashmem proved a lot more complicated than we had anticipated. Currently, we are only focusing on kernel tracing, so LTTng-modules + liburcu + LTTng-tools. So far, we successfully built the modules (with limited support), liburcu and the tools (also with limited support), but we have yet to start tracing.</font></div>
<div><font color="#222222" face="arial, sans-serif"><br></font></div><div><font color="#222222" face="arial, sans-serif">Feel free to ask away if you have any more questions, although other people on the mailing list might have better answers for LTTng-related questions.</font></div>
<div><font color="#222222" face="arial, sans-serif"><br></font></div><div><font color="#222222" face="arial, sans-serif">-PL</font></div><div><br><div class="gmail_quote">On Thu, Feb 21, 2013 at 12:08 PM, Amit Balboul <span dir="ltr"><<a href="mailto:amit.balboul@shinesec.com" target="_blank">amit.balboul@shinesec.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hey Pierre,<div>Thank you for the fast response.</div><div><br></div><div>I'm also using the pre-built NDK environment (r8d),</div>
<div>I continue to work on it, I'll let you know if I'm still having those errors.</div>
<div>About the "static inline pid_t gettid(void)" issue:</div><div>I cannot find any better solution than modifying the userspace-rcu sources to avoid static declaration.</div><div>I dont see the connection to building to Android, because unistd.h "extern"s gettid anyway, so it cannot be defined as static in any of the files (i just removed the "static" from the inline definition).</div>

<div><br></div><div>How do you want me to make this patch ?</div><div><br></div><div>About the syscall.h issue:</div><div>applying the SYSROOT/usr/include/sys folder AFTER the SYSROOT/usr/include in the CPPFLAGS solves the issue (looks like it is better than the link solution).</div>

<div><br></div><div>About the __ANDROID__ definition:</div><div>May I add this symbol to <a href="http://configure.ac" target="_blank">configure.ac</a> and use it in the sources, ?</div><span class="HOEnZb"><font color="#888888"><div>
<br></div><div><br>
</div><div>Amit.</div></font></span><div><div class="h5"><div><br></div><div><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 21, 2013 at 3:18 PM, Pierre-Luc St-Charles <span dir="ltr"><<a href="mailto:pierre-luc.st-charles@polymtl.ca" target="_blank">pierre-luc.st-charles@polymtl.ca</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Forwarded to mailing list:<div><br></div><div><div><span style="color:rgb(34,34,34);font-size:13.333333969116211px;font-family:arial,sans-serif">Hey Amil,</span><div style="color:rgb(34,34,34);font-size:13.333333969116211px;font-family:arial,sans-serif">


<br></div><div style="color:rgb(34,34,34);font-size:13.333333969116211px;font-family:arial,sans-serif">Sorry we kept you out of the loop, we've been struggling on some issues in the later projects; as for liburcu, we've come across the same problems you cited, except the last one:</div>


<div style="color:rgb(34,34,34);font-size:13.333333969116211px;font-family:arial,sans-serif"><div>    - syscall.h / lpthread / gettid : your solutions, or a #ifdef __ANDROID__ barrier, seems to work as a temp fix.</div>
<div>    - rand_r : after substituting for the regular (not-thread-safe) rand, we decide to go with our own implementation, but the one you found might actually be better</div><div>    - rpl_malloc : same fix here, but we also found that ac_cv_func_realloc_0_nonnull *might* also help in some cases (along with ac_cv_func_malloc_0_nonnull)</div>


<div><br></div></div><div style="color:rgb(34,34,34);font-size:13.333333969116211px;font-family:arial,sans-serif">As for the __sync_synchronize error, we haven't encountered those and we managed to successfully build the library.</div>


<div style="color:rgb(34,34,34);font-size:13.333333969116211px;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-size:13.333333969116211px;font-family:arial,sans-serif">
Possible differences:</div><div style="color:rgb(34,34,34);font-size:13.333333969116211px;font-family:arial,sans-serif">We opted for AOSP's own pre-built & packaged NDK toolchain, (which can be found here: <a href="http://developer.android.com/tools/sdk/ndk/index.html" style="color:rgb(17,85,204)" target="_blank">http://developer.android.com/tools/sdk/ndk/index.html</a>) and pointed the sysroot variable to its platforms/android-14/arch-arm/ directory (latest). By default, it doesn't include some module/kernel headers, but it should be enough for liburcu. We are currently considering adding the liburcu project itself (along with the others) directly in the android external modules, so that it may be compiled with exactly the SAME settings as the rest of the libraries/binaries/modules, using the same NDK (but for that, we'll need to drop the autoconf/automake stuff, and that's another story).</div>


<div style="color:rgb(34,34,34);font-size:13.333333969116211px;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-size:13.333333969116211px;font-family:arial,sans-serif">
The rest should be identical, we might have used some extra parameters here and there that might be based on our environment in the build process, but here they are anyway:</div><div style="color:rgb(34,34,34);font-size:13.333333969116211px;font-family:arial,sans-serif">


    in ./configure, add : --target=arm-linux-androideabi --prefix=$SYSROOT/usr</div><div style="color:rgb(34,34,34);font-size:13.333333969116211px;font-family:arial,sans-serif">    make sure you provide $SYSROOT/usr/lib instead of $SYSROOT/lib as the default library path</div>


<div style="color:rgb(34,34,34);font-size:13.333333969116211px;font-family:arial,sans-serif">    </div><div style="color:rgb(34,34,34);font-size:13.333333969116211px;font-family:arial,sans-serif">
Keep us informed if the problem still happens, we'll try to debug your issue further.</div><br></div><div class="gmail_quote"><div>On Thu, Feb 21, 2013 at 5:13 AM, Amit Balboul <span dir="ltr"><<a href="mailto:amit.balboul@shinesec.com" target="_blank">amit.balboul@shinesec.com</a>></span> wrote:<br>


</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">Hi all,<div><br></div><div>In continue to posts from <a href="http://www.mail-archive.com/lttng-dev@lists.lttng.org/msg02542.html" target="_blank">http://www.mail-archive.com/lttng-dev@lists.lttng.org/msg02542.html</a>,<br>



<div><br></div><div>I'm trying to build the LTTng kernel-tracer for Android on ARM:</div><div>(JB4.2.1 - kernel 3.0.31 - on Galaxy Nexus).<br></div><div>I'm having some trouble completing the process, didn't find any usable information so far, maybe u can help.<br>




</div><div><br></div><div>I want to build the: (I've managed in the past to build the modules for goldfish's 2.6.29 but this required patching the kernel).</div><div>(1) userspace-rcu</div><div>(2) modules</div><div>



(3) tools</div><div>I'm currently stuck in the first phase (building userspace-rcu).</div>
<div><br></div><div>My steps and the issues I've encountered are:</div><div>1. Clone the userspace-rcu git repository</div><div>2. Generate a sysroot for arm-linux-androideabi from google's NDK (using its "make-standalone-toolchain.sh" script with arm-linux-androideabi-4.4.3 toolchain).</div>




<div>3. Run ./bootstrap - creating <a href="http://config.h.in" target="_blank">config.h.in</a>, Makefile.in, configure, ...<br></div><div>4. Run ./configure with --host=arm-linux-androideabi and the relevant environment variables (CC, LD, CPPFLAGS, CFLAGS, LDFLAGS, LIB), pointing to the NDK ARM SYSROOT.</div>



<div>5. Run make</div><div><br></div><div>Some errors I encoutered and their fixes (workarounds), while trying as much as I can leave the sources untouched:</div><div>1. syscall.h not found. In some files, the <syscall.h> is included. In NDK SYSROOT the syscall.h lays in sys/</div>



<div>FIX: created a link: SYSROOT/include/syscall.h -> SYSROOT/include/sys/syscall.h</div><div>2. Android's libraries includes the pthread lib automatically, thus not having a stand-alone pthread library.</div>
<div>FIX: removed "-lpthread" from Makefile.am, tests/Makefile.am</div><div>3. static declaration of "gettid" follows non-static declaration (in SYSROOT/include/unistd.h, "gettid" is declared as "external")<br>



</div><div>For the mean time I commented this declaration... Maybe adding "#ifndef gettid" before the declaration of  "static gettid" in the sources will fix it ?</div><div>4. rand_r not declared - added a module that implements rand_r (as seen in <a href="https://github.com/xbmc/xbmc/tree/master/xbmc/android/bionic_supplement" target="_blank">https://github.com/xbmc/xbmc/tree/master/xbmc/android/bionic_supplement</a>)</div>



<div>5. undefined reference to rpl_malloc<br></div><div>FIX: setting ac_cv_func_malloc_0_nonnull=yes before launching ./configure.</div><div><br></div><div>now, after running ./configure and make, still not completed. I get many "undefined reference to __sync_syncronize" messages. the urcu/arch/generic.h defines the memory barriers functions as cmm_* but their implementation is not taken from urcu/arch/arm.h but from Line 46 in the same file (generic.h).</div>



<div>Can u help with this?</div><div>Am I missing something here ?</div><div><br></div><div>Also, how does the build system use the kernel 3.0.31 (or any other) sysroot ?<br></div><div><br></div><div>
Thank you</div></div><span><font color="#888888"><div><br></div><div>Amit.</div></font></span></div>
<br></div></div><div>_______________________________________________<br>
lttng-dev mailing list<br>
<a href="mailto:lttng-dev@lists.lttng.org" target="_blank">lttng-dev@lists.lttng.org</a><br>
<a href="http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev" target="_blank">http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev</a><br>
<br></div></blockquote></div><br></div>
</blockquote></div><br></div></div></div></div>
</blockquote></div><br></div>