Remove some dead code around import library generation
This was missed when replacing the usage of LLVM for generating import libraries.
This commit is contained in:
parent
8a1f8039a7
commit
c02c311d84
2 changed files with 0 additions and 78 deletions
|
@ -56,25 +56,6 @@ pub enum LLVMRustResult {
|
||||||
Failure,
|
Failure,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rust version of the C struct with the same name in rustc_llvm/llvm-wrapper/RustWrapper.cpp.
|
|
||||||
#[repr(C)]
|
|
||||||
pub struct LLVMRustCOFFShortExport {
|
|
||||||
pub name: *const c_char,
|
|
||||||
pub ordinal_present: bool,
|
|
||||||
/// value of `ordinal` only important when `ordinal_present` is true
|
|
||||||
pub ordinal: u16,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl LLVMRustCOFFShortExport {
|
|
||||||
pub fn new(name: *const c_char, ordinal: Option<u16>) -> LLVMRustCOFFShortExport {
|
|
||||||
LLVMRustCOFFShortExport {
|
|
||||||
name,
|
|
||||||
ordinal_present: ordinal.is_some(),
|
|
||||||
ordinal: ordinal.unwrap_or(0),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Translation of LLVM's MachineTypes enum, defined in llvm\include\llvm\BinaryFormat\COFF.h.
|
/// Translation of LLVM's MachineTypes enum, defined in llvm\include\llvm\BinaryFormat\COFF.h.
|
||||||
///
|
///
|
||||||
/// We include only architectures supported on Windows.
|
/// We include only architectures supported on Windows.
|
||||||
|
@ -2347,15 +2328,6 @@ unsafe extern "C" {
|
||||||
) -> &'a mut RustArchiveMember<'a>;
|
) -> &'a mut RustArchiveMember<'a>;
|
||||||
pub fn LLVMRustArchiveMemberFree<'a>(Member: &'a mut RustArchiveMember<'a>);
|
pub fn LLVMRustArchiveMemberFree<'a>(Member: &'a mut RustArchiveMember<'a>);
|
||||||
|
|
||||||
pub fn LLVMRustWriteImportLibrary(
|
|
||||||
ImportName: *const c_char,
|
|
||||||
Path: *const c_char,
|
|
||||||
Exports: *const LLVMRustCOFFShortExport,
|
|
||||||
NumExports: usize,
|
|
||||||
Machine: u16,
|
|
||||||
MinGW: bool,
|
|
||||||
) -> LLVMRustResult;
|
|
||||||
|
|
||||||
pub fn LLVMRustSetDataLayoutFromTargetMachine<'a>(M: &'a Module, TM: &'a TargetMachine);
|
pub fn LLVMRustSetDataLayoutFromTargetMachine<'a>(M: &'a Module, TM: &'a TargetMachine);
|
||||||
|
|
||||||
pub fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock);
|
pub fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock);
|
||||||
|
|
|
@ -1796,56 +1796,6 @@ extern "C" LLVMValueRef LLVMRustBuildMaxNum(LLVMBuilderRef B, LLVMValueRef LHS,
|
||||||
return wrap(unwrap(B)->CreateMaxNum(unwrap(LHS), unwrap(RHS)));
|
return wrap(unwrap(B)->CreateMaxNum(unwrap(LHS), unwrap(RHS)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This struct contains all necessary info about a symbol exported from a DLL.
|
|
||||||
struct LLVMRustCOFFShortExport {
|
|
||||||
const char *name;
|
|
||||||
bool ordinal_present;
|
|
||||||
// The value of `ordinal` is only meaningful if `ordinal_present` is true.
|
|
||||||
uint16_t ordinal;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Machine must be a COFF machine type, as defined in PE specs.
|
|
||||||
extern "C" LLVMRustResult
|
|
||||||
LLVMRustWriteImportLibrary(const char *ImportName, const char *Path,
|
|
||||||
const LLVMRustCOFFShortExport *Exports,
|
|
||||||
size_t NumExports, uint16_t Machine, bool MinGW) {
|
|
||||||
std::vector<llvm::object::COFFShortExport> ConvertedExports;
|
|
||||||
ConvertedExports.reserve(NumExports);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < NumExports; ++i) {
|
|
||||||
bool ordinal_present = Exports[i].ordinal_present;
|
|
||||||
uint16_t ordinal = ordinal_present ? Exports[i].ordinal : 0;
|
|
||||||
ConvertedExports.push_back(llvm::object::COFFShortExport{
|
|
||||||
Exports[i].name, // Name
|
|
||||||
std::string{}, // ExtName
|
|
||||||
std::string{}, // SymbolName
|
|
||||||
std::string{}, // AliasTarget
|
|
||||||
#if LLVM_VERSION_GE(19, 0)
|
|
||||||
std::string{}, // ExportAs
|
|
||||||
#endif
|
|
||||||
ordinal, // Ordinal
|
|
||||||
ordinal_present, // Noname
|
|
||||||
false, // Data
|
|
||||||
false, // Private
|
|
||||||
false // Constant
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
auto Error = llvm::object::writeImportLibrary(
|
|
||||||
ImportName, Path, ConvertedExports,
|
|
||||||
static_cast<llvm::COFF::MachineTypes>(Machine), MinGW);
|
|
||||||
if (Error) {
|
|
||||||
std::string errorString;
|
|
||||||
auto stream = llvm::raw_string_ostream(errorString);
|
|
||||||
stream << Error;
|
|
||||||
stream.flush();
|
|
||||||
LLVMRustSetLastError(errorString.c_str());
|
|
||||||
return LLVMRustResult::Failure;
|
|
||||||
} else {
|
|
||||||
return LLVMRustResult::Success;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Transfers ownership of DiagnosticHandler unique_ptr to the caller.
|
// Transfers ownership of DiagnosticHandler unique_ptr to the caller.
|
||||||
extern "C" DiagnosticHandler *
|
extern "C" DiagnosticHandler *
|
||||||
LLVMRustContextGetDiagnosticHandler(LLVMContextRef C) {
|
LLVMRustContextGetDiagnosticHandler(LLVMContextRef C) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue