Skip to content

Commit de6bd26

Browse files
committed
tests: add regression test for #rust-lang#135332
1 parent 8e59cf9 commit de6bd26

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
other::big_function();
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
proc::declare_big_function!();
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extern crate proc_macro;
2+
use proc_macro::TokenStream;
3+
4+
#[proc_macro]
5+
pub fn declare_big_function(_input: TokenStream) -> TokenStream {
6+
include_str!("./generated.rs").parse().unwrap()
7+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//! Regression test for <https://github.com/rust-lang/rust/issues/135332>.
2+
//!
3+
//! We can't simply drop debuginfo location spans when LLVM's location discriminator value limit is
4+
//! reached. Otherwise, with `-Z verify-llvm-ir`, LLVM will report a broken module for
5+
//!
6+
//! ```text
7+
//! inlinable function call in a function with debug info must have a !dbg location
8+
//! ```
9+
10+
//@ only-nightly: requires unstable rustc flag
11+
12+
#![deny(warnings)]
13+
14+
use run_make_support::{dynamic_lib_name, rfs, rust_lib_name, rustc};
15+
16+
// Generate a program that has a *lot*
17+
fn generate_program(n: u32) -> String {
18+
let mut program = String::from("pub type BigType = Vec<Vec<String>>;\n\n");
19+
program.push_str("pub fn big_function() -> BigType {\n");
20+
program.push_str(" vec![\n");
21+
for i in 1..=n {
22+
program.push_str(&format!("vec![\"string{}\".to_owned()],\n", i));
23+
}
24+
program.push_str(" ]\n");
25+
program.push_str("}\n");
26+
program
27+
}
28+
29+
fn main() {
30+
// The reported threshold is around 1366, but let's bump it to around 1500 to be less sensitive.
31+
rfs::write("generated.rs", generate_program(1500));
32+
33+
rustc()
34+
.input("proc.rs")
35+
.crate_type("proc-macro")
36+
.edition("2021")
37+
.opt_level("3")
38+
.arg("-Cdebuginfo=line-tables-only")
39+
.arg("-Clto=fat")
40+
.arg("-Zdylib-lto")
41+
.arg("-Zverify-llvm-ir")
42+
.run();
43+
rustc()
44+
.extern_("proc", dynamic_lib_name("proc"))
45+
.input("other.rs")
46+
.crate_type("rlib")
47+
.edition("2021")
48+
.opt_level("3")
49+
.arg("-Cdebuginfo=line-tables-only")
50+
.arg("-Clto=fat")
51+
.arg("-Zverify-llvm-ir")
52+
.run();
53+
rustc()
54+
.extern_("other", rust_lib_name("other"))
55+
.input("main.rs")
56+
.edition("2021")
57+
.opt_level("3")
58+
.arg("-Cdebuginfo=line-tables-only")
59+
.arg("-Clto=fat")
60+
.arg("-Zverify-llvm-ir")
61+
.run();
62+
}

0 commit comments

Comments
 (0)