Stream: git-wasmtime

Topic: wasmtime / Issue #1899 Fix compilation error due to redef...


view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 16:11):

github-actions[bot] commented on Issue #1899:

Subscribe to Label Action

cc @peterhuene

<details>
This issue or pull request has been labeled: "wasmtime:c-api"

Thus the following users have been cc'd because of the following labels:

To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.

Learn more.
</details>

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 17:11):

alexcrichton commented on Issue #1899:

Thanks for the PR! I'm curious, though, how did this turn into an error? We're compiling the C examples on CI which in theory would catch this. Is there a way we can catch this on our own CI?

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 17:14):

AlexEne commented on Issue #1899:

I just tried to use this in my project. I am surprised that the C examples compile in your CI?
I'm using clang on OSX and was basically going through the example code trying to instantiate a VM.
Maybe it gets ignored on certain compilers if the symbol isn't referenced at all?

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 17:17):

AlexEne edited a comment on Issue #1899:

I just tried to use this in my project. I am surprised that the C examples compile in your CI?
I'm using clang on OSX and was basically going through the example code trying to instantiate a VM.
Maybe it gets ignored on certain compilers if the symbol isn't referenced at all?

Also I'm compiling it as C++, not C, maybe it's allowed in C?

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 17:19):

AlexEne edited a comment on Issue #1899:

I'm using clang on OSX and was basically going through the example code trying to instantiate a VM.

Also I'm compiling it as C++, not C, maybe it's allowed in C?

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 17:24):

AlexEne edited a comment on Issue #1899:

I'm using clang on OSX and was basically going through the example code trying to instantiate a VM.

Also I'm compiling it as C++, not C, maybe it's allowed in C? if that's the case just compiling the examples as C++ should do the trick.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 17:41):

AlexEne edited a comment on Issue #1899:

I'm using clang on OSX and was basically going through the example code trying to instantiate a VM.

Also I'm compiling it as C++, not C, maybe it's allowed in C? if that's the case just compiling the examples as C++ should do the trick.

That being said, I was looking at the current CI run for this PR and I can't find where the examples are compiled.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 17:43):

alexcrichton commented on Issue #1899:

Hm we're compiling the examples on macOS as well, so we should see it there if it's an issue. Do you perhaps have some extra warnings or such turned on which would cause this to be an error?

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 17:46):

AlexEne commented on Issue #1899:

I do have warnings set as errors, however this looks like it's a hard error, not a warning:

In file included from myfile.cpp:2:
wasmtime/crates/c-api/include/wasmtime.h:42:6: error: definition of type 'wasmtime_profiling_strategy_t' conflicts with typedef of the same name
enum wasmtime_profiling_strategy_t { // ProfilingStrategy
     ^
wasmtime/crates/c-api/include/wasmtime.h:41:17: note: 'wasmtime_profiling_strategy_t' declared here
typedef uint8_t wasmtime_profiling_strategy_t;

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 17:48):

AlexEne edited a comment on Issue #1899:

I do have warnings set as errors, however this looks like it's a hard error, not a warning:

In file included from myfile.cpp:2:
wasmtime/crates/c-api/include/wasmtime.h:42:6: error: definition of type 'wasmtime_profiling_strategy_t' conflicts with typedef of the same name
enum wasmtime_profiling_strategy_t { // ProfilingStrategy
     ^
wasmtime/crates/c-api/include/wasmtime.h:41:17: note: 'wasmtime_profiling_strategy_t' declared here
typedef uint8_t wasmtime_profiling_strategy_t;

I was looking through the tests that run on this PR, but can't find any reference of compiling the examples (it's a long log :D) https://pipelines.actions.githubusercontent.com/ceoZblEsqJYG99Z8v3Kua3u5YSq6xmgwoMNvYfC5How3o8shjd/_apis/pipelines/1/runs/39807/signedlogcontent/26?urlExpires=2020-06-18T17%3A48%3A21.3835673Z&urlSigningMethod=HMACV1&urlSignature=haTCuoUHaScfQ3HsHjt2sR7t0baZqGOInfcIxUaV95g%3D

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 17:49):

AlexEne edited a comment on Issue #1899:

I do have warnings set as errors, however this looks like it's a hard error, not a warning:

In file included from myfile.cpp:2:
wasmtime/crates/c-api/include/wasmtime.h:42:6: error: definition of type 'wasmtime_profiling_strategy_t' conflicts with typedef of the same name
enum wasmtime_profiling_strategy_t { // ProfilingStrategy
     ^
wasmtime/crates/c-api/include/wasmtime.h:41:17: note: 'wasmtime_profiling_strategy_t' declared here
typedef uint8_t wasmtime_profiling_strategy_t;

I was looking through the tests that run on this PR, but can't find any reference of compiling the examples (it's a long log :D), what is the exact step that should do it?

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 17:51):

AlexEne commented on Issue #1899:

Just to clarify this is an error when compiling a host VM that's written in C++ that wants to use WASMTime, not an error in compiling C->WASM (I did find some of these tested in the nightly runs).

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 17:52):

AlexEne edited a comment on Issue #1899:

Just to clarify this is an error when compiling a host VM that's written in C++ that wants to use WASMTime's C bindings, not an error in compiling C->WASM (I did find some of these tested in the nightly runs).

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 17:53):

AlexEne edited a comment on Issue #1899:

Just to clarify this is an error when compiling a host VM that's written in C++ that wants to use WASMTime's through it's C bindings, not an error in compiling C->WASM (I did find some of these tested in the nightly runs).

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 18:23):

peterhuene commented on Issue #1899:

This is indeed illegal in C++ and we don't have any examples that include wasmtime.h from a C++ source file (clang and gcc both use the file extension to default the language).

We should probably add a hello.cc to examples/ to catch this in CI.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 18:24):

peterhuene edited a comment on Issue #1899:

This is indeed illegal in C++ and we don't have any examples that include wasmtime.h from a C++ source file (clang and gcc both use the file extension to default the language).

We should probably add a hello.cc to examples/ to catch this in CI.

@AlexEne would you mind adding one in this PR?

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 18:49):

AlexEne commented on Issue #1899:

I added a new file, I wanted initially to just rename hello.c -> hello.cc, but I noticed that you refernce it in some places as a C example and I don't know how strongly you feel about C/C++ distinction so I left both in there.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 19:18):

alexcrichton commented on Issue #1899:

Ah nice find! I think though to run these examples we'll need to add support to this runner as well.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 19:54):

AlexEne commented on Issue #1899:

Ah, so that's where it was, I will add it to the file.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 23:10):

AlexEne commented on Issue #1899:

I've added a way for tests to also compile and run any .cc files found, in additon to the .c files. The C++ files are optional so if none are found they are skipped, but if .c files are missing tests will fail as before.

Output:

======== C/C++ example `hello` ============
Running for file: "examples/hello.c"
Initializing...
Loading binary...
Compiling module...
Instantiating module...
Extracting export...
Calling fib...
> fib(6) = 21
Shutting down...
Done.
Running for file: "examples/hello.cc"
Generating Code...
Compiling...
Generating Code...
hello.obj : warning LNK4042: object specified more than once; extras ignored
Initializing...
Loading binary...
Compiling module...
Instantiating module...
Extracting export...
Calling fib...
> fib(6) = 21
Shutting down...
Done.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 18 2020 at 23:14):

AlexEne edited a comment on Issue #1899:

I've added a way for tests to also compile and run any .cc files found, in additon to the .c files. The C++ files are optional so if none are found they are skipped, but if .c files are missing tests will fail as before.

Output:

======== C/C++ example `hello` ============
hello.c
Initializing...
Loading binary...
Compiling module...
Instantiating module...
Extracting export...
Calling fib...
> fib(6) = 21
Shutting down...
Done.
hello.cc
Initializing...
Loading binary...
Compiling module...
Instantiating module...
Extracting export...
Calling fib...
> fib(6) = 21
Shutting down...

view this post on Zulip Wasmtime GitHub notifications bot (Jun 19 2020 at 05:59):

peterhuene commented on Issue #1899:

Thanks for fixing this and adding a test case!


Last updated: Nov 22 2024 at 16:03 UTC