When cross-compiling, for example for Android, ./configure will detect lzma and zstd setups from the build system, when it should be ignoring them. It should only look in the NDK and --prefix values.
$ sudo apt install liblzma-dev$ export host_triplet=armv7a-linux-androideabi$ export EXTERNAL_ROOT=`pwd`/external$ export platform=21$ export CC=${host_triplet}${platform}-clang$ export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH$ ./configure --host="$host_triplet" --enable-android --enable-static-libevent --with-libevent-dir=$EXTERNAL_ROOT --enable-static-openssl --with-openssl-dir=$EXTERNAL_ROOT --prefix=$EXTERNAL_ROOT[snip] CC src/lib/evloop/compat_libevent.osrc/lib/compress/compress_lzma.c:24:18: fatal error: lzma.h: No such file or directory #include <lzma.h> ^compilation terminated.
The workaround is to add --disable-lzma --disable-zstd.
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.
That reminds me, I saw an issue when running all these Android builds where ./configure --enable-lzma would fail to include without stopping with an error when running the build without pkg-config. I don't remember the exact details, unfortuately. ./configure would print out an error, but it would continue with the whole build, and the resulting tor binary did not have lzma.
(These are libraries that we detect with pkg-config; an appropriate solution would probably depend on how pkg-config expects people to handle this.)
You can tell pkg-config to look in your cross-compile root using $PKG_CONFIG_PATH, $PKG_CONFIG_LIBDIR, and $PKG_CONFIG_SYSROOT_DIR:
https://linux.die.net/man/1/pkg-config
That reminds me, I saw an issue when running all these Android builds where ./configure --enable-lzma would fail to include without stopping with an error when running the build without pkg-config. I don't remember the exact details, unfortuately. ./configure would print out an error, but it would continue with the whole build, and the resulting tor binary did not have lzma.
On a plain Debian/buster system, running the commands in the issue report should reproduce this. None of the PKG_CONFIG_* env vars are set. Seems to me that if ./configure depends on pkg-config, it should set those env vars when cross-compiling. Or it would probably be enough to use the value set by --prefix=. That's in effect what we are doing in our complete Android builds:
It would not be too much work for me to setup a cross-compiling test CI job in gitlab-ci if you would use it. I don't really know how to do that in travis, since you can start with a plain base image, AFAIK.
Or maybe skip pkg-config all together when cross-compiling, it seems to cause more problems than fix in that case. The dependencies are never going to come from the system.
Or maybe skip pkg-config all together when cross-compiling, it seems to cause more problems than fix in that case. The dependencies are never going to come from the system.
Do the libraries in your cross-compiling root contain pkg-config files?
They end with ".pc".
tor-android $ ls -1 external/lib/pkgconfig/libcrypto.pclibevent_core.pclibevent_extra.pclibevent_openssl.pclibevent.pclibevent_pthreads.pcliblzma.pclibssl.pclibzstd.pcopenssl.pc
It would not be too much work for me to setup a cross-compiling test CI job in gitlab-ci if you would use it. I don't really know how to do that in travis, since you can start with a plain base image, AFAIK.
As far as I know, the network team monitors Jenkins, Travis, and Appveyor CI. That's enough for now. We might move to GitLab after the ticket tracker transition. Or a few people might be using GitLab for their own builds.
If you want to contribute GitLab configs, that's fine, but you should also find someone to run and monitor them.
PKG_CONFIG_SYSROOT_DIR doesn't seem right because it includes the prefix e.g. /usr. Here's the snipped from the docs:
"Modify -I and -L to use the directories located in target sysroot. this option is usefull when crosscompiling package that use pkg-config to determine CFLAGS anf LDFLAGS. -I and -L are modified to point to the new system root. this means that a -I/usr/include/libfoo will become -I/var/target/usr/include/libfoo with a PKG_CONFIG_SYSROOT_DIR equal to /var/target (same rule apply to -L)"
export PKG_CONFIG_PATH=$EXTERNAL_ROOT/lib/pkgconfig has been working in the tor-android project.
About gitlab-ci, I have the .gitlab-ci.yml updates already done. And they don't have to be monitored by the network team to be useful. They'll take affect on anyone who has a tor fork in a gitlab instance. That said, gitlab-ci can be set up like Travis-CI and Appveyor in GitHub pull requests.
PKG_CONFIG_SYSROOT_DIR doesn't seem right because it includes the prefix e.g. /usr. Here's the snipped from the docs:
"Modify -I and -L to use the directories located in target sysroot. this option is usefull when crosscompiling package that use pkg-config to determine CFLAGS anf LDFLAGS. -I and -L are modified to point to the new system root. this means that a -I/usr/include/libfoo will become -I/var/target/usr/include/libfoo with a PKG_CONFIG_SYSROOT_DIR equal to /var/target (same rule apply to -L)"
export PKG_CONFIG_PATH=$EXTERNAL_ROOT/lib/pkgconfig has been working in the tor-android project.
Ok, let's work out how to set PKG_CONFIG_PATH in configure?
I'm guessing the MinGW/Windows builds us a cross-compile too, I'm not aware of Tor's Windows build setup, so I can't speak to that, though I have maintained autotools build systems for Windows before.
Now that I think about this, I think this could break some setups on UNIX since those might rely on the pkg-config PATH having multiple paths in it, and when cross-compiling, there should only be --prefix. It needs to be set only when cross-compiling. So I think this needs to set based on these conditions
Can you provide an example of where that check is wrong? libevent is a hard requirement for building, and the idea here is that this is testing that the user ran make install into prefix for libevent. In that case, libevent.pc will be present. This error points out incomplete or missing installs, and is only enabled in very specific cases than can be overridden. This check is more isolated than enable_tool_name_check, and that check is totally broken on Android and iOS #32334 (moved).
I don't think it makes sense for me to contribute any more patches to the tor build system, my experience and point of view seems to only conflict with the opinions here. It seems that the tor devs have a very different conception of what ./configure should provide that is specific to tor. In my contributions to gnupg, openssl, ffmpeg, puredata, and others, I've built an understanding that ./configure is meant to provide a clean build interface for consumers first and foremost. Providing useful errors is an essential part of that. I've never worked on a build system that put all the possible customization options first, before the simple build.
Happy to see this stuff merged. At this point for the Android builds, we'll be working out of our fork for 0.4.1.x and 0.4.2.x. So we won't need the backports.
Nick, do you think we should backport this build fix to 0.4.2?
Hm. Can we envision this breaking any reasonable build that would previously have succeeded? If not, I think a backport is reasonable.
It only sets PKG_CONFIG_PATH when it's unset. So it does override the default path compiled in to the pkg-config binary, but that path is wrong for cross-compiles. It never overrides user-configured paths.