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:
- peterhuene: wasmtime:c-api
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
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?
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?
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?
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?
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.
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.
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?
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;
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
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?
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).
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).
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).
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
toexamples/
to catch this in CI.
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
toexamples/
to catch this in CI.@AlexEne would you mind adding one in this PR?
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.
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.
AlexEne commented on Issue #1899:
Ah, so that's where it was, I will add it to the file.
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.
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...
peterhuene commented on Issue #1899:
Thanks for fixing this and adding a test case!
Last updated: Nov 22 2024 at 16:03 UTC