From 847c8520b14e3ae9aec26a33f70750a071d3f18d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 11 May 2015 21:07:38 -0700 Subject: [PATCH] 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. --- src/librustc_llvm/lib.rs | 2 +- src/librustc_trans/trans/debuginfo/mod.rs | 2 +- src/rustllvm/RustWrapper.cpp | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index 54031e4b04d..3e575785d27 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -1771,7 +1771,7 @@ extern { Dialect: c_uint) -> ValueRef; - pub static LLVMRustDebugMetadataVersion: u32; + pub fn LLVMRustDebugMetadataVersion() -> u32; pub fn LLVMRustAddModuleFlag(M: ModuleRef, name: *const c_char, diff --git a/src/librustc_trans/trans/debuginfo/mod.rs b/src/librustc_trans/trans/debuginfo/mod.rs index e4312b669ad..4e5407016ba 100644 --- a/src/librustc_trans/trans/debuginfo/mod.rs +++ b/src/librustc_trans/trans/debuginfo/mod.rs @@ -193,7 +193,7 @@ pub fn finalize(cx: &CrateContext) { // Prevent bitcode readers from deleting the debug info. let ptr = "Debug Info Version\0".as_ptr(); llvm::LLVMRustAddModuleFlag(cx.llmod(), ptr as *const _, - llvm::LLVMRustDebugMetadataVersion); + llvm::LLVMRustDebugMetadataVersion()); }; } diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 5a2d1ec4207..66db7326d21 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -233,7 +233,9 @@ DIT unwrapDI(LLVMMetadataRef ref) { return DIT(ref ? unwrap(ref) : NULL); } -extern "C" const uint32_t LLVMRustDebugMetadataVersion = DEBUG_METADATA_VERSION; +extern "C" const uint32_t LLVMRustDebugMetadataVersion() { + return DEBUG_METADATA_VERSION; +} extern "C" void LLVMRustAddModuleFlag(LLVMModuleRef M, const char *name,