rustc: add ability to output regular LTO bitcode modules

Adding the option to control from rustc CLI
if the resulted ".o" bitcode module files are with
thinLTO info or regular LTO info.

Allows using "-lto-embed-bitcode=optimized" during linkage
correctly.

Signed-off-by: Ziv Dunkelman <ziv.dunkelman@nextsilicon.com>
This commit is contained in:
Ziv Dunkelman
2022-06-08 17:30:16 +03:00
parent 0ed9c64c3e
commit 724c91234d
10 changed files with 32 additions and 7 deletions

View File

@@ -199,7 +199,7 @@ pub(crate) fn run_thin(
pub(crate) fn prepare_thin(module: ModuleCodegen<ModuleLlvm>) -> (String, ThinBuffer) {
let name = module.name.clone();
let buffer = ThinBuffer::new(module.module_llvm.llmod());
let buffer = ThinBuffer::new(module.module_llvm.llmod(), true);
(name, buffer)
}
@@ -709,9 +709,9 @@ unsafe impl Send for ThinBuffer {}
unsafe impl Sync for ThinBuffer {}
impl ThinBuffer {
pub fn new(m: &llvm::Module) -> ThinBuffer {
pub fn new(m: &llvm::Module, is_thin: bool) -> ThinBuffer {
unsafe {
let buffer = llvm::LLVMRustThinLTOBufferCreate(m);
let buffer = llvm::LLVMRustThinLTOBufferCreate(m, is_thin);
ThinBuffer(buffer)
}
}