forked from bytecodealliance/wasmtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move gdbjit C helpers to a separate file
This commit splits out the gdbjit-related helpers from `helpers.c` in Wasmtime to a separate C file built as part of the `wasmtime-jit-debug` crate. This'll help excise these helpers if gdbjit support is disabled at compile time and additionally brings them closer to the actual definition in the `wasmtime-jit-debug` crate.
- Loading branch information
1 parent
fc3c868
commit 5456d4e
Showing
5 changed files
with
68 additions
and
47 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use wasmtime_versioned_export_macros::versioned_suffix; | ||
|
||
fn main() { | ||
if !cfg!(feature = "gdb_jit_int") { | ||
return; | ||
} | ||
|
||
let mut build = cc::Build::new(); | ||
build.warnings(true); | ||
let os = std::env::var("CARGO_CFG_TARGET_OS").unwrap(); | ||
build.define(&format!("CFG_TARGET_OS_{os}"), None); | ||
build.define("VERSIONED_SUFFIX", Some(versioned_suffix!())); | ||
|
||
println!("cargo:rerun-if-changed=gdbjit.c"); | ||
build.file("gdbjit.c"); | ||
build.compile("gdbjit-helpers"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
|
||
#define CONCAT2(a, b) a##b | ||
#define CONCAT(a, b) CONCAT2(a, b) | ||
#define VERSIONED_SYMBOL(a) CONCAT(a, VERSIONED_SUFFIX) | ||
|
||
#ifdef CFG_TARGET_OS_windows | ||
// export required for external access. | ||
__declspec(dllexport) | ||
#else | ||
// Note the `weak` linkage here, though, which is intended to let other code | ||
// override this symbol if it's defined elsewhere, since this definition doesn't | ||
// matter. | ||
// Just in case cross-language LTO is enabled we set the `noinline` attribute | ||
// and also try to have some sort of side effect in this function with a dummy | ||
// `asm` statement. | ||
__attribute__((weak, noinline)) | ||
#endif | ||
void __jit_debug_register_code() { | ||
#ifndef CFG_TARGET_OS_windows | ||
__asm__(""); | ||
#endif | ||
} | ||
|
||
struct JITDescriptor { | ||
uint32_t version_; | ||
uint32_t action_flag_; | ||
void *relevant_entry_; | ||
void *first_entry_; | ||
}; | ||
|
||
#ifdef CFG_TARGET_OS_windows | ||
// export required for external access. | ||
__declspec(dllexport) | ||
#else | ||
// Note the `weak` linkage here which is the same purpose as above. We want to | ||
// let other runtimes be able to override this since our own definition isn't | ||
// important. | ||
__attribute__((weak)) | ||
#endif | ||
struct JITDescriptor __jit_debug_descriptor = {1, 0, NULL, NULL}; | ||
|
||
struct JITDescriptor *VERSIONED_SYMBOL(wasmtime_jit_debug_descriptor)() { | ||
return &__jit_debug_descriptor; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters