From 5714988e237444258fd0c9e565037a25430c7734 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 20 Jul 2021 14:37:12 +0200 Subject: [PATCH 1/2] fix(api,c-api,vm) Try passing `--export-dynamic` with a `build.rs` to the linker. --- .cargo/config.toml | 5 ----- lib/api/build.rs | 5 +++++ lib/c-api/build.rs | 4 ++++ lib/vm/build.rs | 6 +++++- 4 files changed, 14 insertions(+), 6 deletions(-) delete mode 100644 .cargo/config.toml create mode 100644 lib/api/build.rs diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index d83dcde74f6..00000000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,5 +0,0 @@ -[target.'cfg(target_os = "linux")'] -rustflags = [ - # Put the VM functions in the dynamic symbol table. - "-C", "link-arg=-Wl,-E", -] diff --git a/lib/api/build.rs b/lib/api/build.rs new file mode 100644 index 00000000000..43fde88973c --- /dev/null +++ b/lib/api/build.rs @@ -0,0 +1,5 @@ +//! Pass `--export-dynamic` to the linker. +fn main() { + #[cfg(target_os = "linux")] + println!("cargo:rustc-cdylib-link-arg=--export-dynamic"); +} diff --git a/lib/c-api/build.rs b/lib/c-api/build.rs index ce423ac12e1..e411c704f8c 100644 --- a/lib/c-api/build.rs +++ b/lib/c-api/build.rs @@ -1,5 +1,6 @@ //! This build script aims at: //! +//! * pass `--export-dynamic` to the linker, //! * generating the C header files for the C API, //! * setting `inline-c` up. @@ -69,6 +70,9 @@ macro_rules! map_feature_as_c_define { } fn main() { + #[cfg(target_os = "linux")] + println!("cargo:rustc-cdylib-link-arg=--export-dynamic"); + if !running_self() { return; } diff --git a/lib/vm/build.rs b/lib/vm/build.rs index 278eb570db7..c5abd9f1e6c 100644 --- a/lib/vm/build.rs +++ b/lib/vm/build.rs @@ -1,8 +1,12 @@ -//! Runtime build script compiles C code using setjmp for trap handling. +//! 1. Pass `--export-dynamic` to the linker. +//! 2. Runtime build script compiles C code using setjmp for trap handling. use std::env; fn main() { + #[cfg(target_os = "linux")] + println!("cargo:rustc-cdylib-link-arg=--export-dynamic"); + println!("cargo:rerun-if-changed=src/trap/handlers.c"); cc::Build::new() From bb9cee5a083e19ad17496fbbbd7823b441cf2977 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Tue, 20 Jul 2021 14:48:44 +0200 Subject: [PATCH 2/2] !try --- lib/engine-dylib/build.rs | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 lib/engine-dylib/build.rs diff --git a/lib/engine-dylib/build.rs b/lib/engine-dylib/build.rs new file mode 100644 index 00000000000..43fde88973c --- /dev/null +++ b/lib/engine-dylib/build.rs @@ -0,0 +1,5 @@ +//! Pass `--export-dynamic` to the linker. +fn main() { + #[cfg(target_os = "linux")] + println!("cargo:rustc-cdylib-link-arg=--export-dynamic"); +}