22839: Build tor with rust enabled on win

- make tor_util static library name configurable
- fix Rust libary dependency order for Windows
This commit is contained in:
Ties Stuij 2017-08-10 01:08:41 -07:00 committed by Nick Mathewson
parent 8f8a061b0c
commit 2e99f839e9
8 changed files with 113 additions and 94 deletions

View File

@ -26,7 +26,7 @@ TESTING_TOR_BINARY=$(top_builddir)/src/or/tor$(EXEEXT)
endif
if USE_RUST
rust_ldadd=$(top_builddir)/src/rust/target/release/libtor_util.a
rust_ldadd=$(top_builddir)/src/rust/target/release/@TOR_RUST_UTIL_STATIC_NAME@
else
rust_ldadd=
endif

View File

@ -258,64 +258,6 @@ dnl List all external rust crates we depend on here. Include the version
rust_crates="libc-0.2.22"
AC_SUBST(rust_crates)
if test "x$enable_rust" = "xyes"; then
AC_ARG_VAR([RUSTC], [path to the rustc binary])
AC_CHECK_PROG([RUSTC], [rustc], [rustc],[no])
if test "x$RUSTC" = "xno"; then
AC_MSG_ERROR([rustc unavailable but rust integration requested.])
fi
AC_ARG_VAR([CARGO], [path to the cargo binary])
AC_CHECK_PROG([CARGO], [cargo], [cargo],[no])
if test "x$CARGO" = "xno"; then
AC_MSG_ERROR([cargo unavailable but rust integration requested.])
fi
AC_DEFINE([HAVE_RUST], 1, [have Rust])
if test "x$enable_cargo_online_mode" = "xyes"; then
CARGO_ONLINE=
RUST_DL=#
else
CARGO_ONLINE=--frozen
RUST_DL=
dnl When we're not allowed to touch the network, we need crate dependencies
dnl locally available.
AC_MSG_CHECKING([rust crate dependencies])
AC_ARG_VAR([RUST_DEPENDENCIES], [path to directory with local crate mirror])
if test "x$RUST_DEPENDENCIES" = "x"; then
RUST_DEPENDENCIES="$srcdir/src/ext/rust/"
NEED_MOD=1
fi
if test ! -d "$RUST_DEPENDENCIES"; then
AC_MSG_ERROR([Rust dependency directory $RUST_DEPENDENCIES does not exist. Specify a dependency directory using the RUST_DEPENDENCIES variable or allow cargo to fetch crates using --enable-cargo-online-mode.])
fi
for dep in $rust_crates; do
if test ! -d "$RUST_DEPENDENCIES"/"$dep"; then
AC_MSG_ERROR([Failure to find rust dependency $RUST_DEPENDENCIES/$dep. Specify a dependency directory using the RUST_DEPENDENCIES variable or allow cargo to fetch crates using --enable-cargo-online-mode.])
fi
done
if test "x$NEED_MOD" = "x1"; then
dnl When looking for dependencies from cargo, pick right directory
RUST_DEPENDENCIES="../../src/ext/rust"
fi
fi
AC_SUBST(CARGO_ONLINE)
AC_SUBST(RUST_DL)
dnl Let's check the rustc version, too
AC_MSG_CHECKING([rust version])
RUSTC_VERSION_MAJOR=`$RUSTC --version | cut -d ' ' -f 2 | cut -d '.' -f 1`
RUSTC_VERSION_MINOR=`$RUSTC --version | cut -d ' ' -f 2 | cut -d '.' -f 2`
if test "x$RUSTC_VERSION_MAJOR" = "x" -o "x$RUSTC_VERSION_MINOR" = "x"; then
AC_MSG_ERROR([rustc version couldn't be identified])
fi
if test "$RUSTC_VERSION_MAJOR" -lt 2 -a "$RUSTC_VERSION_MINOR" -lt 14; then
AC_MSG_ERROR([rustc must be at least version 1.14])
fi
fi
ifdef([AC_C_FLEXIBLE_ARRAY_MEMBER], [
AC_C_FLEXIBLE_ARRAY_MEMBER
], [
@ -451,6 +393,73 @@ fi
AC_C_BIGENDIAN
if test "x$enable_rust" = "xyes"; then
AC_ARG_VAR([RUSTC], [path to the rustc binary])
AC_CHECK_PROG([RUSTC], [rustc], [rustc],[no])
if test "x$RUSTC" = "xno"; then
AC_MSG_ERROR([rustc unavailable but rust integration requested.])
fi
AC_ARG_VAR([CARGO], [path to the cargo binary])
AC_CHECK_PROG([CARGO], [cargo], [cargo],[no])
if test "x$CARGO" = "xno"; then
AC_MSG_ERROR([cargo unavailable but rust integration requested.])
fi
AC_DEFINE([HAVE_RUST], 1, [have Rust])
if test "x$enable_cargo_online_mode" = "xyes"; then
CARGO_ONLINE=
RUST_DL=#
else
CARGO_ONLINE=--frozen
RUST_DL=
dnl When we're not allowed to touch the network, we need crate dependencies
dnl locally available.
AC_MSG_CHECKING([rust crate dependencies])
AC_ARG_VAR([RUST_DEPENDENCIES], [path to directory with local crate mirror])
if test "x$RUST_DEPENDENCIES" = "x"; then
RUST_DEPENDENCIES="$srcdir/src/ext/rust/"
NEED_MOD=1
fi
if test ! -d "$RUST_DEPENDENCIES"; then
AC_MSG_ERROR([Rust dependency directory $RUST_DEPENDENCIES does not exist. Specify a dependency directory using the RUST_DEPENDENCIES variable or allow cargo to fetch crates using --enable-cargo-online-mode.])
fi
for dep in $rust_crates; do
if test ! -d "$RUST_DEPENDENCIES"/"$dep"; then
AC_MSG_ERROR([Failure to find rust dependency $RUST_DEPENDENCIES/$dep. Specify a dependency directory using the RUST_DEPENDENCIES variable or allow cargo to fetch crates using --enable-cargo-online-mode.])
fi
done
if test "x$NEED_MOD" = "x1"; then
dnl When looking for dependencies from cargo, pick right directory
RUST_DEPENDENCIES="../../src/ext/rust"
fi
fi
dnl For now both MSVC and MinGW rust libraries will output static libs with
dnl the MSVC naming convention.
if test "$bwin32" = "true"; then
TOR_RUST_UTIL_STATIC_NAME=tor_util.lib
else
TOR_RUST_UTIL_STATIC_NAME=libtor_util.a
fi
AC_SUBST(TOR_RUST_UTIL_STATIC_NAME)
AC_SUBST(CARGO_ONLINE)
AC_SUBST(RUST_DL)
dnl Let's check the rustc version, too
AC_MSG_CHECKING([rust version])
RUSTC_VERSION_MAJOR=`$RUSTC --version | cut -d ' ' -f 2 | cut -d '.' -f 1`
RUSTC_VERSION_MINOR=`$RUSTC --version | cut -d ' ' -f 2 | cut -d '.' -f 2`
if test "x$RUSTC_VERSION_MAJOR" = "x" -o "x$RUSTC_VERSION_MINOR" = "x"; then
AC_MSG_ERROR([rustc version couldn't be identified])
fi
if test "$RUSTC_VERSION_MAJOR" -lt 2 -a "$RUSTC_VERSION_MINOR" -lt 14; then
AC_MSG_ERROR([rustc must be at least version 1.14])
fi
fi
AC_SEARCH_LIBS(socket, [socket network])
AC_SEARCH_LIBS(gethostbyname, [nsl])
AC_SEARCH_LIBS(dlopen, [dl])
@ -574,13 +583,16 @@ if test "$bwin32" = "true"; then
# Some of the cargo-cults recommend -lwsock32 as well, but I don't
# think it's actually necessary.
TOR_LIB_GDI=-lgdi32
TOR_LIB_USERENV=-luserenv
else
TOR_LIB_WS32=
TOR_LIB_GDI=
TOR_LIB_USERENV=
fi
AC_SUBST(TOR_LIB_WS32)
AC_SUBST(TOR_LIB_GDI)
AC_SUBST(TOR_LIB_IPHLPAPI)
AC_SUBST(TOR_LIB_USERENV)
tor_libevent_pkg_redhat="libevent"
tor_libevent_pkg_debian="libevent-dev"
@ -894,7 +906,7 @@ dnl since sometimes the linker will like an option but not be willing to
dnl use it with a build of a library.
all_ldflags_for_check="$TOR_LDFLAGS_zlib $TOR_LDFLAGS_openssl $TOR_LDFLAGS_libevent"
all_libs_for_check="$TOR_ZLIB_LIBS $TOR_LIB_MATH $TOR_LIBEVENT_LIBS $TOR_OPENSSL_LIBS $TOR_SYSTEMD_LIBS $TOR_LIB_WS32 $TOR_LIB_GDI $TOR_CAP_LIBS"
all_libs_for_check="$TOR_ZLIB_LIBS $TOR_LIB_MATH $TOR_LIBEVENT_LIBS $TOR_OPENSSL_LIBS $TOR_SYSTEMD_LIBS $TOR_LIB_WS32 $TOR_LIB_GDI $TOR_LIB_USERENV $TOR_CAP_LIBS"
CFLAGS_FTRAPV=
CFLAGS_FWRAPV=

View File

@ -30,13 +30,14 @@ FUZZING_LIBS = \
src/common/libor-ctime-testing.a \
src/common/libor-event-testing.a \
src/trunnel/libor-trunnel-testing.a \
$(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
@TOR_LIBEVENT_LIBS@ \
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @CURVE25519_LIBS@ \
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@CURVE25519_LIBS@ \
@TOR_SYSTEMD_LIBS@ \
@TOR_LZMA_LIBS@ \
@TOR_ZSTD_LIBS@ \
$(rust_ldadd)
@TOR_ZSTD_LIBS@
oss-fuzz-prereqs: \
src/or/libtor-testing.a \

View File

@ -127,10 +127,11 @@ src_or_tor_LDADD = src/or/libtor.a src/common/libor.a src/common/libor-ctime.a \
src/common/libor-crypto.a $(LIBKECCAK_TINY) $(LIBDONNA) \
src/common/libor-event.a src/trunnel/libor-trunnel.a \
src/trace/libor-trace.a \
$(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ @TOR_OPENSSL_LIBS@ \
@TOR_LIB_WS32@ @TOR_LIB_GDI@ @CURVE25519_LIBS@ @TOR_SYSTEMD_LIBS@ \
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ \
$(rust_ldadd)
@TOR_LIB_WS32@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@CURVE25519_LIBS@ @TOR_SYSTEMD_LIBS@ \
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
if COVERAGE_ENABLED
src_or_tor_cov_SOURCES = src/or/tor_main.c

View File

@ -4,7 +4,7 @@ EXTRA_DIST +=\
src/rust/tor_util/ffi.rs \
src/rust/tor_util/rust_string.rs
src/rust/target/release/libtor_util.a: FORCE
src/rust/target/release/@TOR_RUST_UTIL_STATIC_NAME@: FORCE
( cd "$(abs_top_srcdir)/src/rust/tor_util" ; \
CARGO_TARGET_DIR="$(abs_top_builddir)/src/rust/target" \
CARGO_HOME="$(abs_top_builddir)/src/rust" \

View File

@ -15,13 +15,13 @@ FUZZING_LIBS = \
src/common/libor-ctime-testing.a \
src/common/libor-event-testing.a \
src/trunnel/libor-trunnel-testing.a \
$(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
@TOR_LIBEVENT_LIBS@ \
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @CURVE25519_LIBS@ \
@TOR_LIBEVENT_LIBS@ @TOR_OPENSSL_LIBS@ \
@TOR_LIB_WS32@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ @CURVE25519_LIBS@ \
@TOR_SYSTEMD_LIBS@ \
@TOR_LZMA_LIBS@ \
@TOR_ZSTD_LIBS@ \
$(rust_ldadd)
@TOR_ZSTD_LIBS@
oss-fuzz-prereqs: \
src/or/libtor-testing.a \

View File

@ -197,9 +197,10 @@ src_test_test_switch_id_LDFLAGS = @TOR_LDFLAGS_zlib@
src_test_test_switch_id_LDADD = \
src/common/libor-testing.a \
src/common/libor-ctime-testing.a \
$(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ \
$(rust_ldadd)
@TOR_LIB_WS32@ @TOR_LIB_USERENV@ \
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
src_test_test_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ \
@TOR_LDFLAGS_libevent@
@ -212,10 +213,11 @@ src_test_test_LDADD = src/or/libtor-testing.a \
src/common/libor-event-testing.a \
src/trunnel/libor-trunnel-testing.a \
src/trace/libor-trace.a \
$(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @CURVE25519_LIBS@ \
@TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ \
$(rust_ldadd)
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@CURVE25519_LIBS@ \
@TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
src_test_test_slow_CPPFLAGS = $(src_test_test_CPPFLAGS)
src_test_test_slow_CFLAGS = $(src_test_test_CFLAGS)
@ -237,10 +239,11 @@ src_test_bench_LDADD = src/or/libtor.a src/common/libor.a \
src/common/libor-crypto.a $(LIBKECCAK_TINY) $(LIBDONNA) \
src/common/libor-event.a src/trunnel/libor-trunnel.a \
src/trace/libor-trace.a \
$(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @CURVE25519_LIBS@ \
@TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ \
$(rust_ldadd)
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@CURVE25519_LIBS@ \
@TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
src_test_test_workqueue_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ \
@TOR_LDFLAGS_libevent@
@ -250,10 +253,11 @@ src_test_test_workqueue_LDADD = src/or/libtor-testing.a \
src/common/libor-crypto-testing.a $(LIBKECCAK_TINY) $(LIBDONNA) \
src/common/libor-event-testing.a \
src/trace/libor-trace.a \
$(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @CURVE25519_LIBS@ \
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ \
$(rust_ldadd)
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@CURVE25519_LIBS@ \
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
src_test_test_timers_CPPFLAGS = $(src_test_test_CPPFLAGS)
src_test_test_timers_CFLAGS = $(src_test_test_CFLAGS)
@ -262,10 +266,11 @@ src_test_test_timers_LDADD = \
src/common/libor-ctime-testing.a \
src/common/libor-event-testing.a \
src/common/libor-crypto-testing.a $(LIBKECCAK_TINY) $(LIBDONNA) \
$(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @CURVE25519_LIBS@ \
@TOR_LZMA_LIBS@ \
$(rust_ldadd)
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@CURVE25519_LIBS@ \
@TOR_LZMA_LIBS@
src_test_test_timers_LDFLAGS = $(src_test_test_LDFLAGS)
noinst_HEADERS+= \
@ -292,10 +297,10 @@ src_test_test_ntor_cl_LDADD = src/or/libtor.a src/common/libor.a \
src/common/libor-ctime.a \
src/common/libor-crypto.a $(LIBKECCAK_TINY) $(LIBDONNA) \
src/trace/libor-trace.a \
$(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @CURVE25519_LIBS@ \
@TOR_LZMA_LIBS@ \
$(rust_ldadd)
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@CURVE25519_LIBS@ @TOR_LZMA_LIBS@
src_test_test_ntor_cl_AM_CPPFLAGS = \
-I"$(top_srcdir)/src/or"
@ -315,9 +320,9 @@ src_test_test_bt_cl_SOURCES = src/test/test_bt_cl.c
src_test_test_bt_cl_LDADD = src/common/libor-testing.a \
src/common/libor-ctime-testing.a \
src/trace/libor-trace.a \
$(rust_ldadd) \
@TOR_LIB_MATH@ \
@TOR_LIB_WS32@ @TOR_LIB_GDI@ \
$(rust_ldadd)
@TOR_LIB_WS32@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@
src_test_test_bt_cl_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
src_test_test_bt_cl_CPPFLAGS= $(src_test_AM_CPPFLAGS) $(TEST_CPPFLAGS)

View File

@ -8,8 +8,8 @@ src_tools_tor_resolve_SOURCES = src/tools/tor-resolve.c
src_tools_tor_resolve_LDFLAGS =
src_tools_tor_resolve_LDADD = src/common/libor.a \
src/common/libor-ctime.a \
@TOR_LIB_MATH@ @TOR_LIB_WS32@ \
$(rust_ldadd)
$(rust_ldadd) \
@TOR_LIB_MATH@ @TOR_LIB_WS32@ @TOR_LIB_USERENV@
if COVERAGE_ENABLED
src_tools_tor_cov_resolve_SOURCES = src/tools/tor-resolve.c
@ -26,9 +26,9 @@ src_tools_tor_gencert_LDADD = src/common/libor.a src/common/libor-crypto.a \
src/common/libor-ctime.a \
$(LIBKECCAK_TINY) \
$(LIBDONNA) \
$(rust_ldadd) \
@TOR_LIB_MATH@ @TOR_ZLIB_LIBS@ @TOR_OPENSSL_LIBS@ \
@TOR_LIB_WS32@ @TOR_LIB_GDI@ @CURVE25519_LIBS@ \
$(rust_ldadd)
@TOR_LIB_WS32@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ @CURVE25519_LIBS@
if COVERAGE_ENABLED
src_tools_tor_cov_gencert_SOURCES = src/tools/tor-gencert.c