From 859601c446559664fb42032f10fa198d21e8e3f7 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 25 Feb 2021 12:53:51 +0100 Subject: [PATCH] feat(c-api) Reduce the number of dependencies by statically compiling CRT. This patch adds the `-Ctarget-feature=+crt-static` flag when compiling `libwasmer` on Windows. The goal is twofold: Reducing the number of dependencies, and improving the portability of `libwasmer.dll` on more Windows instances. Before: ```sh $ objdump --all-headers wasmer.dll | rg 'DLL Name' DLL Name: bcrypt.dll DLL Name: ADVAPI32.dll DLL Name: KERNEL32.dll DLL Name: VCRUNTIME140.dll DLL Name: api-ms-win-crt-heap-l1-1-0.dll DLL Name: api-ms-win-crt-runtime-l1-1-0.dll DLL Name: api-ms-win-crt-math-l1-1-0.dll DLL Name: api-ms-win-crt-string-l1-1-0.dll ``` After: ```sh $ objdump --all-headers wasmer.dll | rg 'DLL Name' (to be defined) ``` --- .cargo/config.toml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 5ae061b86c3..5c466488d47 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,4 +1,14 @@ + [target.'cfg(target_os = "linux")'] rustflags = [ - "-C", "link-arg=-Wl,-E" + # Put the VM functions in the dynamic symbol table. + "-C", "link-arg=-Wl,-E", ] + +[target.'cfg(target_os = "windows")'] +rustflags = [ + # Enable `libwasmer` to be statically linked against the C Runtime + # Libraries (CRT) to reduce the number of dependencies inside the + # DLL. + "-C", "target-feature=+crt-static", +] \ No newline at end of file