Skip to content

Commit

Permalink
Merge branch 'maint-0.3.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
nmathewson committed Oct 30, 2018
2 parents ed8a853 + ee1cc0f commit c19bb4d
Show file tree
Hide file tree
Showing 19 changed files with 46 additions and 56 deletions.
15 changes: 5 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,8 @@ env:
## We don't list default variable values, because we set the defaults
## in global (or the default is unset)
-
## We turn off hardening for Rust builds, because they are incompatible,
## and it's going to take a while for them to be fixed. See:
## https:/trac.torproject.org/projects/tor/ticket/25386
## https:/trac.torproject.org/projects/tor/ticket/26398
## TOR_RUST_DEPENDENCIES is spelt RUST_DEPENDENCIES in 0.3.2
- RUST_OPTIONS="--enable-rust" TOR_RUST_DEPENDENCIES=true HARDENING_OPTIONS=""
- RUST_OPTIONS="--enable-rust" TOR_RUST_DEPENDENCIES=true

matrix:
## include creates builds with gcc, linux, sudo: false
Expand All @@ -54,10 +50,9 @@ matrix:
# We clone our stem repo and run `make test-stem`
- env: TEST_STEM="yes"
## Check rust online with distcheck, to make sure we remove rust products
## But without hardening (see above)
- env: DISTCHECK="yes" RUST_OPTIONS="--enable-rust --enable-cargo-online-mode" HARDENING_OPTIONS=""
- env: DISTCHECK="yes" RUST_OPTIONS="--enable-rust --enable-cargo-online-mode"
## Check disable module dirauth with and without rust
- env: MODULES_OPTIONS="--disable-module-dirauth" RUST_OPTIONS="--enable-rust" TOR_RUST_DEPENDENCIES=true HARDENING_OPTIONS=""
- env: MODULES_OPTIONS="--disable-module-dirauth" RUST_OPTIONS="--enable-rust" TOR_RUST_DEPENDENCIES=true
- env: MODULES_OPTIONS="--disable-module-dirauth"
## Check NSS
- env: NSS_OPTIONS="--enable-nss"
Expand Down Expand Up @@ -181,8 +176,8 @@ install:
- if [[ "$ASCIIDOC_OPTIONS" == "" ]] && [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export XML_CATALOG_FILES="/usr/local/etc/xml/catalog"; fi
## If we're using Rust, download rustup
- if [[ "$RUST_OPTIONS" != "" ]]; then curl -Ssf -o rustup.sh https://sh.rustup.rs; fi
## Install the stable channels of rustc and cargo and setup our toolchain environment
- if [[ "$RUST_OPTIONS" != "" ]]; then sh rustup.sh -y --default-toolchain stable; fi
## Install the nightly channels of rustc and cargo and setup our toolchain environment
- if [[ "$RUST_OPTIONS" != "" ]]; then sh rustup.sh -y --default-toolchain nightly; fi
- if [[ "$RUST_OPTIONS" != "" ]]; then source $HOME/.cargo/env; fi
## If we're testing rust builds in offline-mode, then set up our vendored dependencies
- if [[ "$TOR_RUST_DEPENDENCIES" == "true" ]]; then export TOR_RUST_DEPENDENCIES=$PWD/src/ext/rust/crates; fi
Expand Down
8 changes: 8 additions & 0 deletions changes/rust_asan
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
o Major bugfixes (compilation, rust):
- Rust tests can now build and run successfully with the
--enable-fragile-hardening option enabled.
Doing this currently requires the rust beta channel; it will
be possible with stable rust as of rust version 1.31 is out.
Patch from Alex Crichton.
Fixes bugs 27272, 27273, and 27274.
Bugfix on 0.3.1.1-alpha.
9 changes: 4 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1210,17 +1210,17 @@ dnl variable.
RUST_LINKER_OPTIONS=""
if test "x$have_clang" = "xyes"; then
if test "x$CFLAGS_ASAN" != "x"; then
RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS $CFLAGS_ASAN"
RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=$CFLAGS_ASAN -Cdefault-linker-libraries"
fi
if test "x$CFLAGS_UBSAN" != "x"; then
RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS $CFLAGS_UBSAN"
RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=$CFLAGS_UBSAN -Cdefault-linker-libraries"
fi
else
if test "x$CFLAGS_ASAN" != "x"; then
RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -lasan"
RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=-fsanitize=address -Cdefault-linker-libraries"
fi
if test "x$CFLAGS_UBSAN" != "x"; then
RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -lubsan"
RUST_LINKER_OPTIONS="$RUST_LINKER_OPTIONS -Clink-arg=-fsanitize=undefined -Cdefault-linker-libraries"
fi
fi
AC_SUBST(RUST_LINKER_OPTIONS)
Expand Down Expand Up @@ -2416,7 +2416,6 @@ AC_CONFIG_FILES([
Doxyfile
Makefile
config.rust
link_rust.sh
contrib/dist/suse/tor.sh
contrib/operator-tools/tor.logrotate
contrib/dist/tor.sh
Expand Down
10 changes: 0 additions & 10 deletions link_rust.sh.in

This file was deleted.

1 change: 1 addition & 0 deletions src/rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions src/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,3 @@ members = [
[profile.release]
debug = true
panic = "abort"

[features]
default = []
# If this feature is enabled, test code which calls Tor C code from Rust will
# execute with `cargo test`. Due to numerous linker issues (#25386), this is
# currently disabled by default. Crates listed here are those which, in their
# unittests, doctests, and/or integration tests, call C code.
test-c-from-rust = [
"crypto/test-c-from-rust",
]

# We have to define a feature here because doctests don't get cfg(test),
# and we need to disable some C dependencies when running the doctests
# because of the various linker issues. See
# https://github.com/rust-lang/rust/issues/45599
test_linking_hack = []
1 change: 0 additions & 1 deletion src/rust/crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ build = "../build.rs"
[lib]
name = "crypto"
path = "lib.rs"
crate_type = ["rlib", "staticlib"]

[dependencies]
libc = "=0.2.39"
Expand Down
6 changes: 2 additions & 4 deletions src/rust/external/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ name = "external"

[dependencies]
libc = "=0.2.39"

[dependencies.smartlist]
path = "../smartlist"
smartlist = { path = "../smartlist" }
tor_allocate = { path = "../tor_allocate" }

[lib]
name = "external"
path = "lib.rs"
crate_type = ["rlib", "staticlib"]

[features]
# We have to define a feature here because doctests don't get cfg(test),
Expand Down
2 changes: 1 addition & 1 deletion src/rust/external/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//! module implementing this functionality repeatedly.

extern crate libc;

extern crate tor_allocate;
extern crate smartlist;

pub mod crypto_digest;
Expand Down
1 change: 0 additions & 1 deletion src/rust/protover/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ path = "../tor_log"
[lib]
name = "protover"
path = "lib.rs"
crate_type = ["rlib", "staticlib"]
1 change: 0 additions & 1 deletion src/rust/smartlist/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ libc = "0.2.39"
[lib]
name = "smartlist"
path = "lib.rs"
crate_type = ["rlib", "staticlib"]

[features]
# We have to define a feature here because doctests don't get cfg(test),
Expand Down
9 changes: 9 additions & 0 deletions src/rust/smartlist/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@ extern crate libc;
mod smartlist;

pub use smartlist::*;

// When testing we may be compiled with sanitizers which are incompatible with
// Rust's default allocator, jemalloc (unsure why at this time). Most crates
// link to `tor_allocate` which switches by default to a non-jemalloc allocator,
// but we don't already depend on `tor_allocate` so make sure that while testing
// we don't use jemalloc. (but rather malloc/free)
#[global_allocator]
#[cfg(test)]
static A: std::alloc::System = std::alloc::System;
1 change: 0 additions & 1 deletion src/rust/tor_allocate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ libc = "=0.2.39"
[lib]
name = "tor_allocate"
path = "lib.rs"
crate_type = ["rlib", "staticlib"]

[features]
# We have to define a feature here because doctests don't get cfg(test),
Expand Down
5 changes: 5 additions & 0 deletions src/rust/tor_allocate/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@

extern crate libc;

use std::alloc::System;

mod tor_allocate;
pub use tor_allocate::*;

#[global_allocator]
static A: System = System;
1 change: 0 additions & 1 deletion src/rust/tor_log/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ authors = ["The Tor Project"]
[lib]
name = "tor_log"
path = "lib.rs"
crate_type = ["rlib", "staticlib"]

[features]
# We have to define a feature here because doctests don't get cfg(test),
Expand Down
2 changes: 1 addition & 1 deletion src/rust/tor_rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version = "0.1.0"
[lib]
name = "tor_rust"
path = "lib.rs"
crate_type = ["rlib", "staticlib"]
crate_type = ["staticlib"]

[dependencies.tor_util]
path = "../tor_util"
Expand Down
1 change: 0 additions & 1 deletion src/rust/tor_util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ version = "0.0.1"
[lib]
name = "tor_util"
path = "lib.rs"
crate_type = ["rlib", "staticlib"]

[dependencies.tor_allocate]
path = "../tor_allocate"
Expand Down
3 changes: 1 addition & 2 deletions src/test/include.am
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ TESTS_ENVIRONMENT = \
export EXTRA_CARGO_OPTIONS="$(EXTRA_CARGO_OPTIONS)"; \
export CARGO_ONLINE="$(CARGO_ONLINE)"; \
export CCLD="$(CCLD)"; \
chmod +x "$(abs_top_builddir)/link_rust.sh"; \
export RUSTFLAGS="-C linker=$(abs_top_builddir)/link_rust.sh";
export RUSTFLAGS="-C linker=`echo '$(CC)' | cut -d' ' -f 1` $(RUST_LINKER_OPTIONS)";

TESTSCRIPTS = \
src/test/fuzz_static_testcases.sh \
Expand Down
10 changes: 9 additions & 1 deletion src/test/test_rust.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@ set -e

export LSAN_OPTIONS=suppressions=${abs_top_srcdir:-../../..}/src/test/rust_supp.txt

# When testing Cargo we pass a number of very specific linker flags down
# through Cargo. We do not, however, want these flags to affect things like
# build scripts, only the tests that we're compiling. To ensure this happens
# we unconditionally pass `--target` into Cargo, ensuring that `RUSTFLAGS` in
# the environment won't make their way into build scripts.
rustc_host=$(rustc -vV | grep host | sed 's/host: //')

for cargo_toml_dir in "${abs_top_srcdir:-../../..}"/src/rust/*; do
if [ -e "${cargo_toml_dir}/Cargo.toml" ]; then
cd "${abs_top_builddir:-../../..}/src/rust" && \
CARGO_TARGET_DIR="${abs_top_builddir:-../../..}/src/rust/target" \
"${CARGO:-cargo}" test ${CARGO_ONLINE-"--frozen"} \
--features "test_linking_hack" \
--features "test_linking_hack" \
--target $rustc_host \
${EXTRA_CARGO_OPTIONS} \
--manifest-path "${cargo_toml_dir}/Cargo.toml" || exitcode=1
fi
Expand Down

0 comments on commit c19bb4d

Please sign in to comment.