Skip to content

Commit dd9b4de

Browse files
authored
Rollup merge of #134567 - bjorn3:remove_unused_code, r=compiler-errors
Remove some dead code around import library generation This was missed when replacing the usage of LLVM for generating import libraries. `@bors` rollup
2 parents a1c90e7 + c02c311 commit dd9b4de

File tree

2 files changed

+0
-78
lines changed

2 files changed

+0
-78
lines changed

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

-28
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,6 @@ pub enum LLVMRustResult {
5656
Failure,
5757
}
5858

59-
// Rust version of the C struct with the same name in rustc_llvm/llvm-wrapper/RustWrapper.cpp.
60-
#[repr(C)]
61-
pub struct LLVMRustCOFFShortExport {
62-
pub name: *const c_char,
63-
pub ordinal_present: bool,
64-
/// value of `ordinal` only important when `ordinal_present` is true
65-
pub ordinal: u16,
66-
}
67-
68-
impl LLVMRustCOFFShortExport {
69-
pub fn new(name: *const c_char, ordinal: Option<u16>) -> LLVMRustCOFFShortExport {
70-
LLVMRustCOFFShortExport {
71-
name,
72-
ordinal_present: ordinal.is_some(),
73-
ordinal: ordinal.unwrap_or(0),
74-
}
75-
}
76-
}
77-
7859
/// Translation of LLVM's MachineTypes enum, defined in llvm\include\llvm\BinaryFormat\COFF.h.
7960
///
8061
/// We include only architectures supported on Windows.
@@ -2347,15 +2328,6 @@ unsafe extern "C" {
23472328
) -> &'a mut RustArchiveMember<'a>;
23482329
pub fn LLVMRustArchiveMemberFree<'a>(Member: &'a mut RustArchiveMember<'a>);
23492330

2350-
pub fn LLVMRustWriteImportLibrary(
2351-
ImportName: *const c_char,
2352-
Path: *const c_char,
2353-
Exports: *const LLVMRustCOFFShortExport,
2354-
NumExports: usize,
2355-
Machine: u16,
2356-
MinGW: bool,
2357-
) -> LLVMRustResult;
2358-
23592331
pub fn LLVMRustSetDataLayoutFromTargetMachine<'a>(M: &'a Module, TM: &'a TargetMachine);
23602332

23612333
pub fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock);

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

-50
Original file line numberDiff line numberDiff line change
@@ -1796,56 +1796,6 @@ extern "C" LLVMValueRef LLVMRustBuildMaxNum(LLVMBuilderRef B, LLVMValueRef LHS,
17961796
return wrap(unwrap(B)->CreateMaxNum(unwrap(LHS), unwrap(RHS)));
17971797
}
17981798

1799-
// This struct contains all necessary info about a symbol exported from a DLL.
1800-
struct LLVMRustCOFFShortExport {
1801-
const char *name;
1802-
bool ordinal_present;
1803-
// The value of `ordinal` is only meaningful if `ordinal_present` is true.
1804-
uint16_t ordinal;
1805-
};
1806-
1807-
// Machine must be a COFF machine type, as defined in PE specs.
1808-
extern "C" LLVMRustResult
1809-
LLVMRustWriteImportLibrary(const char *ImportName, const char *Path,
1810-
const LLVMRustCOFFShortExport *Exports,
1811-
size_t NumExports, uint16_t Machine, bool MinGW) {
1812-
std::vector<llvm::object::COFFShortExport> ConvertedExports;
1813-
ConvertedExports.reserve(NumExports);
1814-
1815-
for (size_t i = 0; i < NumExports; ++i) {
1816-
bool ordinal_present = Exports[i].ordinal_present;
1817-
uint16_t ordinal = ordinal_present ? Exports[i].ordinal : 0;
1818-
ConvertedExports.push_back(llvm::object::COFFShortExport{
1819-
Exports[i].name, // Name
1820-
std::string{}, // ExtName
1821-
std::string{}, // SymbolName
1822-
std::string{}, // AliasTarget
1823-
#if LLVM_VERSION_GE(19, 0)
1824-
std::string{}, // ExportAs
1825-
#endif
1826-
ordinal, // Ordinal
1827-
ordinal_present, // Noname
1828-
false, // Data
1829-
false, // Private
1830-
false // Constant
1831-
});
1832-
}
1833-
1834-
auto Error = llvm::object::writeImportLibrary(
1835-
ImportName, Path, ConvertedExports,
1836-
static_cast<llvm::COFF::MachineTypes>(Machine), MinGW);
1837-
if (Error) {
1838-
std::string errorString;
1839-
auto stream = llvm::raw_string_ostream(errorString);
1840-
stream << Error;
1841-
stream.flush();
1842-
LLVMRustSetLastError(errorString.c_str());
1843-
return LLVMRustResult::Failure;
1844-
} else {
1845-
return LLVMRustResult::Success;
1846-
}
1847-
}
1848-
18491799
// Transfers ownership of DiagnosticHandler unique_ptr to the caller.
18501800
extern "C" DiagnosticHandler *
18511801
LLVMRustContextGetDiagnosticHandler(LLVMContextRef C) {

0 commit comments

Comments
 (0)