Skip to content

Commit cd3dd5b

Browse files
committed
Add tests for -Zdwarf-version lto behavior
1 parent 3086510 commit cd3dd5b

5 files changed

+48
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//@ compile-flags: -g --crate-type=rlib -Zdwarf-version=4
2+
3+
pub fn check_is_even(number: &u64) -> bool {
4+
number % 2 == 0
5+
}

Diff for: tests/assembly/dwarf-mixed-versions-lto.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// This test ensures that if LTO occurs between crates with different DWARF versions, we
2+
// will choose the highest DWARF version for the final binary. This matches Clang's behavior.
3+
4+
//@ only-linux
5+
//@ aux-build:dwarf-mixed-versions-lto-aux.rs
6+
//@ compile-flags: -C lto -g -Zdwarf-version=5
7+
//@ assembly-output: emit-asm
8+
//@ no-prefer-dynamic
9+
10+
extern crate dwarf_mixed_versions_lto_aux;
11+
12+
fn main() {
13+
dwarf_mixed_versions_lto_aux::check_is_even(&0);
14+
}
15+
16+
// CHECK: .section .debug_info
17+
// CHECK-NOT: {{\.(short|hword)}} 2
18+
// CHECK-NOT: {{\.(short|hword)}} 4
19+
// CHECK: {{\.(short|hword)}} 5
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
//@ compile-flags: -g --crate-type=rlib -Zdwarf-version=4
2+
3+
pub fn say_hi() {
4+
println!("hello there")
5+
}

Diff for: tests/ui/lto/dwarf-mixed-versions-lto.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// This test verifies that we do not produce a warning when performing LTO on a
2+
// crate graph that contains a mix of different DWARF version settings. This
3+
// matches Clang's behavior.
4+
5+
//@ ignore-msvc Platform must use DWARF
6+
//@ aux-build:dwarf-mixed-versions-lto-aux.rs
7+
//@ compile-flags: -C lto -g -Zdwarf-version=5
8+
//@ no-prefer-dynamic
9+
//@ build-pass
10+
11+
extern crate dwarf_mixed_versions_lto_aux;
12+
13+
fn main() {
14+
dwarf_mixed_versions_lto_aux::say_hi();
15+
}

Diff for: tests/ui/lto/dwarf-mixed-versions-lto.stderr

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
warning: linking module flags 'Dwarf Version': IDs have conflicting values ('i32 4' from with 'i32 5' from dwarf_mixed_versions_lto.7f4a44b55cf2f174-cgu.0)
2+
3+
warning: 1 warning emitted
4+

0 commit comments

Comments
 (0)