Skip to content

Commit dbb2ece

Browse files
author
Mark McCaskey
committed
Work around unstable linkage attribute
1 parent a089cf5 commit dbb2ece

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ backend-llvm = [
9797
"wasmer-llvm-backend",
9898
"wasmer-runtime/llvm",
9999
"wasmer-middleware-common-tests/llvm",
100+
"wasmer-runtime-core/generate-debug-information-no-export-symbols",
100101
]
101102
backend-singlepass = [
102103
"wasmer-singlepass-backend",

lib/runtime-core/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,6 @@ managed = []
5656
deterministic-execution = ["wasmparser/deterministic"]
5757
# generate debug information from Wasm DWARF for use with the GDB JIT interface
5858
generate-debug-information = ["wasm-debug"]
59+
# don't export symbols related to the GDB JIT interafce, LLVM or some other native
60+
# code will be providing them
61+
generate-debug-information-no-export-symbols = ["generate-debug-information", "wasm-debug"]

lib/runtime-core/src/jit_debug.rs

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::sync::{Arc, Mutex};
1515
// Implementation of this function is derived from wasmtime and is licensed under
1616
// the Apache 2.0 license. See ATTRIBUTIONS.md for full license and more
1717
// information.
18-
#[linkage = "linkonce"]
18+
#[cfg(not(feature = "generate-debug-information-no-export-symbols"))]
1919
#[no_mangle]
2020
#[inline(never)]
2121
extern "C" fn __jit_debug_register_code() {
@@ -81,7 +81,7 @@ struct JitDebugDescriptor {
8181
/// The data is in the form of a doubly linked list. This global variable acts
8282
/// as a head node with extra information about the operation that we want the
8383
/// debugger to perform.
84-
#[linkage = "linkonce"]
84+
#[cfg(not(feature = "generate-debug-information-no-export-symbols"))]
8585
#[no_mangle]
8686
#[allow(non_upper_case_globals)]
8787
static mut __jit_debug_descriptor: JitDebugDescriptor = JitDebugDescriptor {
@@ -91,6 +91,12 @@ static mut __jit_debug_descriptor: JitDebugDescriptor = JitDebugDescriptor {
9191
first_entry: ptr::null_mut(),
9292
};
9393

94+
#[cfg(feature = "generate-debug-information-no-export-symbols")]
95+
extern "C" {
96+
static mut __jit_debug_descriptor: JitDebugDescriptor;
97+
fn __jit_debug_register_code();
98+
}
99+
94100
lazy_static! {
95101
/// Global lock on [`__jit_debug_descriptor`]. Acquire this lock when
96102
/// reading or writing to the global variable. This includes calls to
@@ -173,12 +179,28 @@ impl Drop for JitCodeDebugInfoEntryHandleInner {
173179
}
174180

175181
/// Manager of debug info registered with the debugger.
176-
#[derive(Debug, Clone, Default)]
182+
#[derive(Debug, Clone)]
177183
pub(crate) struct JitCodeDebugInfoManager {
178184
inner: Vec<JitCodeDebugInfoEntryHandle>,
179185
}
180186

187+
impl Default for JitCodeDebugInfoManager {
188+
fn default() -> Self {
189+
Self::new()
190+
}
191+
}
192+
181193
impl JitCodeDebugInfoManager {
194+
pub(crate) fn new() -> Self {
195+
unsafe {
196+
// ensure we set the version, even if externally linked
197+
__jit_debug_descriptor.version = 1;
198+
}
199+
Self {
200+
inner: vec![],
201+
}
202+
}
203+
182204
/// Register debug info relating to JIT code with the debugger.
183205
pub(crate) fn register_new_jit_code_entry(
184206
&mut self,

lib/runtime-core/src/parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub fn read_module<
9999

100100
generate_debug_info: compiler_config.should_generate_debug_info(),
101101
#[cfg(feature = "generate-debug-information")]
102-
debug_info_manager: Default::default(),
102+
debug_info_manager: crate::jit_debug::JitCodeDebugInfoManager::new(),
103103
}));
104104

105105
let mut parser = wasmparser::ValidatingParser::new(

0 commit comments

Comments
 (0)