Skip to content

Commit 9b8094c

Browse files
jieyouxukhuey
authored andcommitted
tests: add regression test for #135332
Issue: #135332
1 parent 341f603 commit 9b8094c

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
other::big_function();
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
proc::declare_big_function!();
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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` and fat LTO, 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+
//@ ignore-cross-compile
11+
//@ needs-dynamic-linking
12+
//@ only-nightly: requires unstable rustc flag
13+
14+
#![deny(warnings)]
15+
16+
use run_make_support::{dynamic_lib_name, rfs, rust_lib_name, rustc};
17+
18+
// Generate a program that has a *lot*
19+
fn generate_program(n: u32) -> String {
20+
let mut program = String::from("pub type BigType = Vec<Vec<String>>;\n\n");
21+
program.push_str("pub fn big_function() -> BigType {\n");
22+
program.push_str(" vec![\n");
23+
for i in 1..=n {
24+
program.push_str(&format!("vec![\"string{}\".to_owned()],\n", i));
25+
}
26+
program.push_str(" ]\n");
27+
program.push_str("}\n");
28+
program
29+
}
30+
31+
fn main() {
32+
// The reported threshold is around 1366, but let's bump it to around 1500 to be less sensitive.
33+
rfs::write("generated.rs", generate_program(1500));
34+
35+
rustc()
36+
.input("proc.rs")
37+
.crate_type("proc-macro")
38+
.edition("2021")
39+
.arg("-Cdebuginfo=line-tables-only")
40+
.run();
41+
rustc()
42+
.extern_("proc", dynamic_lib_name("proc"))
43+
.input("other.rs")
44+
.crate_type("rlib")
45+
.edition("2021")
46+
.opt_level("3")
47+
.arg("-Cdebuginfo=line-tables-only")
48+
.run();
49+
rustc()
50+
.extern_("other", rust_lib_name("other"))
51+
.input("main.rs")
52+
.edition("2021")
53+
.opt_level("3")
54+
.arg("-Cdebuginfo=line-tables-only")
55+
.arg("-Clto=fat")
56+
.arg("-Zverify-llvm-ir")
57+
.run();
58+
}

0 commit comments

Comments
 (0)