Add tests for -Zdwarf-version lto behavior

This commit is contained in:
Wesley Wiser 2025-02-06 04:25:40 +00:00
parent 30865107cb
commit cd3dd5bd23
5 changed files with 48 additions and 0 deletions

View file

@ -0,0 +1,5 @@
//@ compile-flags: -g --crate-type=rlib -Zdwarf-version=4
pub fn check_is_even(number: &u64) -> bool {
number % 2 == 0
}

View file

@ -0,0 +1,19 @@
// This test ensures that if LTO occurs between crates with different DWARF versions, we
// will choose the highest DWARF version for the final binary. This matches Clang's behavior.
//@ only-linux
//@ aux-build:dwarf-mixed-versions-lto-aux.rs
//@ compile-flags: -C lto -g -Zdwarf-version=5
//@ assembly-output: emit-asm
//@ no-prefer-dynamic
extern crate dwarf_mixed_versions_lto_aux;
fn main() {
dwarf_mixed_versions_lto_aux::check_is_even(&0);
}
// CHECK: .section .debug_info
// CHECK-NOT: {{\.(short|hword)}} 2
// CHECK-NOT: {{\.(short|hword)}} 4
// CHECK: {{\.(short|hword)}} 5

View file

@ -0,0 +1,5 @@
//@ compile-flags: -g --crate-type=rlib -Zdwarf-version=4
pub fn say_hi() {
println!("hello there")
}

View file

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

View file

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