Skip to content

Commit 053ce3b

Browse files
TaowyooDrTobe
andauthored
Fix macos build (#333)
* Allow name-mangling for the mbedtls_free, mbedtls_calloc and mbedtls_ssl_flush_output functions According to the discussion in rust-lang/rust-bindgen#1221 (comment), the \u{1} is a hint to LLVM to avoid name-mangling but this might be required on some platforms to link against the right name, e.g. on macOS. * Add macOS test in CI * tests: add missing nextest config * build: bump ver --------- Co-authored-by: Tobias Naumann <[email protected]>
1 parent 0a79c87 commit 053ce3b

File tree

7 files changed

+130
-4
lines changed

7 files changed

+130
-4
lines changed

.config/nextest.toml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# This is based on the default config used by nextest. It is embedded in the binary at
2+
# build time. It may be used as a template for .config/nextest.toml.
3+
4+
[store]
5+
# The directory under the workspace root at which nextest-related files are
6+
# written. Profile-specific storage is currently written to dir/<profile-name>.
7+
dir = "target/nextest"
8+
9+
[test-groups]
10+
serial-integration = { max-threads = 1 }
11+
12+
# This section defines the default nextest profile. Custom profiles are layered
13+
# on top of the default profile.
14+
[profile.default]
15+
# "retries" defines the number of times a test should be retried. If set to a
16+
# non-zero value, tests that succeed on a subsequent attempt will be marked as
17+
# non-flaky. Can be overridden through the `--retries` option.
18+
# Examples
19+
# * retries = 3
20+
# * retries = { backoff = "fixed", count = 2, delay = "1s" }
21+
# * retries = { backoff = "exponential", count = 10, delay = "1s", jitter = true, max-delay = "10s" }
22+
retries = 0
23+
24+
# The number of threads to run tests with. Supported values are either an integer or
25+
# the string "num-cpus". Can be overridden through the `--test-threads` option.
26+
test-threads = "num-cpus"
27+
28+
# The number of threads required for each test. This is generally used in overrides to
29+
# mark certain tests as heavier than others. However, it can also be set as a global parameter.
30+
threads-required = 1
31+
32+
# Show these test statuses in the output.
33+
#
34+
# The possible values this can take are:
35+
# * none: no output
36+
# * fail: show failed (including exec-failed) tests
37+
# * retry: show flaky and retried tests
38+
# * slow: show slow tests
39+
# * pass: show passed tests
40+
# * skip: show skipped tests (most useful for CI)
41+
# * all: all of the above
42+
#
43+
# Each value includes all the values above it; for example, "slow" includes
44+
# failed and retried tests.
45+
#
46+
# Can be overridden through the `--status-level` flag.
47+
status-level = "pass"
48+
49+
# Similar to status-level, show these test statuses at the end of the run.
50+
final-status-level = "flaky"
51+
52+
# "failure-output" defines when standard output and standard error for failing tests are produced.
53+
# Accepted values are
54+
# * "immediate": output failures as soon as they happen
55+
# * "final": output failures at the end of the test run
56+
# * "immediate-final": output failures as soon as they happen and at the end of
57+
# the test run; combination of "immediate" and "final"
58+
# * "never": don't output failures at all
59+
#
60+
# For large test suites and CI it is generally useful to use "immediate-final".
61+
#
62+
# Can be overridden through the `--failure-output` option.
63+
failure-output = "immediate"
64+
65+
# "success-output" controls production of standard output and standard error on success. This should
66+
# generally be set to "never".
67+
success-output = "never"
68+
69+
# Cancel the test run on the first failure. For CI runs, consider setting this
70+
# to false.
71+
fail-fast = true
72+
73+
# Treat a test that takes longer than the configured 'period' as slow, and print a message.
74+
# See <https://nexte.st/book/slow-tests> for more information.
75+
#
76+
# Optional: specify the parameter 'terminate-after' with a non-zero integer,
77+
# which will cause slow tests to be terminated after the specified number of
78+
# periods have passed.
79+
# Example: slow-timeout = { period = "60s", terminate-after = 2 }
80+
slow-timeout = { period = "60s" }
81+
82+
# Treat a test as leaky if after the process is shut down, standard output and standard error
83+
# aren't closed within this duration.
84+
#
85+
# This usually happens in case of a test that creates a child process and lets it inherit those
86+
# handles, but doesn't clean the child process up (especially when it fails).
87+
#
88+
# See <https://nexte.st/book/leaky-tests> for more information.
89+
leak-timeout = "100ms"
90+
91+
[profile.default.junit]
92+
# Output a JUnit report into the given file inside 'store.dir/<profile-name>'.
93+
# If unspecified, JUnit is not written out.
94+
95+
# path = "junit.xml"
96+
97+
# The name of the top-level "report" element in JUnit report. If aggregating
98+
# reports across different test runs, it may be useful to provide separate names
99+
# for each report.
100+
report-name = "nextest-run"
101+
102+
# Whether standard output and standard error for passing tests should be stored in the JUnit report.
103+
# Output is stored in the <system-out> and <system-err> elements of the <testcase> element.
104+
store-success-output = false
105+
106+
# Whether standard output and standard error for failing tests should be stored in the JUnit report.
107+
# Output is stored in the <system-out> and <system-err> elements of the <testcase> element.
108+
#
109+
# Note that if a description can be extracted from the output, it is always stored in the
110+
# <description> element.
111+
store-failure-output = true
112+
113+
[[profile.default.overrides]]
114+
# `is_probably_prime` test heavily use rdrand, sometimes the VM where test is running has shortage on it
115+
filter = 'test(is_probably_prime)'
116+
retries = { backoff = "exponential", count = 6, delay = "1s", jitter = true }
117+
test-group = 'serial-integration'
118+

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ jobs:
5454
- rust: nightly
5555
target: x86_64-unknown-linux-gnu
5656
os: ubuntu-20.04
57+
- rust: stable
58+
target: x86_64-apple-darwin
59+
os: macos-latest
5760

5861
runs-on: ${{ matrix.os }}
5962

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ci.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ case "$TRAVIS_RUST_VERSION" in
4343
cargo nextest run --no-default-features --features "$FEAT"no_std_deps,rdrand,time --target $TARGET
4444
cargo nextest run --no-default-features --features "$FEAT"no_std_deps --target $TARGET
4545
fi
46+
if [ "$TARGET" == "x86_64-apple-darwin" ]; then
47+
cargo nextest run --no-default-features --features no_std_deps --target $TARGET
48+
fi
4649

4750
else
4851
cargo +$TRAVIS_RUST_VERSION test --no-run --features "$FEAT" --target=$TARGET

mbedtls-sys/build/cmake.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ impl super::BuildConfig {
1919
.define("ENABLE_TESTING", "OFF")
2020
// This is turn off on windows by default
2121
.define("GEN_FILES", "ON")
22+
// Prefer unix-style over Apple-style Python3 on macOS, required for the Github Actions CI
23+
.define("Python3_FIND_FRAMEWORK", "LAST")
2224
.build_target("install");
2325
for cflag in &self.cflags {
2426
cmk.cflag(cflag);

mbedtls/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "mbedtls"
33
# We jumped from v0.9 to v0.12 because v0.10 and v0.11 were based on mbedtls 3.X, which
44
# we decided not to support.
5-
version = "0.12.0-alpha.1"
5+
version = "0.12.0-alpha.2"
66
authors = ["Jethro Beekman <[email protected]>"]
77
build = "build.rs"
88
edition = "2018"

mbedtls/src/alloc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ use core::ptr::NonNull;
1616
use mbedtls_sys::types::raw_types::c_void;
1717

1818
extern "C" {
19-
#[link_name = concat!("\u{1}forward_mbedtls_free_", env!("RUST_MBEDTLS_METADATA_HASH"))]
19+
#[link_name = concat!("forward_mbedtls_free_", env!("RUST_MBEDTLS_METADATA_HASH"))]
2020
pub(crate) fn mbedtls_free(n: *mut mbedtls_sys::types::raw_types::c_void);
21-
#[link_name = concat!("\u{1}forward_mbedtls_calloc_", env!("RUST_MBEDTLS_METADATA_HASH"))]
21+
#[link_name = concat!("forward_mbedtls_calloc_", env!("RUST_MBEDTLS_METADATA_HASH"))]
2222
pub(crate) fn mbedtls_calloc(
2323
n: mbedtls_sys::types::size_t,
2424
size: mbedtls_sys::types::size_t,

0 commit comments

Comments
 (0)