forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#39157 - michaelwoerister:debug-lto, r=alexc…
…richton Add regression test for debuginfo + LTO Fixes rust-lang#25270, which cannot be reproduced with the current nightly version of the compiler anymore (due to various fixes to debuginfo generation in the past). Should we run into the "possible ODR violation" again, the test added by this PR can be extend with the new case. r? @alexcrichton
- Loading branch information
Showing
4 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// compile-flags: -g --crate-type=rlib | ||
|
||
pub struct StructWithLifetime<'a>(&'a i32); | ||
pub fn mk_struct_with_lt<'a>(x: &'a i32) -> StructWithLifetime<'a> { | ||
StructWithLifetime(x) | ||
} | ||
|
||
pub struct RegularStruct(u32); | ||
pub fn mk_regular_struct(x: u32) -> RegularStruct { | ||
RegularStruct(x) | ||
} | ||
|
||
pub fn take_fn(f: fn(i32) -> i32, x: i32) -> i32 { | ||
f(x) | ||
} | ||
|
||
pub fn with_closure(x: i32) -> i32 { | ||
let closure = |i| { x + i }; | ||
|
||
closure(1) + closure(2) | ||
} | ||
|
||
pub fn generic_fn<T>(x: T) -> (T, u32) { | ||
(x, 1) | ||
} | ||
|
||
pub fn user_of_generic_fn(x: f32) -> (f32, u32) { | ||
generic_fn(x) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// This test case makes sure that we don't run into LLVM's dreaded | ||
// "possible ODR violation" assertion when compiling with LTO + Debuginfo. | ||
// It covers cases that have traditionally been prone to cause this error. | ||
// If new cases emerge, add them to this file. | ||
|
||
// aux-build:debuginfo-lto-aux.rs | ||
// compile-flags: -C lto -g | ||
// no-prefer-dynamic | ||
|
||
extern crate debuginfo_lto_aux; | ||
|
||
fn some_fn(x: i32) -> i32 { | ||
x + 1 | ||
} | ||
|
||
fn main() { | ||
let i = 0; | ||
let _ = debuginfo_lto_aux::mk_struct_with_lt(&i); | ||
let _ = debuginfo_lto_aux::mk_regular_struct(1); | ||
let _ = debuginfo_lto_aux::take_fn(some_fn, 1); | ||
let _ = debuginfo_lto_aux::with_closure(22); | ||
let _ = debuginfo_lto_aux::generic_fn(0f32); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters