Stream: git-wasmtime

Topic: wasmtime / issue #3979 Cannot static link MinGW build


view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2022 at 10:32):

sjml opened issue #3979:

Test Case

The problem is a build/link issue, so I created a minimal example in this repository.

Steps to Reproduce

Expected Results

Being able to link wasmtime statically for a MinGW build.

Actual Results

Build fails.

Versions and Environment

Wasmtime version or commit: v0.35.1

Operating system: Building on macOS, running on Windows

Architecture: x86_64

Extra Info

Part of the issue seems to be these lines in wasm.h: note that it declares an external implementation (dllimport) if _WIN32 is defined, with no provision for static linking.

If I change that so WASM_API_EXTERN is blank (as on other platforms) then it's able to link to libwasmtime.a, but then fails the build since it can't find a bunch of Windows libraries.

If static linking with MinGW is not possible or practical, I understand, but what is the static .a library file used for, then? I note there's a DLL loading static lib, which I get, but it's not clear how to use the full static library, if it's even possible.

I'm not a MinGW expert, so there may be something I'm missing here... thanks for whatever help you can offer.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2022 at 10:32):

sjml labeled issue #3979:

Test Case

The problem is a build/link issue, so I created a minimal example in this repository.

Steps to Reproduce

Expected Results

Being able to link wasmtime statically for a MinGW build.

Actual Results

Build fails.

Versions and Environment

Wasmtime version or commit: v0.35.1

Operating system: Building on macOS, running on Windows

Architecture: x86_64

Extra Info

Part of the issue seems to be these lines in wasm.h: note that it declares an external implementation (dllimport) if _WIN32 is defined, with no provision for static linking.

If I change that so WASM_API_EXTERN is blank (as on other platforms) then it's able to link to libwasmtime.a, but then fails the build since it can't find a bunch of Windows libraries.

If static linking with MinGW is not possible or practical, I understand, but what is the static .a library file used for, then? I note there's a DLL loading static lib, which I get, but it's not clear how to use the full static library, if it's even possible.

I'm not a MinGW expert, so there may be something I'm missing here... thanks for whatever help you can offer.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2022 at 11:33):

sjml edited issue #3979:

Test Case

The problem is a build/link issue, so I created a minimal example in this repository.

Steps to Reproduce

Expected Results

Being able to link wasmtime statically for a MinGW build.

Actual Results

Build fails.

Versions and Environment

Wasmtime version or commit: v0.35.1

Operating system: Building on macOS, running on Windows

Architecture: x86_64

Extra Info

Part of the issue seems to be these lines in wasm.h: note that it declares an external implementation (dllimport) if _WIN32 is defined, with no provision for static linking.

If I change that so WASM_API_EXTERN is blank (as on other platforms) then it's able to link to libwasmtime.a, but then fails the build since it can't find a bunch of Windows libraries.

If static linking with MinGW is not possible or practical, I understand, but what is the static .a library file used for, then? I note there's a DLL loading static lib, which I get, but it's not clear how to use the full static library, if it's even possible.

I'm not a MinGW expert, so there may be something I'm missing here... thanks for whatever help you can offer.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2022 at 11:34):

sjml edited issue #3979:

Test Case

The problem is a build/link issue, so I created a minimal example in this repository.

Steps to Reproduce

Expected Results

Being able to link wasmtime statically for a MinGW build.

Actual Results

Build fails.

Versions and Environment

Wasmtime version or commit: v0.35.1

Operating system: Building on macOS, running on Windows

Architecture: x86_64

Extra Info

Part of the issue seems to be these lines in wasm.h: note that it declares an external implementation (dllimport) if _WIN32 is defined, with no provision for static linking.

If I change that so WASM_API_EXTERN is blank (as on other platforms) then it's able to link to libwasmtime.a, but then fails the build since it can't find a bunch of Windows libraries.

If static linking with MinGW is not possible or practical, I understand, but what is the static .a library file used for, then? I note there's a DLL loading static lib, which I get, but it's not clear how to use the full static library, if it's even possible.

I'm not a MinGW expert, so there may be something I'm missing here... thanks for whatever help you can offer.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2022 at 11:35):

sjml edited issue #3979:

Test Case

The problem is a build/link issue, so I created a minimal example in this repository.

Steps to Reproduce

Expected Results

Being able to link wasmtime statically for a MinGW build.

Actual Results

Build fails.

Versions and Environment

Wasmtime version or commit: v0.35.1

Operating system: Building on macOS, running on Windows

Architecture: x86_64

Extra Info

Part of the issue seems to be these lines in wasm.h: note that it declares an external implementation (dllimport) if _WIN32 is defined, with no provision for static linking.

If I change that so WASM_API_EXTERN is blank (as on other platforms) then it's able to link to libwasmtime.a, but then fails the build since it can't find a bunch of Windows libraries.

If static linking with MinGW is not possible or practical, I understand, but what is the static .a library file used for, then? I note there's a DLL loading static lib, which I get, but it's not clear how to use the full static library, if it's even possible.

I'm not a MinGW expert, so there may be something I'm missing here... thanks for whatever help you can offer.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 31 2022 at 15:12):

alexcrichton commented on issue #3979:

Yeah linking with Windows is a bit trickier than other platforms, as you've found you'll need to -DWASM_API_EXTERN on the command line to avoid the dllimport annotation. Note that when static linking you'll need to link all of the Windows libraries manually since they're not implicitly listed in the *.a file.

You can see an example of how this is done with the wasmtime-go compliation flags on Windows which statically links using MinGW I believe.

Can you try passing the extra -l flags and see if it works for you?

view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2022 at 04:23):

sjml commented on issue #3979:

Ah, yup that did the trick. Sorry to bug you on that -- very glad for the pointer to the wasmtime-go example.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 01 2022 at 04:23):

sjml closed issue #3979:

Test Case

The problem is a build/link issue, so I created a minimal example in this repository.

Steps to Reproduce

Expected Results

Being able to link wasmtime statically for a MinGW build.

Actual Results

Build fails.

Versions and Environment

Wasmtime version or commit: v0.35.1

Operating system: Building on macOS, running on Windows

Architecture: x86_64

Extra Info

Part of the issue seems to be these lines in wasm.h: note that it declares an external implementation (dllimport) if _WIN32 is defined, with no provision for static linking.

If I change that so WASM_API_EXTERN is blank (as on other platforms) then it's able to link to libwasmtime.a, but then fails the build since it can't find a bunch of Windows libraries.

If static linking with MinGW is not possible or practical, I understand, but what is the static .a library file used for, then? I note there's a DLL loading static lib, which I get, but it's not clear how to use the full static library, if it's even possible.

I'm not a MinGW expert, so there may be something I'm missing here... thanks for whatever help you can offer.


Last updated: Oct 23 2024 at 20:03 UTC