Build environment: CentOS v5.8/x86_64 with GCC v4.4.6.
Use of the --enable-static-tor cannot result in a successful build, at least not with GLibC v2.5.
Use of this flag causes the --static switch to be placed on the compiler command line when running tests from the configure script. So when the script tries to verify, say, a working libevent library, the test fails. Then the script falsely believes that the intended test (e.g. finding a linkable libevent lib) has failed. The actual failure is the inability to staticly link GLibC.
Here's as example:
$ gcc44 -o /tmp/conftest -static -I/home/rpmbuild/BUILD/tor-0.2.3.20-rc/dependencies/include -I${top_srcdir}/src/common -L/home/rpmbuild/BUILD/tor-0.2.3.20-rc/dependencies/lib -L/home/rpmbuild/BUILD/tor-0.2.3.20-rc/dependencies/lib /tmp/conftest.c -lpthread -ldl -lrt -levent
/home/rpmbuild/BUILD/tor-0.2.3.20-rc/dependencies/lib/libevent.a(evutil.o): In function test_for_getaddrinfo_hacks': /home/rpmbuild/BUILD/tor-0.2.3.20-rc/libevent-2.0.19-stable/evutil.c:1105: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /home/rpmbuild/BUILD/tor-0.2.3.20-rc/dependencies/lib/libevent.a(evutil.o): In function evutil_unparse_protoname':
/home/rpmbuild/BUILD/tor-0.2.3.20-rc/libevent-2.0.19-stable/evutil.c:758: warning: Using 'getprotobynumber' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/rpmbuild/BUILD/tor-0.2.3.20-rc/dependencies/lib/libevent.a(event.o): In function gettime': /home/rpmbuild/BUILD/tor-0.2.3.20-rc/libevent-2.0.19-stable/event.c:366: undefined reference to clock_gettime'
/home/rpmbuild/BUILD/tor-0.2.3.20-rc/dependencies/lib/libevent.a(event.o): In function detect_monotonic': /home/rpmbuild/BUILD/tor-0.2.3.20-rc/libevent-2.0.19-stable/event.c:336: undefined reference to clock_gettime'
Ouch! Guess it couldn't find a working libevent.a, right? Wrong!
What linker couldn't do is staticly link GLibC's runtime libraries. Remove that --static from the command line and the configure script's test succeeds in linking against the specified static libevent library.
Tor can be successfully linked against static zlib/openssl/libevent libraries but it cannot be staticly linked against gLibC. This makes --enable-static-tor pointless, a least for Linux builds.
Trac: Username: tmpname0901
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items
0
Show closed items
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Linked items
0
Link issues together to show that they're related.
Learn more.
Putting this in 0.2.4; I want to clean up our library search and build system heavily, but the way it stands now, it's way too fragile to fix in 0.2.3.x without having a high risk of breaking stuff.
Trac: Milestone: Tor: 0.2.3.x-final to Tor: 0.2.4.x-final
Okay, I have a branch for this. The reason this was failing is because library order was partially reversed for linking. There are three remaining issues that need some clarification. Please see branch bug6623 in my public user repo.
However, overall, I wonder if there is any benefit in supporting static linking at this point. (To be clear, I don't actually have a use for this)
The backtrace unit tests fail because the symbols are not shown/available. This needs further investigation.
$ ./src/test/test util/pwdbutil/pwdb: [forking] OK1 tests ok. (0 skipped)
During linking, the following messages are emitted:
CCLD src/app/tor/usr/lib64/libcrypto.a(fips.o): In function `verify_checksums':(.text+0x4fb): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linkingsrc/lib/libtor-fs.a(dir.o): In function `check_private_dir':/home/user/tor/src/lib/fs/dir.c:216: warning: Using 'getgrgid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linkingsrc/lib/libtor-fs.a(userdb.o): In function `tor_getpwnam':/home/user/tor/src/lib/fs/userdb.c:80: warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linkingsrc/lib/libtor-fs.a(userdb.o): In function `tor_getpwuid':/home/user/tor/src/lib/fs/userdb.c:110: warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linkingsrc/lib/libtor-net.a(resolve.o): In function `tor_addr_lookup':/home/user/tor/src/lib/net/resolve.c:102: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking/usr/lib64/libcrypto.a(b_sock.o): In function `BIO_gethostbyname':(.text+0x71): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking/home/user/repos/libevent/.libs/libevent.a(evutil.o): In function `evutil_unparse_protoname':/home/user/repos/libevent/evutil.c:911: warning: Using 'getprotobynumber' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking/home/user/repos/libevent/.libs/libevent.a(evutil.o): In function `evutil_parse_servname':/home/user/repos/libevent/evutil.c:883: warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
I'd actually like to deprecate the TOR_SEARCH_LIBRARY nonsense if possible, and not add its use for zlib. (I don't understand why this patch starts using TOR_SEARCH_LIBRARY for zlib, but I assume it's necessary? Can we use pkg-config instead?)
When I try to use this patch with --enable-static-tor, it fails during configuration with
checking whether free(NULL) works... noconfigure: error: Your libc implementation doesn't allow free(NULL), as required by C99.
I'd actually like to deprecate the TOR_SEARCH_LIBRARY nonsense if possible, and not add its use for zlib. (I don't understand why this patch starts using TOR_SEARCH_LIBRARY for zlib, but I assume it's necessary? Can we use pkg-config instead?)
Hrm, it shouldn't. I simply moved the zlib check from being after the openssl checks to being before it (because openssl depends on zlib).
When I try to use this patch with --enable-static-tor, it fails during configuration with
{{{
checking whether free(NULL) works... no
configure: error: Your libc implementation doesn't allow free(NULL), as required by C99.
}}}
Am I doing something wrong?
Nope, that is possible. I ran into that, too. Do you have glibc-static installed? -lc is probably resulting in an error due to the lack of a static library. I should've added a more helpful error message for this case. I can do that.
I'd actually like to deprecate the TOR_SEARCH_LIBRARY nonsense if possible, and not add its use for zlib. (I don't understand why this patch starts using TOR_SEARCH_LIBRARY for zlib, but I assume it's necessary? Can we use pkg-config instead?)
Hrm, it shouldn't. I simply moved the zlib check from being after the openssl checks to being before it (because openssl depends on zlib).
Oh! I didn't notice that this was moved code. Okay, no need to change stuff in this patch.
When I try to use this patch with --enable-static-tor, it fails during configuration with
{{{
checking whether free(NULL) works... no
configure: error: Your libc implementation doesn't allow free(NULL), as required by C99.
}}}
Am I doing something wrong?
Nope, that is possible. I ran into that, too. Do you have glibc-static installed? -lc is probably resulting in an error due to the lack of a static library. I should've added a more helpful error message for this case. I can do that.
Marking a number of 0.3.5 tickets as possible, maybe even a good idea, for later. Possibly backportable, some of them. But not currently things to do as part of 0.3.5 stabilization.
I want to build tor, not download it from somewhere else. My computer is on wifi so that prevents me from being an acceptable relay or bridge, best I can tell. But after I copy over the binaries I made, to a computer with ethernet to the router, and run tor I get this:
dyld: Library not loaded: @rpath/libclang_rt.asan_osx_dynamic.dylib Referenced from: /path/to/tor/bin/tor Reason: image not foundAbort trap: 6
So it seems tor is relying on a library burried deep in xcode.
I've already built zlib, libevent, and libressl/openssl as static. My tor configure line informs tor of this. But as soon as I add --enable-static-tor and ./configure, the checking stops (as noted above in comment 21) here:
checking whether free(NULL) works... noconfigure: error: Your libc implementation doesn't allow free(NULL), as required by C99.
Based on my reading of this ticket and others, it seems there is something out of order, but my attempts to mimic what others said worked for them, has not worked for me.
I changed the order as noted in the patch here: #27802 (moved), (lines 169 & 222), but the same error happened.
I want to build tor, not download it from somewhere else. My computer is on wifi so that prevents me from being an acceptable relay or bridge, best I can tell. But after I copy over the binaries I made, to a computer with ethernet to the router, and run tor I get this:
{{{
dyld: Library not loaded: @rpath/libclang_rt.asan_osx_dynamic.dylib
Referenced from: /path/to/tor/bin/tor
Reason: image not found
Abort trap: 6
}}}
So it seems tor is relying on a library burried deep in xcode.
This is the clang address sanitizer library. We don't recommend using it for relays or bridges, because it makes them crash on some non-fatal errors.
You can disable this library by removing --enable-expensive-hardening or --enable-fragile-hardening from your configure command-line.
I've already built zlib, libevent, and libressl/openssl as static. My tor configure line informs tor of this. But as soon as I add --enable-static-tor and ./configure, the checking stops (as noted above in comment 21) here:
{{{
checking whether free(NULL) works... no
configure: error: Your libc implementation doesn't allow free(NULL), as required by C99.
}}}
Based on my reading of this ticket and others, it seems there is something out of order, but my attempts to mimic what others said worked for them, has not worked for me.
I changed the order as noted in the patch here: #27802 (moved), (lines 169 & 222), but the same error happened.
Does macOS ship with a static C library?
As far as I remember, it's not possible to build a truly static binary on macOS, because some of the lower-level OS libraries are dynamic. But you can get close.
And I think you're actually trying to solve a slightly different problem, which is transferring a binary from one macOS to another. That shouldn't require a static tor, Tor Browser compiles a single binary that works on multiple macOS versions.
Have you tried passing -mmacosx-version-min=version to your C compiler? That will disable any features that aren't available on newer macOS.
Have you tried building all the dynamic libraries, and then copying them across with the binary? You may need to set the library paths correctly in the binary, or set LD_LIBRARY_PATH before launching it.
You might also be happier if you use a package manager like HomeBrew to build from source on the wired Mac. It should have package definitions and debugging output that let you modify and verify the build.