Skip to content

Commit

Permalink
fix msvc build
Browse files Browse the repository at this point in the history
  • Loading branch information
Taowyoo committed Sep 8, 2023
1 parent d2bf61b commit b4e0bcc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
10 changes: 5 additions & 5 deletions ct.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ case "$TRAVIS_RUST_VERSION" in

# The SGX target cannot be run under test like a ELF binary
if [ "$TARGET" != "x86_64-fortanix-unknown-sgx" ]; then
# no_std tests only are able to run on x86 platform
if [ "$TARGET" == "x86_64-unknown-linux-gnu" ] || [ "$TARGET" == "x86_64-apple-darwin" ] || [[ "$TARGET" =~ ^x86_64-pc-windows- ]]; then
cargo nextest run --no-default-features --features no_std_deps,rdrand,time --target $TARGET
cargo nextest run --no-default-features --features no_std_deps --target $TARGET
fi
# make sure that explicitly providing the default target works
cargo nextest run --target $TARGET --release
cargo nextest run --features dsa --target $TARGET
Expand All @@ -114,11 +119,6 @@ case "$TRAVIS_RUST_VERSION" in
cargo nextest run --features force_aesni_support,tls13 --target $TARGET
fi

# no_std tests only are able to run on x86 platform
if [ "$TARGET" == "x86_64-unknown-linux-gnu" ] || [ "$TARGET" == "x86_64-apple-darwin" ] || [[ "$TARGET" =~ ^x86_64-pc-windows- ]]; then
cargo nextest run --no-default-features --features no_std_deps,rdrand,time --target $TARGET
cargo nextest run --no-default-features --features no_std_deps --target $TARGET
fi
else
cargo +$TRAVIS_RUST_VERSION test --no-run --target=$TARGET
cargo +$TRAVIS_RUST_VERSION test --no-default-features --features dsa,force_aesni_support,mpi_force_c_code,rdrand,std,time,tls13 --no-run --target=$TARGET
Expand Down
21 changes: 10 additions & 11 deletions mbedtls-platform-support/src/self_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,17 @@ cfg_if::cfg_if! {
}
}
}
cfg_if::cfg_if! {
if #[cfg(any(not(feature = "std"), target_env = "sgx"))] {
#[allow(non_upper_case_globals)]
static mut rand_f: Option<fn() -> c_int> = None;

// needs to be pub for global visiblity
#[doc(hidden)]
#[no_mangle]
pub unsafe extern "C" fn rand() -> c_int {
rand_f.expect("Called self-test rand without enabling self-test")()
}
}
#[cfg(any(not(feature = "std"), target_env = "sgx"))]
#[allow(non_upper_case_globals)]
static mut rand_f: Option<fn() -> c_int> = None;

// needs to be pub for global visiblity
#[cfg(all(any(not(feature = "std"), target_env = "sgx"), not(target_env = "msvc")))]
#[doc(hidden)]
#[no_mangle]
pub unsafe extern "C" fn rand() -> c_int {
rand_f.expect("Called self-test rand without enabling self-test")()
}

/// Set callback functions to enable the MbedTLS self tests.
Expand Down

0 comments on commit b4e0bcc

Please sign in to comment.