Build one big .a library full of Tor's implementation.

This is experimental and probably will break some platforms
This commit is contained in:
Nick Mathewson 2020-09-18 12:17:02 -04:00
parent e8a4482335
commit e9dbb5e395
5 changed files with 63 additions and 11 deletions

View File

@ -14,6 +14,7 @@ CLEANFILES=
TESTS= TESTS=
noinst_PROGRAMS= noinst_PROGRAMS=
DISTCLEANFILES= DISTCLEANFILES=
MOSTLYCLEANFILES=
bin_SCRIPTS= bin_SCRIPTS=
AM_CPPFLAGS=\ AM_CPPFLAGS=\
-I$(top_srcdir)/src \ -I$(top_srcdir)/src \
@ -137,6 +138,13 @@ TOR_INTERNAL_LIBS = \
src/trunnel/libor-trunnel.a \ src/trunnel/libor-trunnel.a \
src/lib/libtor-trace.a src/lib/libtor-trace.a
libtor.a: $(TOR_INTERNAL_LIBS)
$(AM_V_AR) export AR="$(AR)"; \
export ARFLAGS="$(ARFLAGS)"; \
$(top_srcdir)/scripts/build/combine_libs libtor.a $(TOR_INTERNAL_LIBS)
MOSTLYCLEANFILES += libtor.a
# Variants of the above for linking the testing variant of tor (for coverage # Variants of the above for linking the testing variant of tor (for coverage
# and tests) # and tests)
if UNITTESTS_ENABLED if UNITTESTS_ENABLED
@ -148,6 +156,14 @@ TOR_INTERNAL_TESTING_LIBS = \
$(TOR_UTIL_TESTING_LIBS) \ $(TOR_UTIL_TESTING_LIBS) \
src/trunnel/libor-trunnel-testing.a \ src/trunnel/libor-trunnel-testing.a \
src/lib/libtor-trace.a src/lib/libtor-trace.a
src/test/libtor-testing.a: $(TOR_INTERNAL_TESTING_LIBS)
$(AM_V_AR) export AR="$(AR)"; \
export ARFLAGS="$(ARFLAGS)"; \
export RANLIB="$(RANLIB)"; \
$(top_srcdir)/scripts/build/combine_libs src/test/libtor-testing.a $(TOR_INTERNAL_TESTING_LIBS)
MOSTLYCLEANFILES += src/test/libtor-testing.a
endif endif
TOR_LDFLAGS_CRYPTLIB=@TOR_LDFLAGS_openssl@ TOR_LDFLAGS_CRYPTLIB=@TOR_LDFLAGS_openssl@
@ -175,6 +191,7 @@ EXTRA_DIST+= \
Makefile.nmake \ Makefile.nmake \
README \ README \
ReleaseNotes \ ReleaseNotes \
scripts/build/combine_libs \
scripts/maint/checkIncludes.py \ scripts/maint/checkIncludes.py \
scripts/maint/checkSpace.pl \ scripts/maint/checkSpace.pl \
scripts/maint/checkSpaceTest.sh \ scripts/maint/checkSpaceTest.sh \
@ -701,7 +718,7 @@ show-distdir-core:
file $(distdir)/_build/core; fi file $(distdir)/_build/core; fi
show-libs: show-libs:
@echo $(TOR_INTERNAL_LIBS) @echo libtor.a
show-testing-libs: show-testing-libs:
@echo $(TOR_INTERNAL_TESTING_LIBS) @echo src/test/libtor-testing.a

35
scripts/build/combine_libs Executable file
View File

@ -0,0 +1,35 @@
#!/bin/sh
set -e
TMPDIR="$(mktemp -d -t tor_lib_combining.XXXXXX)"
ORIGDIR="$(pwd)"
trap 'cd "$ORIGDIR" && rm -rf "$TMPDIR"' 0
abspath() {
echo "$(cd "$(dirname "$1")">/dev/null && pwd)/$(basename "$1")"
}
TARGET=$(abspath "$1")
#echo ORIGDIR="$ORIGDIR"
#echo AR="$AR"
#echo ARFLAGS="$AFLAGS"
shift
for input in "$@"; do
cd "$ORIGDIR"
abs=$(abspath "$input")
dir="$TMPDIR"/$(basename "$input" .a)
mkdir "$dir"
cd "$dir">/dev/null
ar x "$abs"
done
cd "$TMPDIR" >/dev/null
#echo "${AR:-ar}" "${ARFLAGS:-cru}" library.tmp.a ./*/**
"${AR:-ar}" "${ARFLAGS:-cru}" library.tmp.a ./*/**
"${RANLIB:-ranlib}" library.tmp.a
mv -f library.tmp.a "$TARGET"

View File

@ -31,7 +31,7 @@ FUZZING_CFLAGS = \
FUZZING_LDFLAG = \ FUZZING_LDFLAG = \
@TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) @TOR_LDFLAGS_libevent@ @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) @TOR_LDFLAGS_libevent@
FUZZING_LIBS = \ FUZZING_LIBS = \
$(TOR_INTERNAL_TESTING_LIBS) \ src/test/libtor-testing.a \
$(rust_ldadd) \ $(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \ @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
@TOR_LIBEVENT_LIBS@ $(TOR_LIBS_CRYPTLIB) \ @TOR_LIBEVENT_LIBS@ $(TOR_LIBS_CRYPTLIB) \
@ -41,7 +41,7 @@ FUZZING_LIBS = \
@TOR_ZSTD_LIBS@ @TOR_ZSTD_LIBS@
oss-fuzz-prereqs: \ oss-fuzz-prereqs: \
$(TOR_INTERNAL_TESTING_LIBS) src/test/libtor-testing.a
noinst_HEADERS += \ noinst_HEADERS += \
src/test/fuzz/fuzzing.h src/test/fuzz/fuzzing.h

View File

@ -15,7 +15,7 @@ src_app_tor_SOURCES = src/app/main/tor_main.c
# matters a lot there, and is quite hard to debug if you forget to do it. # matters a lot there, and is quite hard to debug if you forget to do it.
src_app_tor_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) @TOR_LDFLAGS_libevent@ src_app_tor_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) @TOR_LDFLAGS_libevent@
src_app_tor_LDADD = $(TOR_INTERNAL_LIBS) \ src_app_tor_LDADD = libtor.a \
$(rust_ldadd) \ $(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ $(TOR_LIBS_CRYPTLIB) \ @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ $(TOR_LIBS_CRYPTLIB) \
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \ @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@ -27,7 +27,7 @@ src_app_tor_cov_SOURCES = $(src_app_tor_SOURCES)
src_app_tor_cov_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS) src_app_tor_cov_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS)
src_app_tor_cov_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS) src_app_tor_cov_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
src_app_tor_cov_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) @TOR_LDFLAGS_libevent@ src_app_tor_cov_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) @TOR_LDFLAGS_libevent@
src_app_tor_cov_LDADD = $(TOR_INTERNAL_TESTING_LIBS) \ src_app_tor_cov_LDADD = src/test/libtor-testing.a \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ $(TOR_LIBS_CRYPTLIB) \ @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ $(TOR_LIBS_CRYPTLIB) \
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ \ @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ \
@CURVE25519_LIBS@ @TOR_SYSTEMD_LIBS@ \ @CURVE25519_LIBS@ @TOR_SYSTEMD_LIBS@ \

View File

@ -310,7 +310,7 @@ src_test_test_switch_id_LDADD = \
src_test_test_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \ src_test_test_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
@TOR_LDFLAGS_libevent@ @TOR_LDFLAGS_libevent@
src_test_test_LDADD = \ src_test_test_LDADD = \
$(TOR_INTERNAL_TESTING_LIBS) \ src/test/libtor-testing.a \
$(rust_ldadd) \ $(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \ @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \ $(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@ -339,7 +339,7 @@ src_test_test_memwipe_LDFLAGS = $(src_test_test_LDFLAGS) @CFLAGS_BUGTRAP@
src_test_bench_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \ src_test_bench_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
@TOR_LDFLAGS_libevent@ @TOR_LDFLAGS_libevent@
src_test_bench_LDADD = \ src_test_bench_LDADD = \
$(TOR_INTERNAL_LIBS) \ libtor.a \
$(rust_ldadd) \ $(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \ @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \ $(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@ -349,7 +349,7 @@ src_test_bench_LDADD = \
src_test_test_workqueue_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \ src_test_test_workqueue_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
@TOR_LDFLAGS_libevent@ @TOR_LDFLAGS_libevent@
src_test_test_workqueue_LDADD = \ src_test_test_workqueue_LDADD = \
$(TOR_INTERNAL_TESTING_LIBS) \ src/test/libtor-testing.a \
$(rust_ldadd) \ $(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \ @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \ $(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@ -398,7 +398,7 @@ noinst_PROGRAMS+= src/test/test-hs-ntor-cl
src_test_test_ntor_cl_SOURCES = src/test/test_ntor_cl.c src_test_test_ntor_cl_SOURCES = src/test/test_ntor_cl.c
src_test_test_ntor_cl_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) src_test_test_ntor_cl_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB)
src_test_test_ntor_cl_LDADD = \ src_test_test_ntor_cl_LDADD = \
$(TOR_INTERNAL_LIBS) \ libtor.a \
$(rust_ldadd) \ $(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \ @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \ $(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@ -409,7 +409,7 @@ src_test_test_ntor_cl_AM_CPPFLAGS = \
src_test_test_hs_ntor_cl_SOURCES = src/test/test_hs_ntor_cl.c src_test_test_hs_ntor_cl_SOURCES = src/test/test_hs_ntor_cl.c
src_test_test_hs_ntor_cl_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) src_test_test_hs_ntor_cl_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB)
src_test_test_hs_ntor_cl_LDADD = \ src_test_test_hs_ntor_cl_LDADD = \
$(TOR_INTERNAL_LIBS) \ libtor.a \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \ @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ \ $(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ \
@CURVE25519_LIBS@ @TOR_TRACE_LIBS@ @CURVE25519_LIBS@ @TOR_TRACE_LIBS@