Commit 29080866 authored by Nick Mathewson's avatar Nick Mathewson 🎃
Browse files

Merge branch 'combined_libs'

parents 0d420918 e834702f
......@@ -14,6 +14,7 @@ CLEANFILES=
TESTS=
noinst_PROGRAMS=
DISTCLEANFILES=
MOSTLYCLEANFILES=
bin_SCRIPTS=
AM_CPPFLAGS=\
-I$(top_srcdir)/src \
......@@ -137,6 +138,13 @@ TOR_INTERNAL_LIBS = \
src/trunnel/libor-trunnel.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
# and tests)
if UNITTESTS_ENABLED
......@@ -148,6 +156,14 @@ TOR_INTERNAL_TESTING_LIBS = \
$(TOR_UTIL_TESTING_LIBS) \
src/trunnel/libor-trunnel-testing.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
TOR_LDFLAGS_CRYPTLIB=@TOR_LDFLAGS_openssl@
......@@ -175,6 +191,7 @@ EXTRA_DIST+= \
Makefile.nmake \
README \
ReleaseNotes \
scripts/build/combine_libs \
scripts/maint/checkIncludes.py \
scripts/maint/checkSpace.pl \
scripts/maint/checkSpaceTest.sh \
......@@ -701,7 +718,7 @@ show-distdir-core:
file $(distdir)/_build/core; fi
show-libs:
@echo $(TOR_INTERNAL_LIBS)
@echo libtor.a
show-testing-libs:
@echo $(TOR_INTERNAL_TESTING_LIBS)
@echo src/test/libtor-testing.a
o Minor features (compilation):
- When building Tor, first link all object files into a single
static library. This may help with embedding Tor in other
programs. Note that most Tor functions do not constitute a
part of a stable or supported API: Only those functions in
tor_api.h should be used if embedding Tor. Closes ticket
40127.
#!/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"
......@@ -31,17 +31,18 @@ FUZZING_CFLAGS = \
FUZZING_LDFLAG = \
@TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) @TOR_LDFLAGS_libevent@
FUZZING_LIBS = \
$(TOR_INTERNAL_TESTING_LIBS) \
src/test/libtor-testing.a \
$(rust_ldadd) \
@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@ @CURVE25519_LIBS@ \
@TOR_SYSTEMD_LIBS@ \
@TOR_LZMA_LIBS@ \
@TOR_ZSTD_LIBS@
@TOR_ZSTD_LIBS@ \
@TOR_TRACE_LIBS@
oss-fuzz-prereqs: \
$(TOR_INTERNAL_TESTING_LIBS)
src/test/libtor-testing.a
noinst_HEADERS += \
src/test/fuzz/fuzzing.h
......
......@@ -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.
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) \
@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@ \
......@@ -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_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
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_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ \
@CURVE25519_LIBS@ @TOR_SYSTEMD_LIBS@ \
......
......@@ -7,17 +7,18 @@ FUZZING_CFLAGS = \
FUZZING_LDFLAG = \
@TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) @TOR_LDFLAGS_libevent@
FUZZING_LIBS = \
$(TOR_INTERNAL_TESTING_LIBS) \
src/test/libtor-testing.a \
$(rust_ldadd) \
@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@ @CURVE25519_LIBS@ \
@TOR_SYSTEMD_LIBS@ \
@TOR_LZMA_LIBS@ \
@TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@
@TOR_ZSTD_LIBS@ \
@TOR_TRACE_LIBS@
oss-fuzz-prereqs: \
$(TOR_INTERNAL_TESTING_LIBS)
src/test/libtor-testing.a
noinst_HEADERS += \
src/test/fuzz/fuzzing.h
......
......@@ -312,7 +312,7 @@ src_test_test_switch_id_LDADD = \
src_test_test_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
@TOR_LDFLAGS_libevent@
src_test_test_LDADD = \
$(TOR_INTERNAL_TESTING_LIBS) \
src/test/libtor-testing.a \
$(rust_ldadd) \
@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@ \
......@@ -341,7 +341,7 @@ src_test_test_memwipe_LDFLAGS = $(src_test_test_LDFLAGS) @CFLAGS_BUGTRAP@
src_test_bench_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
@TOR_LDFLAGS_libevent@
src_test_bench_LDADD = \
$(TOR_INTERNAL_LIBS) \
libtor.a \
$(rust_ldadd) \
@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@ \
......@@ -351,7 +351,7 @@ src_test_bench_LDADD = \
src_test_test_workqueue_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
@TOR_LDFLAGS_libevent@
src_test_test_workqueue_LDADD = \
$(TOR_INTERNAL_TESTING_LIBS) \
src/test/libtor-testing.a \
$(rust_ldadd) \
@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@ \
......@@ -400,7 +400,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_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB)
src_test_test_ntor_cl_LDADD = \
$(TOR_INTERNAL_LIBS) \
libtor.a \
$(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
......@@ -411,7 +411,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_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB)
src_test_test_hs_ntor_cl_LDADD = \
$(TOR_INTERNAL_LIBS) \
libtor.a \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_SHLWAPI@ @TOR_LIB_GDI@ \
@CURVE25519_LIBS@ @TOR_TRACE_LIBS@
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment