thin_modules.len() as u32,
symbol_white_list.as_ptr(),
symbol_white_list.len() as u32,
- );
- if data.is_null() {
- let msg = "failed to prepare thin LTO context".to_string();
- return Err(write::llvm_err(&diag_handler, msg))
- }
+ ).ok_or_else(|| {
+ write::llvm_err(&diag_handler, "failed to prepare thin LTO context".to_string())
+ })?;
+
let data = ThinData(data);
info!("thin LTO data created");
timeline.record("data");
module_names: Vec<CString>,
}
-struct ThinData(*mut llvm::ThinLTOData);
+struct ThinData(&'static mut llvm::ThinLTOData);
unsafe impl Send for ThinData {}
unsafe impl Sync for ThinData {}
impl Drop for ThinData {
fn drop(&mut self) {
unsafe {
- llvm::LLVMRustFreeThinLTOData(self.0);
+ llvm::LLVMRustFreeThinLTOData(&mut *(self.0 as *mut _));
}
}
}
NumModules: c_uint,
PreservedSymbols: *const *const c_char,
PreservedSymbolsLen: c_uint,
- ) -> *mut ThinLTOData;
+ ) -> Option<&'static mut ThinLTOData>;
pub fn LLVMRustPrepareThinLTORename(
- Data: *const ThinLTOData,
+ Data: &ThinLTOData,
Module: &Module,
) -> bool;
pub fn LLVMRustPrepareThinLTOResolveWeak(
- Data: *const ThinLTOData,
+ Data: &ThinLTOData,
Module: &Module,
) -> bool;
pub fn LLVMRustPrepareThinLTOInternalize(
- Data: *const ThinLTOData,
+ Data: &ThinLTOData,
Module: &Module,
) -> bool;
pub fn LLVMRustPrepareThinLTOImport(
- Data: *const ThinLTOData,
+ Data: &ThinLTOData,
Module: &Module,
) -> bool;
- pub fn LLVMRustFreeThinLTOData(Data: *mut ThinLTOData);
+ pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
pub fn LLVMRustParseBitcodeForThinLTO(
Context: &Context,
Data: *const u8,