Skip to content

Commit 3db1c06

Browse files
committed
Build C code with LTO when LTO is enabled for rust code
1 parent daa18b7 commit 3db1c06

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/bootstrap/src/utils/cc_detect.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use std::collections::HashSet;
2525
use std::iter;
2626
use std::path::{Path, PathBuf};
2727

28-
use crate::core::config::TargetSelection;
28+
use crate::core::config::{RustcLto, TargetSelection};
2929
use crate::utils::exec::{BootstrapCommand, command};
3030
use crate::{Build, CLang, GitRepo};
3131

@@ -53,6 +53,15 @@ fn new_cc_build(build: &Build, target: TargetSelection) -> cc::Build {
5353
}
5454
}
5555
}
56+
match build.config.rust_lto {
57+
RustcLto::Off | RustcLto::ThinLocal => {}
58+
RustcLto::Thin => {
59+
cfg.flag_if_supported("-flto=thin");
60+
}
61+
RustcLto::Fat => {
62+
cfg.flag_if_supported("-flto=full");
63+
}
64+
}
5665
cfg
5766
}
5867

0 commit comments

Comments
 (0)