Skip to content

Commit

Permalink
Merge #2140
Browse files Browse the repository at this point in the history
2140: feat(c-api) Reduce the number of dependencies by statically compiling CRT r=Hywan a=Hywan

# Description

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'
    DLL Name: bcrypt.dll
    DLL Name: ADVAPI32.dll
    DLL Name: KERNEL32.dll
```

# Review

- [x] Add a short description of the the change to the CHANGELOG.md file


Co-authored-by: Ivan Enderlin <[email protected]>
  • Loading branch information
bors[bot] and Hywan authored Feb 26, 2021
2 parents d1bd9ea + 965aa53 commit 3dc537c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
[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 3dc537c

Please sign in to comment.