[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] 22839: Build tor with rust enabled on win
commit 2e99f839e97e2b5b1e99abdb9a8673380c87ae18
Author: Ties Stuij <ties@xxxxxxxx>
Date: Thu Aug 10 01:08:41 2017 -0700
22839: Build tor with rust enabled on win
- make tor_util static library name configurable
- fix Rust libary dependency order for Windows
---
Makefile.am | 2 +-
configure.ac | 130 +++++++++++++++++++---------------
scripts/codegen/fuzzing_include_am.py | 7 +-
src/or/include.am | 7 +-
src/rust/tor_util/include.am | 2 +-
src/test/fuzz/include.am | 8 +--
src/test/include.am | 43 ++++++-----
src/tools/include.am | 8 +--
8 files changed, 113 insertions(+), 94 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 79d2e7852..f1f64f210 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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
diff --git a/configure.ac b/configure.ac
index 345e499ff..1e41b3f08 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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=
diff --git a/scripts/codegen/fuzzing_include_am.py b/scripts/codegen/fuzzing_include_am.py
index 6e45c2192..045d0f892 100755
--- a/scripts/codegen/fuzzing_include_am.py
+++ b/scripts/codegen/fuzzing_include_am.py
@@ -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 \
diff --git a/src/or/include.am b/src/or/include.am
index 8db5be095..69b505fcd 100644
--- a/src/or/include.am
+++ b/src/or/include.am
@@ -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
diff --git a/src/rust/tor_util/include.am b/src/rust/tor_util/include.am
index f0cd63920..ec3898577 100644
--- a/src/rust/tor_util/include.am
+++ b/src/rust/tor_util/include.am
@@ -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" \
diff --git a/src/test/fuzz/include.am b/src/test/fuzz/include.am
index 2961dab56..d90e8283f 100644
--- a/src/test/fuzz/include.am
+++ b/src/test/fuzz/include.am
@@ -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 \
diff --git a/src/test/include.am b/src/test/include.am
index 7a9ecca90..c0d95d951 100644
--- a/src/test/include.am
+++ b/src/test/include.am
@@ -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)
diff --git a/src/tools/include.am b/src/tools/include.am
index 717af9e2a..37936c742 100644
--- a/src/tools/include.am
+++ b/src/tools/include.am
@@ -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
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits