Skip to content

Commit 847c852

Browse files
committed
rustc_llvm: Don't export constants across dlls
For imports of constants across DLLs to work on Windows it *requires* that the import be marked with `dllimport` (unlike functions where the marker is optional, but strongly recommended). This currently isn't working for importing FFI constants across boundaries, however, so the one constant exported from `rustc_llvm.dll` is now a function to be called instead.
1 parent b538189 commit 847c852

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/librustc_llvm/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1771,7 +1771,7 @@ extern {
17711771
Dialect: c_uint)
17721772
-> ValueRef;
17731773

1774-
pub static LLVMRustDebugMetadataVersion: u32;
1774+
pub fn LLVMRustDebugMetadataVersion() -> u32;
17751775

17761776
pub fn LLVMRustAddModuleFlag(M: ModuleRef,
17771777
name: *const c_char,

src/librustc_trans/trans/debuginfo/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ pub fn finalize(cx: &CrateContext) {
193193
// Prevent bitcode readers from deleting the debug info.
194194
let ptr = "Debug Info Version\0".as_ptr();
195195
llvm::LLVMRustAddModuleFlag(cx.llmod(), ptr as *const _,
196-
llvm::LLVMRustDebugMetadataVersion);
196+
llvm::LLVMRustDebugMetadataVersion());
197197
};
198198
}
199199

src/rustllvm/RustWrapper.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,9 @@ DIT unwrapDI(LLVMMetadataRef ref) {
233233
return DIT(ref ? unwrap<MDNode>(ref) : NULL);
234234
}
235235

236-
extern "C" const uint32_t LLVMRustDebugMetadataVersion = DEBUG_METADATA_VERSION;
236+
extern "C" const uint32_t LLVMRustDebugMetadataVersion() {
237+
return DEBUG_METADATA_VERSION;
238+
}
237239

238240
extern "C" void LLVMRustAddModuleFlag(LLVMModuleRef M,
239241
const char *name,

0 commit comments

Comments
 (0)