Currently we are building just Orbot in tor-browser-build and fetching the dependencies as we need them. We should at least build Tor and its dependencies on our own, integrating Android specific build logic into our projects we already have (like OpenSSL, Libevent etc.).
This is the parent ticket for that task.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related.
Learn more.
It seems that Android is moving to clang, and clang has more limited options for reproducibility. I think GCC support is still there, but deprecated. I found some specific issues on what is missing from clang here:
https://reproducible-builds.org/docs/build-path/
I justed looked through it, you could get rid of tor-android in TBB if you build libevent, openssl, lzma, zstd, and tor. The build configuration for each of those can be taken from https://github.com/guardianproject/tor-android, especially after this merge request, which should simplify things a bunch:
I verified that tor starts up correctly with the armv7 build on a device. The browser loads and displays pages. I have not verified reproducibility yet.
Trac: Keywords: TorBrowserTeam202001 deleted, TorBrowserTeam202001R added Cc: sisbell, hans@guardianproject.info, tbb-team to sysrqb, gk, sisbell, hans@guardianproject.info, tbb-team Status: assigned to needs_review
I verified that tor starts up correctly with the armv7 build on a device. The browser loads and displays pages. I have not verified reproducibility yet.
Some comments/questions:
in the builds of openssl, libevent, tor, you are setting ANDROID_NDK_HOME and adding $ANDROID_NDK_HOME to PATH. Shouldn't that be done in var/setup in projects/android-toolchain/config instead of in each project?
could you explain (for example in the commit message) why libevent needs to be updated from 2.1.8 to 2.1.11?
could you explain why the --disable-libevent-regress--disable-samples options are needed to build libevent (and whether it would be useful to use them on other platforms too)?
in the libevent build, you are adding CC=clang to the configure for all platforms. I think it should be added to the android builds only as it doesn't seem to be needed for other platforms.
it seems we could have a var/configure_opt for android in rbm.conf containing something like CC=clang --host=[% c("var/host") %] [% c("var/configure_opt_project") %], where var/configure_opt_project is defined in each project to define options specific to this project
I think the name var/host is a little confusing and could be renamed to var/configure_host to make it more clear where it's used
Trac: Keywords: TorBrowserTeam202001R deleted, TorBrowserTeam202001 added Status: needs_review to needs_revision
I've made progress to getting libraries running as shared libraries but have hit a blocker that I need help with
The problem occurs when I try to run tor browser. I get a missing symbol where libTor can't find a symbol from openssl
10744 10744 F linker : CANNOT LINK EXECUTABLE "/data/app/org.torproject.torbrowser-o2cGxqnhQbWOPhFKKcOFiA==/lib/arm/libTor.so": cannot locate symbol "SSL_CTX_set_security_level" referenced by "/data/app/org.torproject.torbrowser-o2cGxqnhQbWOPhFKKcOFiA==/lib/arm/libTor.so"...
Looking at the libraries, we see the function undefined in libTor. So I'm wondering what flag I need to set to make sure these are included. I'm building with clang.
$ readelf -Ws libTor.so | grep set_security 3819: 00000000 0 FUNC GLOBAL DEFAULT UND SSL_CTX_set_security_level@OPENSSL_1_1_0 (5)110559: 00000000 0 FUNC GLOBAL DEFAULT UND SSL_CTX_set_security_level
$ readelf -Ws libssl.so | grep set_security 537: 000328bc 12 FUNC GLOBAL DEFAULT 11 SSL_CTX_set_security_level@@OPENSSL_1_1_0 543: 000328d4 12 FUNC GLOBAL DEFAULT 11 SSL_CTX_set_security_callback@@OPENSSL_1_1_0 679: 0003288c 12 FUNC GLOBAL DEFAULT 11 SSL_set_security_callback@@OPENSSL_1_1_0 681: 00032874 12 FUNC GLOBAL DEFAULT 11 SSL_set_security_level@@OPENSSL_1_1_0 2743: 000328bc 12 FUNC GLOBAL DEFAULT 11 SSL_CTX_set_security_level 2749: 000328d4 12 FUNC GLOBAL DEFAULT 11 SSL_CTX_set_security_callback 2885: 0003288c 12 FUNC GLOBAL DEFAULT 11 SSL_set_security_callback 2887: 00032874 12 FUNC GLOBAL DEFAULT 11 SSL_set_security_level
I've made progress to getting libraries running as shared libraries but have hit a blocker that I need help with
The problem occurs when I try to run tor browser. I get a missing symbol where libTor can't find a symbol from openssl
{{{
10744 10744 F linker : CANNOT LINK EXECUTABLE "/data/app/org.torproject.torbrowser-o2cGxqnhQbWOPhFKKcOFiA==/lib/arm/libTor.so": cannot locate symbol "SSL_CTX_set_security_level" referenced by "/data/app/org.torproject.torbrowser-o2cGxqnhQbWOPhFKKcOFiA==/lib/arm/libTor.so"...
}}}]
Taking a guess, tor is probably using a version of openssl shipped with Android. I doubt apps look in their lib/ directory by default for libraries.
You can try setting LD_LIBRARY_PATH on the command line, for testing. If that works, then we should think about how we should solve this problem. There are a few options. One option is we modify TOPL:
Yes, I think you are right. Android only loads from /system/lib so I'll need to explicitly load openssl and the other shared libs. I'm not sure loading them from the android app will work, however, as tor is a spawned process. I'm looking into this now.
I've made progress to getting libraries running as shared libraries but have hit a blocker that I need help with
The problem occurs when I try to run tor browser. I get a missing symbol where libTor can't find a symbol from openssl
{{{
10744 10744 F linker : CANNOT LINK EXECUTABLE "/data/app/org.torproject.torbrowser-o2cGxqnhQbWOPhFKKcOFiA==/lib/arm/libTor.so": cannot locate symbol "SSL_CTX_set_security_level" referenced by "/data/app/org.torproject.torbrowser-o2cGxqnhQbWOPhFKKcOFiA==/lib/arm/libTor.so"...
}}}]
Taking a guess, tor is probably using a version of openssl shipped with Android. I doubt apps look in their lib/ directory by default for libraries.
You can try setting LD_LIBRARY_PATH on the command line, for testing. If that works, then we should think about how we should solve this problem. There are a few options. One option is we modify TOPL:
I think it makes sense to ship PTs as individual shared libraries, but I think that trying to use libssl.so will be painful. We've tried that in the past, and from that experience, committed to always statically linking those kinds of deps in. I guess it could be worth the pain if PTs also need libssl.so or other libs that are linked into libtor.so.
Also, I don't remember the details, but Android does add the app's lib dir to the loading path, and adds it before /system/lib. But that is probably only for libraries that are loaded from Java. "Native code" probably needs to handle that manually.
The following commits specify the info and NDK setup dependent projects need for configuration.
Bug 33216: Add Android Host and ABI Info to RBM.conf
Bug 33215: Android Toolchain: Add NDK bin path to system path
The above two issues address previous review comments to add ANDROID_NDK_HOME to setup in android-toolchain and another review comment to rename _var/host _to var/configure_host
Modify the core dependent libraries to build with Android
This last commit packages up everything within the Android library
Bug 32993: Package Tor With Tor Android Service Project
Other issues:
There was a suggestion to move some of the fields in configure_opt up to rbm. OpenSSL doesn't use the same configure_host value as other projects so this will require some more discussion if we want to move forward with this suggestion.
Information regarding libevent --disable-libevent-regress--disable-samples. I need to look back through my notes. I'll post in a follow up comment.
Shared Libraries. I was unable to get shared libraries working with LD_LIBRARY_PATH on my device. It also seems support for this can be different across OEMs. So I moved forward with static libraries.
One thought that recently struck me is that loading shared libraries works easily in Java space. The LD_LIBRARY_PATH stuff is automatically handled when loading using System.load(), or you can load using the full path using System.loadLibrary(). But that means running all bits that need that shared library via Android/Java methods, e.g. not as daemons. IMHO that's the right direction for the future anyway.
One thought that recently struck me is that loading shared libraries works easily in Java space. The LD_LIBRARY_PATH stuff is automatically handled when loading using System.load(), or you can load using the full path using System.loadLibrary(). But that means running all bits that need that shared library via Android/Java methods, e.g. not as daemons. IMHO that's the right direction for the future anyway.
Yes, I agree. After getting this initial version in, I think we should start looking at JNI, which will give us the option of loading the shared libraries through Java.
In the future, please provide one branch per ticket. If one ticket depends on another, then you can base a ticket's branch on top of another ticket's branch, but separating each ticket into its own branch makes reviews much easier.
I'm setting this ticket as 'assigned' and each child ticket can be worked individually.