Add -Z combine_cgu flag

Introduce a compiler option to let rustc combines all regular CGUs into
a single one at the end of compilation.

Part of Issue #64191
This commit is contained in:
Victor Ding
2020-09-09 14:51:16 +10:00
parent e82584a77d
commit c81b43d8ac
6 changed files with 90 additions and 15 deletions

View File

@@ -346,14 +346,14 @@ fn fat_lto(
Ok(LtoModuleCodegen::Fat { module: Some(module), _serialized_bitcode: serialized_bitcode })
}
struct Linker<'a>(&'a mut llvm::Linker<'a>);
crate struct Linker<'a>(&'a mut llvm::Linker<'a>);
impl Linker<'a> {
fn new(llmod: &'a llvm::Module) -> Self {
crate fn new(llmod: &'a llvm::Module) -> Self {
unsafe { Linker(llvm::LLVMRustLinkerNew(llmod)) }
}
fn add(&mut self, bytecode: &[u8]) -> Result<(), ()> {
crate fn add(&mut self, bytecode: &[u8]) -> Result<(), ()> {
unsafe {
if llvm::LLVMRustLinkerAdd(
self.0,