Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better in headers wasm-c-api #1883

Closed
wants to merge 5 commits into from
Closed

Better in headers wasm-c-api #1883

wants to merge 5 commits into from

Conversation

syrusakbary
Copy link
Member

Description

Previously the wasmer.h header corresponded to the (now) deprecated Wasmer API.
However, as we move forward and adopted wasm-c-api, we couldn't use wasmer.h for it because wasmer.h and wasmer_wasm.h had conflicting names.

Now, this PR solves that by having the old Wasmer API to use the WasmKind enum so people can only use one header always.

Review

  • Add a short description of the the change to the CHANGELOG.md file

@syrusakbary
Copy link
Member Author

bors try

bors bot added a commit that referenced this pull request Dec 6, 2020
@bors
Copy link
Contributor

bors bot commented Dec 6, 2020

try

Build failed:

Copy link
Contributor

@Hywan Hywan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the idea is to use wasmer.h everytime, whatever the user needds the deprecated API or the standard++ API, is that correct?

Comment on lines 83 to 84
// Include the deprecated API for import compatibility reasons
#include "wasmer_deprecated.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what to think about this right now 🤔.

@syrusakbary
Copy link
Member Author

So the idea is to use wasmer.h everytime, whatever the user needds the deprecated API or the standard++ API, is that correct?

Yup, that's right!

@@ -79,6 +79,10 @@ fn build_wasm_c_api_headers(crate_dir: &str, out_dir: &str) {
#if !defined(WASMER_WASM_H_MACROS)

#define WASMER_WASM_H_MACROS

// Include the deprecated API for import compatibility reasons
#include "wasmer_deprecated.h"
Copy link
Contributor

@nlewycky nlewycky Dec 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest doing this the other way. Make users of the deprecated API #include "wasmer_deprecated.h" which in turn includes (and re-exports) the full #include "wasmer.h". That way the deprecated doesn't need to redeclare any duplicate stuff, and people can easily build to the new API without using old parts by accident, and both APIs are available to users of the old API upgrading parts to the new API.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to do it this way because I don't want to have breaking changes for people that are using the #include "wasmer.h" header for using the API.

That's the main reason for this. We will probably remove this on 2.0 :)

Comment on lines +28 to +33
// Define the `DEPRECATED` macro.
#if defined(GCC) || defined(__GNUC__) || __has_attribute(deprecated)
# define DEPRECATED(message) __attribute__((deprecated(message)))
#elif defined(MSVC) || __has_declspec_attribute(deprecated)
# define DEPRECATED(message) __declspec(deprecated(message))
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, perfect! It seems that we should be marking the entire deprecated API with DEPRECATED("use X instead") now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to have this macro available for our custom extensions to the Wasmer C API, we have 2 functions related to initializing WASI which are now deprecated and not marked like this, only marked by a comment

Copy link
Contributor

@MarkMcCaskey MarkMcCaskey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a good change overall! My biggest concern is implicitly encouraging the deprecated API by making it always imported / weirdness from accidentally mixing the APIs.

lib/c-api/build.rs Outdated Show resolved Hide resolved
@MarkMcCaskey
Copy link
Contributor

bors try

bors bot added a commit that referenced this pull request Dec 10, 2020
@bors
Copy link
Contributor

bors bot commented Dec 10, 2020

try

Build failed:

@Hywan
Copy link
Contributor

Hywan commented Dec 11, 2020

My biggest concern is implicitly encouraging the deprecated API by making it always imported / weirdness from accidentally mixing the APIs.

That's my biggest concern too. With an IDE, a user could just run autocompletion and use functions or types from the deprecated API by mistake :-/. That's really not ideal. And for that, I am likely to stand against this PR if we don't find a correct solution to avoid such scenario.

@syrusakbary
Copy link
Member Author

Closing this PR as it was already merged in master with #2375

@syrusakbary syrusakbary closed this Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants