diff options
Diffstat (limited to 'src/rust')
-rw-r--r-- | src/rust/Cargo.lock | 1 | ||||
-rw-r--r-- | src/rust/Cargo.toml | 16 | ||||
-rw-r--r-- | src/rust/crypto/Cargo.toml | 1 | ||||
-rw-r--r-- | src/rust/external/Cargo.toml | 6 | ||||
-rw-r--r-- | src/rust/external/lib.rs | 2 | ||||
-rw-r--r-- | src/rust/protover/Cargo.toml | 1 | ||||
-rw-r--r-- | src/rust/protover/ffi.rs | 3 | ||||
-rw-r--r-- | src/rust/smartlist/Cargo.toml | 1 | ||||
-rw-r--r-- | src/rust/smartlist/lib.rs | 9 | ||||
-rw-r--r-- | src/rust/tor_allocate/Cargo.toml | 1 | ||||
-rw-r--r-- | src/rust/tor_allocate/lib.rs | 5 | ||||
-rw-r--r-- | src/rust/tor_log/Cargo.toml | 1 | ||||
-rw-r--r-- | src/rust/tor_log/tor_log.rs | 8 | ||||
-rw-r--r-- | src/rust/tor_rust/Cargo.toml | 2 | ||||
-rw-r--r-- | src/rust/tor_util/Cargo.toml | 1 |
15 files changed, 26 insertions, 32 deletions
diff --git a/src/rust/Cargo.lock b/src/rust/Cargo.lock index 1d2a7359aa..7d6a6635c5 100644 --- a/src/rust/Cargo.lock +++ b/src/rust/Cargo.lock @@ -26,6 +26,7 @@ version = "0.0.1" dependencies = [ "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", "smartlist 0.0.1", + "tor_allocate 0.0.1", ] [[package]] diff --git a/src/rust/Cargo.toml b/src/rust/Cargo.toml index e399dbb33a..83f9629660 100644 --- a/src/rust/Cargo.toml +++ b/src/rust/Cargo.toml @@ -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 = [] diff --git a/src/rust/crypto/Cargo.toml b/src/rust/crypto/Cargo.toml index 6ebfe0dc11..a7ff7f78d9 100644 --- a/src/rust/crypto/Cargo.toml +++ b/src/rust/crypto/Cargo.toml @@ -9,7 +9,6 @@ build = "../build.rs" [lib] name = "crypto" path = "lib.rs" -crate_type = ["rlib", "staticlib"] [dependencies] libc = "=0.2.39" diff --git a/src/rust/external/Cargo.toml b/src/rust/external/Cargo.toml index 4735144ee6..5f443645bb 100644 --- a/src/rust/external/Cargo.toml +++ b/src/rust/external/Cargo.toml @@ -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), diff --git a/src/rust/external/lib.rs b/src/rust/external/lib.rs index b72a4f6e4c..d68036fcad 100644 --- a/src/rust/external/lib.rs +++ b/src/rust/external/lib.rs @@ -8,7 +8,7 @@ //! module implementing this functionality repeatedly. extern crate libc; - +extern crate tor_allocate; extern crate smartlist; pub mod crypto_digest; diff --git a/src/rust/protover/Cargo.toml b/src/rust/protover/Cargo.toml index 2f7783e76c..84a7c71c1a 100644 --- a/src/rust/protover/Cargo.toml +++ b/src/rust/protover/Cargo.toml @@ -31,4 +31,3 @@ path = "../tor_log" [lib] name = "protover" path = "lib.rs" -crate_type = ["rlib", "staticlib"] diff --git a/src/rust/protover/ffi.rs b/src/rust/protover/ffi.rs index 940f923327..ac149fbbbc 100644 --- a/src/rust/protover/ffi.rs +++ b/src/rust/protover/ffi.rs @@ -62,6 +62,9 @@ pub extern "C" fn protover_all_supported( }; if let Some(unsupported) = relay_proto_entry.all_supported() { + if missing_out.is_null() { + return 0; + } let c_unsupported: CString = match CString::new(unsupported.to_string()) { Ok(n) => n, Err(_) => return 1, diff --git a/src/rust/smartlist/Cargo.toml b/src/rust/smartlist/Cargo.toml index 4ecdf50869..a5afe7bf74 100644 --- a/src/rust/smartlist/Cargo.toml +++ b/src/rust/smartlist/Cargo.toml @@ -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), diff --git a/src/rust/smartlist/lib.rs b/src/rust/smartlist/lib.rs index 2716842af2..34d0b907ed 100644 --- a/src/rust/smartlist/lib.rs +++ b/src/rust/smartlist/lib.rs @@ -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; diff --git a/src/rust/tor_allocate/Cargo.toml b/src/rust/tor_allocate/Cargo.toml index 7bb3b9887f..06ac605f17 100644 --- a/src/rust/tor_allocate/Cargo.toml +++ b/src/rust/tor_allocate/Cargo.toml @@ -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), diff --git a/src/rust/tor_allocate/lib.rs b/src/rust/tor_allocate/lib.rs index 5a355bc8d6..1cfa0b5178 100644 --- a/src/rust/tor_allocate/lib.rs +++ b/src/rust/tor_allocate/lib.rs @@ -11,5 +11,10 @@ extern crate libc; +use std::alloc::System; + mod tor_allocate; pub use tor_allocate::*; + +#[global_allocator] +static A: System = System; diff --git a/src/rust/tor_log/Cargo.toml b/src/rust/tor_log/Cargo.toml index 1aa9be0612..14d9ae803a 100644 --- a/src/rust/tor_log/Cargo.toml +++ b/src/rust/tor_log/Cargo.toml @@ -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), diff --git a/src/rust/tor_log/tor_log.rs b/src/rust/tor_log/tor_log.rs index 5231d0c631..757c74ff49 100644 --- a/src/rust/tor_log/tor_log.rs +++ b/src/rust/tor_log/tor_log.rs @@ -89,15 +89,15 @@ pub mod log { use super::LogSeverity; use libc::{c_char, c_int}; - /// Severity log types. These mirror definitions in /src/common/torlog.h - /// C_RUST_COUPLED: src/common/log.c, log domain types + /// Severity log types. These mirror definitions in src/lib/log/log.h + /// C_RUST_COUPLED: src/lib/log/log.c, log domain types extern "C" { static LOG_WARN_: c_int; static LOG_NOTICE_: c_int; } - /// Domain log types. These mirror definitions in /src/common/torlog.h - /// C_RUST_COUPLED: src/common/log.c, log severity types + /// Domain log types. These mirror definitions in src/lib/log/log.h + /// C_RUST_COUPLED: src/lib/log/log.c, log severity types extern "C" { static LD_NET_: u32; static LD_GENERAL_: u32; diff --git a/src/rust/tor_rust/Cargo.toml b/src/rust/tor_rust/Cargo.toml index 1523ee0dd1..35c629882e 100644 --- a/src/rust/tor_rust/Cargo.toml +++ b/src/rust/tor_rust/Cargo.toml @@ -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" diff --git a/src/rust/tor_util/Cargo.toml b/src/rust/tor_util/Cargo.toml index 51e4bd9c5d..9ffaeda8a6 100644 --- a/src/rust/tor_util/Cargo.toml +++ b/src/rust/tor_util/Cargo.toml @@ -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" |