|
12 | 12 | //! present.
|
13 | 13 | //!
|
14 | 14 | //! Some CI jobs try to run faster by disabling debug assertions (through setting
|
15 |
| -//! `NO_DEBUG_ASSERTIONS=1`). If debug assertions are disabled, then we can check for the absence of |
16 |
| -//! additional `usize` formatting and padding related symbols. |
| 15 | +//! `NO_DEBUG_ASSERTIONS=1`). If std debug assertions are disabled, then we can check for the |
| 16 | +//! absence of additional `usize` formatting and padding related symbols. |
17 | 17 |
|
18 | 18 | //@ ignore-cross-compile
|
19 | 19 |
|
20 |
| -use run_make_support::artifact_names::bin_name; |
| 20 | +use std::path::Path; |
| 21 | + |
21 | 22 | use run_make_support::env::std_debug_assertions_enabled;
|
22 |
| -use run_make_support::rustc; |
23 | 23 | use run_make_support::symbols::object_contains_any_symbol_substring;
|
| 24 | +use run_make_support::{is_darwin, rustc}; |
| 25 | + |
| 26 | +// Not applicable for `extern "C"` symbol decoration handling. |
| 27 | +fn sym(sym_name: &str) -> String { |
| 28 | + if is_darwin() { |
| 29 | + // Symbols are decorated with an underscore prefix on darwin platforms. |
| 30 | + format!("_{sym_name}") |
| 31 | + } else { |
| 32 | + sym_name.to_string() |
| 33 | + } |
| 34 | +} |
24 | 35 |
|
25 | 36 | fn main() {
|
26 |
| - rustc().input("main.rs").opt().run(); |
27 | 37 | // panic machinery identifiers, these should not appear in the final binary
|
28 | 38 | let mut panic_syms = vec!["panic_bounds_check", "Debug"];
|
29 | 39 | if std_debug_assertions_enabled() {
|
30 | 40 | // if debug assertions are allowed, we need to allow these,
|
31 | 41 | // otherwise, add them to the list of symbols to deny.
|
32 | 42 | panic_syms.extend_from_slice(&["panicking", "panic_fmt", "pad_integral", "Display"]);
|
33 | 43 | }
|
34 |
| - assert!(!object_contains_any_symbol_substring(bin_name("main"), &panic_syms)); |
| 44 | + let panic_syms = panic_syms.into_iter().map(|name| sym(name)).collect::<Vec<_>>(); |
| 45 | + |
| 46 | + let expect_no_panic_symbols = Path::new("expect_no_panic_symbols"); |
| 47 | + rustc().input("main.rs").output(&expect_no_panic_symbols).opt().run(); |
| 48 | + assert!(!object_contains_any_symbol_substring(&expect_no_panic_symbols, &panic_syms)); |
| 49 | + |
| 50 | + let expect_panic_symbols = Path::new("expect_panic_symbols"); |
| 51 | + rustc().input("main.rs").output(&expect_panic_symbols).run(); |
| 52 | + assert!(object_contains_any_symbol_substring(&expect_panic_symbols, &panic_syms)); |
35 | 53 | }
|
0 commit comments