Provide a way of accessing the ThinLTO module import map in rustc.
This commit is contained in:
parent
1114ab684f
commit
2e587df6e2
2 changed files with 36 additions and 0 deletions
|
@ -363,6 +363,10 @@ extern { pub type ThinLTOData; }
|
||||||
/// LLVMRustThinLTOBuffer
|
/// LLVMRustThinLTOBuffer
|
||||||
extern { pub type ThinLTOBuffer; }
|
extern { pub type ThinLTOBuffer; }
|
||||||
|
|
||||||
|
// LLVMRustModuleNameCallback
|
||||||
|
pub type ThinLTOModuleNameCallback =
|
||||||
|
unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
|
||||||
|
|
||||||
/// LLVMRustThinLTOModule
|
/// LLVMRustThinLTOModule
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct ThinLTOModule {
|
pub struct ThinLTOModule {
|
||||||
|
@ -1622,6 +1626,11 @@ extern "C" {
|
||||||
Data: &ThinLTOData,
|
Data: &ThinLTOData,
|
||||||
Module: &Module,
|
Module: &Module,
|
||||||
) -> bool;
|
) -> bool;
|
||||||
|
pub fn LLVMRustGetThinLTOModuleImports(
|
||||||
|
Data: *const ThinLTOData,
|
||||||
|
ModuleNameCallback: ThinLTOModuleNameCallback,
|
||||||
|
CallbackPayload: *mut c_void,
|
||||||
|
);
|
||||||
pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
|
pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
|
||||||
pub fn LLVMRustParseBitcodeForThinLTO(
|
pub fn LLVMRustParseBitcodeForThinLTO(
|
||||||
Context: &Context,
|
Context: &Context,
|
||||||
|
|
|
@ -1123,6 +1123,28 @@ LLVMRustPrepareThinLTOImport(const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" typedef void (*LLVMRustModuleNameCallback)(void*, // payload
|
||||||
|
const char*, // importing module name
|
||||||
|
const char*); // imported module name
|
||||||
|
|
||||||
|
// Calls `module_name_callback` for each module import done by ThinLTO.
|
||||||
|
// The callback is provided with regular null-terminated C strings.
|
||||||
|
extern "C" void
|
||||||
|
LLVMRustGetThinLTOModuleImports(const LLVMRustThinLTOData *data,
|
||||||
|
LLVMRustModuleNameCallback module_name_callback,
|
||||||
|
void* callback_payload) {
|
||||||
|
for (const auto& importing_module : data->ImportLists) {
|
||||||
|
const std::string importing_module_id = importing_module.getKey().str();
|
||||||
|
const auto& imports = importing_module.getValue();
|
||||||
|
for (const auto& imported_module : imports) {
|
||||||
|
const std::string imported_module_id = imported_module.getKey().str();
|
||||||
|
module_name_callback(callback_payload,
|
||||||
|
importing_module_id.c_str(),
|
||||||
|
imported_module_id.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This struct and various functions are sort of a hack right now, but the
|
// This struct and various functions are sort of a hack right now, but the
|
||||||
// problem is that we've got in-memory LLVM modules after we generate and
|
// problem is that we've got in-memory LLVM modules after we generate and
|
||||||
// optimize all codegen-units for one compilation in rustc. To be compatible
|
// optimize all codegen-units for one compilation in rustc. To be compatible
|
||||||
|
@ -1288,6 +1310,11 @@ LLVMRustPrepareThinLTOImport(const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
|
||||||
report_fatal_error("ThinLTO not available");
|
report_fatal_error("ThinLTO not available");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" LLVMRustThinLTOModuleImports
|
||||||
|
LLVMRustGetLLVMRustThinLTOModuleImports(const LLVMRustThinLTOData *Data) {
|
||||||
|
report_fatal_error("ThinLTO not available");
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
LLVMRustFreeThinLTOData(LLVMRustThinLTOData *Data) {
|
LLVMRustFreeThinLTOData(LLVMRustThinLTOData *Data) {
|
||||||
report_fatal_error("ThinLTO not available");
|
report_fatal_error("ThinLTO not available");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue