Skip to content

Commit 1439412

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

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-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: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
//@ 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+
.opt_level("3")
40+
.arg("-Cdebuginfo=line-tables-only")
41+
.arg("-Clto=fat")
42+
.arg("-Zdylib-lto")
43+
.arg("-Zverify-llvm-ir")
44+
.run();
45+
rustc()
46+
.extern_("proc", dynamic_lib_name("proc"))
47+
.input("other.rs")
48+
.crate_type("rlib")
49+
.edition("2021")
50+
.opt_level("3")
51+
.arg("-Cdebuginfo=line-tables-only")
52+
.arg("-Clto=fat")
53+
.arg("-Zverify-llvm-ir")
54+
.run();
55+
rustc()
56+
.extern_("other", rust_lib_name("other"))
57+
.input("main.rs")
58+
.edition("2021")
59+
.opt_level("3")
60+
.arg("-Cdebuginfo=line-tables-only")
61+
.arg("-Clto=fat")
62+
.arg("-Zverify-llvm-ir")
63+
.run();
64+
}

0 commit comments

Comments
 (0)