Skip to content

Commit

Permalink
test: update to the new mangling scheme.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Jan 29, 2019
1 parent 386d425 commit bfb78ea
Show file tree
Hide file tree
Showing 16 changed files with 87 additions and 40 deletions.
14 changes: 7 additions & 7 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2366,15 +2366,15 @@ dependencies = [
name = "rustc-demangle"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-std-workspace-core 1.0.0",
]

[[package]]
name = "rustc-demangle"
version = "0.1.13"
source = "git+https://github.com/eddyb/rustc-demangle?rev=20d5bcc9bcea0d9413540916dd5f9fdadc7012f7#20d5bcc9bcea0d9413540916dd5f9fdadc7012f7"
dependencies = [
"compiler_builtins 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-std-workspace-core 1.0.0",
]

[[package]]
name = "rustc-hash"
Expand Down Expand Up @@ -2497,7 +2497,7 @@ dependencies = [
"cc 1.0.28 (registry+https://github.com/rust-lang/crates.io-index)",
"memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-demangle 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-demangle 0.1.13 (git+https://github.com/eddyb/rustc-demangle?rev=20d5bcc9bcea0d9413540916dd5f9fdadc7012f7)",
"rustc_llvm 0.0.0",
]

Expand All @@ -2513,7 +2513,7 @@ dependencies = [
"memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc-demangle 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-demangle 0.1.13 (git+https://github.com/eddyb/rustc-demangle?rev=20d5bcc9bcea0d9413540916dd5f9fdadc7012f7)",
"rustc_allocator 0.0.0",
"rustc_apfloat 0.0.0",
"rustc_codegen_utils 0.0.0",
Expand Down Expand Up @@ -3094,7 +3094,7 @@ dependencies = [
"panic_unwind 0.0.0",
"profiler_builtins 0.0.0",
"rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-demangle 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-demangle 0.1.13 (git+https://github.com/eddyb/rustc-demangle?rev=20d5bcc9bcea0d9413540916dd5f9fdadc7012f7)",
"rustc_asan 0.0.0",
"rustc_lsan 0.0.0",
"rustc_msan 0.0.0",
Expand Down
7 changes: 6 additions & 1 deletion src/librustc_codegen_llvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ test = false
[dependencies]
cc = "1.0.1"
num_cpus = "1.0"
rustc-demangle = "0.1.4"
# rustc-demangle = "0.1.4"
rustc_llvm = { path = "../librustc_llvm" }
memmap = "0.6"

# HACK(eddyb) temporary until upstreaming support for the new mangling scheme
[dependencies.rustc-demangle]
git = "https://github.com/eddyb/rustc-demangle"
rev = "20d5bcc9bcea0d9413540916dd5f9fdadc7012f7"

[features]
# This is used to convince Cargo to separately cache builds of `rustc_codegen_llvm`
# when this option is enabled or not. That way we can build two, cache two
Expand Down
7 changes: 6 additions & 1 deletion src/librustc_codegen_ssa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test = false
bitflags = "1.0.4"
cc = "1.0.1"
num_cpus = "1.0"
rustc-demangle = "0.1.4"
# rustc-demangle = "0.1.4"
memmap = "0.6"
log = "0.4.5"
libc = "0.2.44"
Expand All @@ -32,3 +32,8 @@ rustc_fs_util = { path = "../librustc_fs_util" }
rustc_incremental = { path = "../librustc_incremental" }
rustc_mir = { path = "../librustc_mir" }
rustc_target = { path = "../librustc_target" }

# HACK(eddyb) temporary until upstreaming support for the new mangling scheme
[dependencies.rustc-demangle]
git = "https://github.com/eddyb/rustc-demangle"
rev = "20d5bcc9bcea0d9413540916dd5f9fdadc7012f7"
8 changes: 7 additions & 1 deletion src/libstd/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ libc = { version = "0.2.44", default-features = false, features = ['rustc-dep-of
compiler_builtins = { version = "0.1.1" }
profiler_builtins = { path = "../libprofiler_builtins", optional = true }
unwind = { path = "../libunwind" }
rustc-demangle = { version = "0.1.10", features = ['rustc-dep-of-std'] }
# rustc-demangle = { version = "0.1.10", features = ['rustc-dep-of-std'] }
backtrace-sys = { version = "0.1.24", features = ["rustc-dep-of-std"], optional = true }

# HACK(eddyb) temporary until upstreaming support for the new mangling scheme
[dependencies.rustc-demangle]
git = "https://github.com/eddyb/rustc-demangle"
rev = "20d5bcc9bcea0d9413540916dd5f9fdadc7012f7"
features = ['rustc-dep-of-std']

[dev-dependencies]
rand = "0.6.1"

Expand Down
18 changes: 9 additions & 9 deletions src/test/codegen/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ pub fn droppy() {
// that's one new drop call per call to possibly_unwinding(), and finally 3 drop calls for the
// regular function exit. We used to have problems with quadratic growths of drop calls in such
// functions.
// CHECK-NOT: invoke{{.*}}drop{{.*}}SomeUniqueName
// CHECK: call{{.*}}drop{{.*}}SomeUniqueName
// CHECK: call{{.*}}drop{{.*}}SomeUniqueName
// CHECK-NOT: call{{.*}}drop{{.*}}SomeUniqueName
// CHECK: invoke{{.*}}drop{{.*}}SomeUniqueName
// CHECK: call{{.*}}drop{{.*}}SomeUniqueName
// CHECK: invoke{{.*}}drop{{.*}}SomeUniqueName
// CHECK: call{{.*}}drop{{.*}}SomeUniqueName
// CHECK-NOT: {{(call|invoke).*}}drop{{.*}}SomeUniqueName
// CHECK-NOT: ; invoke{{.*}}drop{{.*}}SomeUniqueName
// CHECK: ; call{{.*}}drop{{.*}}SomeUniqueName
// CHECK: ; call{{.*}}drop{{.*}}SomeUniqueName
// CHECK-NOT: ; call{{.*}}drop{{.*}}SomeUniqueName
// CHECK: ; invoke{{.*}}drop{{.*}}SomeUniqueName
// CHECK: ; call{{.*}}drop{{.*}}SomeUniqueName
// CHECK: ; invoke{{.*}}drop{{.*}}SomeUniqueName
// CHECK: ; call{{.*}}drop{{.*}}SomeUniqueName
// CHECK-NOT: ; {{(call|invoke).*}}drop{{.*}}SomeUniqueName
// The next line checks for the } that ends the function definition
// CHECK-LABEL: {{^[}]}}
let _s = SomeUniqueName;
Expand Down
4 changes: 3 additions & 1 deletion src/test/codegen/external-no-mangle-fns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ const HIDDEN: () = {
};

// The surrounding item should not accidentally become external
// CHECK: define internal{{.*}} void @_ZN22external_no_mangle_fns1x
// CHECK-LABEL: ; external_no_mangle_fns::x
// CHECK-NEXT: ; Function Attrs:
// CHECK-NEXT: define internal
#[inline(never)]
fn x() {
// CHECK: define void @g()
Expand Down
4 changes: 3 additions & 1 deletion src/test/codegen/external-no-mangle-statics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,6 @@ fn x() {
#[no_mangle]
pub static mut P: u8 = 0;
}
// CHECK: define internal void @_ZN26external_no_mangle_statics1x{{.*$}}
// CHECK-LABEL: ; external_no_mangle_statics::x
// CHECK-NEXT: ; Function Attrs:
// CHECK-NEXT: define internal
4 changes: 3 additions & 1 deletion src/test/codegen/internalize-closures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ pub fn main() {

// We want to make sure that closures get 'internal' linkage instead of
// 'weak_odr' when they are not shared between codegen units
// CHECK: define internal {{.*}}_ZN20internalize_closures4main{{.*}}$u7b$$u7b$closure$u7d$$u7d$
// CHECK-LABEL: ; internalize_closures::main::{closure#0}
// CHECK-NEXT: ; Function Attrs:
// CHECK-NEXT: define internal
let c = |x:i32| { x + 1 };
let _ = c(1);
}
12 changes: 9 additions & 3 deletions src/test/codegen/link-dead-code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@
// This test makes sure that, when -Clink-dead-code is specified, we generate
// code for functions that would otherwise be skipped.

// CHECK-LABEL: define hidden i32 @_ZN14link_dead_code8const_fn
// CHECK-LABEL: ; link_dead_code::const_fn
// CHECK-NEXT: ; Function Attrs:
// CHECK-NEXT: define hidden
const fn const_fn() -> i32 { 1 }

// CHECK-LABEL: define hidden i32 @_ZN14link_dead_code9inline_fn
// CHECK-LABEL: ; link_dead_code::inline_fn
// CHECK-NEXT: ; Function Attrs:
// CHECK-NEXT: define hidden
#[inline]
fn inline_fn() -> i32 { 2 }

// CHECK-LABEL: define hidden i32 @_ZN14link_dead_code10private_fn
// CHECK-LABEL: ; link_dead_code::private_fn
// CHECK-NEXT: ; Function Attrs:
// CHECK-NEXT: define hidden
fn private_fn() -> i32 { 3 }
4 changes: 3 additions & 1 deletion src/test/codegen/local-generics-in-exe-internalized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

// Check that local generics are internalized if they are in the same CGU

// CHECK: define internal {{.*}} @_ZN34local_generics_in_exe_internalized3foo{{.*}}
// CHECK-LABEL: ; local_generics_in_exe_internalized::foo::<u8>
// CHECK-NEXT: ; Function Attrs:
// CHECK-NEXT: define internal
pub fn foo<T>(x: T, y: T) -> (T, T) {
(x, y)
}
Expand Down
4 changes: 3 additions & 1 deletion src/test/codegen/target-cpu-on-functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ pub extern fn exported() {
not_exported();
}

// CHECK-LABEL: define {{.*}} @_ZN23target_cpu_on_functions12not_exported{{.*}}() {{.*}} #0
// CHECK-LABEL: ; target_cpu_on_functions::not_exported
// CHECK-NEXT: ; Function Attrs:
// CHECK-NEXT: define {{.*}}() {{.*}} #0
fn not_exported() {}

// CHECK: attributes #0 = {{.*}} "target-cpu"="{{.*}}"
15 changes: 14 additions & 1 deletion src/test/run-pass/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ fn expected(fn_name: &str) -> String {
format!(" backtrace::{}", fn_name)
}

fn contains_expected_full(s: &str, fn_name: &str) -> bool {
// HACK(eddyb) work around the fact that RUST_BACKTRACE=full
// (or, as is the case here, stack traces from panic-in-panic)
// prints symbols with hashes in them, i.e. `backtrace[...]::`.
let prefix = " backtrace[";
let suffix = &format!("]::{}", fn_name);
s.match_indices(prefix).any(|(i, _)| {
s[i + prefix.len()..]
.trim_start_matches(char::is_alphanumeric)
.starts_with(suffix)
})
}

fn runtest(me: &str) {
// Make sure that the stack trace is printed
let p = template(me).arg("fail").env("RUST_BACKTRACE", "1").spawn().unwrap();
Expand Down Expand Up @@ -78,7 +91,7 @@ fn runtest(me: &str) {
let s = str::from_utf8(&out.stderr).unwrap();
// loosened the following from double::h to double:: due to
// spurious failures on mac, 32bit, optimized
assert!(s.contains("stack backtrace") && s.contains(&expected("double")),
assert!(s.contains("stack backtrace") && contains_expected_full(s, "double"),
"bad output3: {}", s);

// Make sure a stack trace isn't printed too many times
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/symbol-names/basic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![feature(rustc_attrs)]

#[rustc_symbol_name] //~ ERROR _ZN5basic4main
#[rustc_symbol_name] //~ ERROR symbol-name(_RNaCs4fqI2P2rA04_5basic4main)
#[rustc_def_path] //~ ERROR def-path(main)
fn main() {
}
4 changes: 2 additions & 2 deletions src/test/ui/symbol-names/basic.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error: symbol-name(_ZN5basic4main17h08bcaf310214ed52E)
error: symbol-name(_RNaCs4fqI2P2rA04_5basic4main)
--> $DIR/basic.rs:3:1
|
LL | #[rustc_symbol_name] //~ ERROR _ZN5basic4main
LL | #[rustc_symbol_name] //~ ERROR symbol-name(_RNaCs4fqI2P2rA04_5basic4main)
| ^^^^^^^^^^^^^^^^^^^^

error: def-path(main)
Expand Down
6 changes: 4 additions & 2 deletions src/test/ui/symbol-names/impl1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ mod foo {
pub struct Foo { x: u32 }

impl Foo {
#[rustc_symbol_name] //~ ERROR _ZN5impl13foo3Foo3bar
#[rustc_symbol_name]
//~^ ERROR symbol-name(_RNpMNdCs4fqI2P2rA04_5impl13fooNnB2_3Foo3bar)
#[rustc_def_path] //~ ERROR def-path(foo::Foo::bar)
fn bar() { }
}
Expand All @@ -15,7 +16,8 @@ mod bar {
use foo::Foo;

impl Foo {
#[rustc_symbol_name] //~ ERROR _ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz
#[rustc_symbol_name]
//~^ ERROR symbol-name(_RNxMNoCs4fqI2P2rA04_5impl13barNnNdB4_3foo3Foo3baz)
#[rustc_def_path] //~ ERROR def-path(bar::<impl foo::Foo>::baz)
fn baz() { }
}
Expand Down
14 changes: 7 additions & 7 deletions src/test/ui/symbol-names/impl1.stderr
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
error: symbol-name(_ZN5impl13foo3Foo3bar17hc487d6ec13fe9124E)
error: symbol-name(_RNpMNdCs4fqI2P2rA04_5impl13fooNnB2_3Foo3bar)
--> $DIR/impl1.rs:8:9
|
LL | #[rustc_symbol_name] //~ ERROR _ZN5impl13foo3Foo3bar
LL | #[rustc_symbol_name]
| ^^^^^^^^^^^^^^^^^^^^

error: def-path(foo::Foo::bar)
--> $DIR/impl1.rs:9:9
--> $DIR/impl1.rs:10:9
|
LL | #[rustc_def_path] //~ ERROR def-path(foo::Foo::bar)
| ^^^^^^^^^^^^^^^^^

error: symbol-name(_ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz17h38577281258e1527E)
--> $DIR/impl1.rs:18:9
error: symbol-name(_RNxMNoCs4fqI2P2rA04_5impl13barNnNdB4_3foo3Foo3baz)
--> $DIR/impl1.rs:19:9
|
LL | #[rustc_symbol_name] //~ ERROR _ZN5impl13bar33_$LT$impl$u20$impl1..foo..Foo$GT$3baz
LL | #[rustc_symbol_name]
| ^^^^^^^^^^^^^^^^^^^^

error: def-path(bar::<impl foo::Foo>::baz)
--> $DIR/impl1.rs:19:9
--> $DIR/impl1.rs:21:9
|
LL | #[rustc_def_path] //~ ERROR def-path(bar::<impl foo::Foo>::baz)
| ^^^^^^^^^^^^^^^^^
Expand Down

0 comments on commit bfb78ea

Please sign in to comment.