Skip to content

Commit 374368d

Browse files
committed
test(build-std): Add test for LTO
1 parent 5c03433 commit 374368d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/build-std/main.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,37 @@ fn basic() {
187187
assert_eq!(p.glob(deps_dir.join("*.dylib")).count(), 0);
188188
}
189189

190+
#[cargo_test(build_std_real)]
191+
fn lto() {
192+
// Checks that `-Zbuild-std` can work with `lto = "thin"`.
193+
// This regression is from https://github.com/rust-lang/rust/issues/146109.
194+
let p = project()
195+
.file(
196+
"Cargo.toml",
197+
r#"
198+
[package]
199+
name = "foo"
200+
version = "0.1.0"
201+
edition = "2021"
202+
203+
[profile.dev]
204+
lto = "thin"
205+
"#,
206+
)
207+
.file(
208+
"src/main.rs",
209+
r#"
210+
fn main() {}
211+
"#,
212+
)
213+
.build();
214+
215+
p.cargo("build")
216+
.build_std_arg("std")
217+
.env("RUSTFLAGS", "-C linker-features=-lld")
218+
.run();
219+
}
220+
190221
#[cargo_test(build_std_real)]
191222
fn host_proc_macro() {
192223
let p = project()

0 commit comments

Comments
 (0)