@@ -1123,6 +1123,28 @@ LLVMRustPrepareThinLTOImport(const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
1123
1123
return true ;
1124
1124
}
1125
1125
1126
+ extern " C" typedef void (*LLVMRustModuleNameCallback)(void *, // payload
1127
+ const char *, // importing module name
1128
+ const char *); // imported module name
1129
+
1130
+ // Calls `module_name_callback` for each module import done by ThinLTO.
1131
+ // The callback is provided with regular null-terminated C strings.
1132
+ extern " C" void
1133
+ LLVMRustGetThinLTOModuleImports (const LLVMRustThinLTOData *data,
1134
+ LLVMRustModuleNameCallback module_name_callback,
1135
+ void * callback_payload) {
1136
+ for (const auto & importing_module : data->ImportLists ) {
1137
+ const std::string importing_module_id = importing_module.getKey ().str ();
1138
+ const auto & imports = importing_module.getValue ();
1139
+ for (const auto & imported_module : imports) {
1140
+ const std::string imported_module_id = imported_module.getKey ().str ();
1141
+ module_name_callback (callback_payload,
1142
+ importing_module_id.c_str (),
1143
+ imported_module_id.c_str ());
1144
+ }
1145
+ }
1146
+ }
1147
+
1126
1148
// This struct and various functions are sort of a hack right now, but the
1127
1149
// problem is that we've got in-memory LLVM modules after we generate and
1128
1150
// optimize all codegen-units for one compilation in rustc. To be compatible
@@ -1288,6 +1310,11 @@ LLVMRustPrepareThinLTOImport(const LLVMRustThinLTOData *Data, LLVMModuleRef M) {
1288
1310
report_fatal_error (" ThinLTO not available" );
1289
1311
}
1290
1312
1313
+ extern " C" LLVMRustThinLTOModuleImports
1314
+ LLVMRustGetLLVMRustThinLTOModuleImports (const LLVMRustThinLTOData *Data) {
1315
+ report_fatal_error (" ThinLTO not available" );
1316
+ }
1317
+
1291
1318
extern " C" void
1292
1319
LLVMRustFreeThinLTOData (LLVMRustThinLTOData *Data) {
1293
1320
report_fatal_error (" ThinLTO not available" );
0 commit comments