Work around unstable linkage attribute

This commit is contained in:
Mark McCaskey
2020-02-26 18:32:40 -08:00
parent a089cf5a0c
commit dbb2ececf8
4 changed files with 30 additions and 4 deletions

View File

@ -97,6 +97,7 @@ backend-llvm = [
"wasmer-llvm-backend", "wasmer-llvm-backend",
"wasmer-runtime/llvm", "wasmer-runtime/llvm",
"wasmer-middleware-common-tests/llvm", "wasmer-middleware-common-tests/llvm",
"wasmer-runtime-core/generate-debug-information-no-export-symbols",
] ]
backend-singlepass = [ backend-singlepass = [
"wasmer-singlepass-backend", "wasmer-singlepass-backend",

View File

@ -56,3 +56,6 @@ managed = []
deterministic-execution = ["wasmparser/deterministic"] deterministic-execution = ["wasmparser/deterministic"]
# generate debug information from Wasm DWARF for use with the GDB JIT interface # generate debug information from Wasm DWARF for use with the GDB JIT interface
generate-debug-information = ["wasm-debug"] generate-debug-information = ["wasm-debug"]
# don't export symbols related to the GDB JIT interafce, LLVM or some other native
# code will be providing them
generate-debug-information-no-export-symbols = ["generate-debug-information", "wasm-debug"]

View File

@ -15,7 +15,7 @@ use std::sync::{Arc, Mutex};
// Implementation of this function is derived from wasmtime and is licensed under // Implementation of this function is derived from wasmtime and is licensed under
// the Apache 2.0 license. See ATTRIBUTIONS.md for full license and more // the Apache 2.0 license. See ATTRIBUTIONS.md for full license and more
// information. // information.
#[linkage = "linkonce"] #[cfg(not(feature = "generate-debug-information-no-export-symbols"))]
#[no_mangle] #[no_mangle]
#[inline(never)] #[inline(never)]
extern "C" fn __jit_debug_register_code() { extern "C" fn __jit_debug_register_code() {
@ -81,7 +81,7 @@ struct JitDebugDescriptor {
/// The data is in the form of a doubly linked list. This global variable acts /// The data is in the form of a doubly linked list. This global variable acts
/// as a head node with extra information about the operation that we want the /// as a head node with extra information about the operation that we want the
/// debugger to perform. /// debugger to perform.
#[linkage = "linkonce"] #[cfg(not(feature = "generate-debug-information-no-export-symbols"))]
#[no_mangle] #[no_mangle]
#[allow(non_upper_case_globals)] #[allow(non_upper_case_globals)]
static mut __jit_debug_descriptor: JitDebugDescriptor = JitDebugDescriptor { static mut __jit_debug_descriptor: JitDebugDescriptor = JitDebugDescriptor {
@ -91,6 +91,12 @@ static mut __jit_debug_descriptor: JitDebugDescriptor = JitDebugDescriptor {
first_entry: ptr::null_mut(), first_entry: ptr::null_mut(),
}; };
#[cfg(feature = "generate-debug-information-no-export-symbols")]
extern "C" {
static mut __jit_debug_descriptor: JitDebugDescriptor;
fn __jit_debug_register_code();
}
lazy_static! { lazy_static! {
/// Global lock on [`__jit_debug_descriptor`]. Acquire this lock when /// Global lock on [`__jit_debug_descriptor`]. Acquire this lock when
/// reading or writing to the global variable. This includes calls to /// reading or writing to the global variable. This includes calls to
@ -173,12 +179,28 @@ impl Drop for JitCodeDebugInfoEntryHandleInner {
} }
/// Manager of debug info registered with the debugger. /// Manager of debug info registered with the debugger.
#[derive(Debug, Clone, Default)] #[derive(Debug, Clone)]
pub(crate) struct JitCodeDebugInfoManager { pub(crate) struct JitCodeDebugInfoManager {
inner: Vec<JitCodeDebugInfoEntryHandle>, inner: Vec<JitCodeDebugInfoEntryHandle>,
} }
impl Default for JitCodeDebugInfoManager {
fn default() -> Self {
Self::new()
}
}
impl JitCodeDebugInfoManager { impl JitCodeDebugInfoManager {
pub(crate) fn new() -> Self {
unsafe {
// ensure we set the version, even if externally linked
__jit_debug_descriptor.version = 1;
}
Self {
inner: vec![],
}
}
/// Register debug info relating to JIT code with the debugger. /// Register debug info relating to JIT code with the debugger.
pub(crate) fn register_new_jit_code_entry( pub(crate) fn register_new_jit_code_entry(
&mut self, &mut self,

View File

@ -99,7 +99,7 @@ pub fn read_module<
generate_debug_info: compiler_config.should_generate_debug_info(), generate_debug_info: compiler_config.should_generate_debug_info(),
#[cfg(feature = "generate-debug-information")] #[cfg(feature = "generate-debug-information")]
debug_info_manager: Default::default(), debug_info_manager: crate::jit_debug::JitCodeDebugInfoManager::new(),
})); }));
let mut parser = wasmparser::ValidatingParser::new( let mut parser = wasmparser::ValidatingParser::new(