diff options
author | Ivancing <648262030@qq.com> | 2024-07-22 01:40:42 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-21 10:40:42 -0700 |
commit | 4e8f5875bc59ddfb84c8b0b26071a547b49823a9 (patch) | |
tree | ecee05a99e9be182a196dad035dfab79280bab92 /cli/build.rs | |
parent | bb1c6c49bb30a6518ca4dbd3b3f7ec52f5861b76 (diff) |
fix(cli): add NAPI support in standalone mode (#24642)
Currently, importing Node-Addons modules in a standalone binary results
in a `missing symbol called` error
(https://github.com/denoland/deno/issues/24614). Because the NAPI
symbols are not exported in this mode. This PR should fix the issue.
Diffstat (limited to 'cli/build.rs')
-rw-r--r-- | cli/build.rs | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/cli/build.rs b/cli/build.rs index 4fe6fd1ea..f131bc1dc 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -404,16 +404,28 @@ fn main() { ); #[cfg(target_os = "windows")] - println!( - "cargo:rustc-link-arg-bin=deno=/DEF:{}", - symbols_path.display() - ); + { + println!( + "cargo:rustc-link-arg-bin=deno=/DEF:{}", + symbols_path.display() + ); + println!( + "cargo:rustc-link-arg-bin=denort=/DEF:{}", + symbols_path.display() + ); + } #[cfg(target_os = "macos")] - println!( - "cargo:rustc-link-arg-bin=deno=-Wl,-exported_symbols_list,{}", - symbols_path.display() - ); + { + println!( + "cargo:rustc-link-arg-bin=deno=-Wl,-exported_symbols_list,{}", + symbols_path.display() + ); + println!( + "cargo:rustc-link-arg-bin=denort=-Wl,-exported_symbols_list,{}", + symbols_path.display() + ); + } #[cfg(target_os = "linux")] { @@ -426,19 +438,30 @@ fn main() { { println!("cargo:warning=Compiling with all symbols exported, this will result in a larger binary. Please use glibc 2.35 or later for an optimised build."); println!("cargo:rustc-link-arg-bin=deno=-rdynamic"); + println!("cargo:rustc-link-arg-bin=denort=-rdynamic"); } else { println!( "cargo:rustc-link-arg-bin=deno=-Wl,--export-dynamic-symbol-list={}", symbols_path.display() ); + println!( + "cargo:rustc-link-arg-bin=denort=-Wl,--export-dynamic-symbol-list={}", + symbols_path.display() + ); } } #[cfg(target_os = "android")] - println!( - "cargo:rustc-link-arg-bin=deno=-Wl,--export-dynamic-symbol-list={}", - symbols_path.display() - ); + { + println!( + "cargo:rustc-link-arg-bin=deno=-Wl,--export-dynamic-symbol-list={}", + symbols_path.display() + ); + println!( + "cargo:rustc-link-arg-bin=denort=-Wl,--export-dynamic-symbol-list={}", + symbols_path.display() + ); + } // To debug snapshot issues uncomment: // op_fetch_asset::trace_serializer(); |