Skip to content

Commit

Permalink
feat(c-api) Reduce the number of dependencies by statically compiling…
Browse files Browse the repository at this point in the history
… 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)
```
  • Loading branch information
Hywan committed Feb 25, 2021
1 parent d1bd9ea commit 859601c
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -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",
]

0 comments on commit 859601c

Please sign in to comment.