From 645519c29cc72addc1254d081ace2c734f91c2d7 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 13 Nov 2019 15:28:04 +0100 Subject: [PATCH 1/6] fix(runtime-c-api) Use `#if defined` instead of `#ifdef`. --- lib/runtime-c-api/build.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/runtime-c-api/build.rs b/lib/runtime-c-api/build.rs index 7c518398c63..4ff1dfb450a 100644 --- a/lib/runtime-c-api/build.rs +++ b/lib/runtime-c-api/build.rs @@ -13,20 +13,20 @@ fn main() { out_wasmer_header_file.push("wasmer"); const WASMER_PRE_HEADER: &str = r#" -#ifndef WASMER_H_MACROS -#define WASMER_H_MACROS -#if MSVC -#ifdef _M_AMD64 -#define ARCH_X86_64 -#endif -#endif +#if !defined(WASMER_H_MACROS) + #define WASMER_H_MACROS + #if defined(MSVC) + #if defined(_M_AMD64) + #define ARCH_X86_64 + #endif + #endif -#if GCC -#ifdef __x86_64__ -#define ARCH_X86_64 -#endif + #if defined(GCC) + #if defined(__x86_64__) + #define ARCH_X86_64 + #endif + #endif #endif -#endif // WASMER_H_MACROS "#; // Generate the C bindings in the `OUT_DIR`. out_wasmer_header_file.set_extension("h"); From b081d17ab0eeb22bbc6639cd80c535682fc90bfc Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 13 Nov 2019 15:28:57 +0100 Subject: [PATCH 2/6] feat(runtime-c-api) Add support for clang in `WASMER_H_MACROS`. --- lib/runtime-c-api/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/runtime-c-api/build.rs b/lib/runtime-c-api/build.rs index 4ff1dfb450a..1978c9934c5 100644 --- a/lib/runtime-c-api/build.rs +++ b/lib/runtime-c-api/build.rs @@ -21,7 +21,7 @@ fn main() { #endif #endif - #if defined(GCC) + #if defined(GCC) || defined(__clang__) #if defined(__x86_64__) #define ARCH_X86_64 #endif From be9d7f2e6e88c0efd75115639a73d0df39be13b6 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 13 Nov 2019 15:29:33 +0100 Subject: [PATCH 3/6] chore(runtime-c-api) Update header files. --- lib/runtime-c-api/wasmer.h | 26 +++++++++++++------------- lib/runtime-c-api/wasmer.hh | 26 +++++++++++++------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lib/runtime-c-api/wasmer.h b/lib/runtime-c-api/wasmer.h index bc4a3ed4fe6..e1175c1fd28 100644 --- a/lib/runtime-c-api/wasmer.h +++ b/lib/runtime-c-api/wasmer.h @@ -1,18 +1,18 @@ -#ifndef WASMER_H_MACROS -#define WASMER_H_MACROS -#if MSVC -#ifdef _M_AMD64 -#define ARCH_X86_64 +#if !defined(WASMER_H_MACROS) + #define WASMER_H_MACROS + #if defined(MSVC) + #if defined(_M_AMD64) + #define ARCH_X86_64 + #endif + #endif + + #if defined(GCC) || defined(__clang__) + #if defined(__x86_64__) + #define ARCH_X86_64 + #endif + #endif #endif -#endif - -#if GCC -#ifdef __x86_64__ -#define ARCH_X86_64 -#endif -#endif -#endif // WASMER_H_MACROS #ifndef WASMER_H diff --git a/lib/runtime-c-api/wasmer.hh b/lib/runtime-c-api/wasmer.hh index acf4b20e797..b4d2c190861 100644 --- a/lib/runtime-c-api/wasmer.hh +++ b/lib/runtime-c-api/wasmer.hh @@ -1,18 +1,18 @@ -#ifndef WASMER_H_MACROS -#define WASMER_H_MACROS -#if MSVC -#ifdef _M_AMD64 -#define ARCH_X86_64 +#if !defined(WASMER_H_MACROS) + #define WASMER_H_MACROS + #if defined(MSVC) + #if defined(_M_AMD64) + #define ARCH_X86_64 + #endif + #endif + + #if defined(GCC) || defined(__clang__) + #if defined(__x86_64__) + #define ARCH_X86_64 + #endif + #endif #endif -#endif - -#if GCC -#ifdef __x86_64__ -#define ARCH_X86_64 -#endif -#endif -#endif // WASMER_H_MACROS #ifndef WASMER_H From 938dedbbce4d24ec07650d3958155e32631553e6 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 13 Nov 2019 15:35:37 +0100 Subject: [PATCH 4/6] doc(changelog) Add #960. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a3bcfcd9518..24d0a57f3ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## **[Unreleased]** +- [#960](https://github.com/wasmerio/wasmer/pull/960) Fix `runtime-c-api` header files when compiled by clang. - [#925](https://github.com/wasmerio/wasmer/pull/925) Host functions can be closures with a captured environment. - [#917](https://github.com/wasmerio/wasmer/pull/917) Host functions (aka imported functions) may not have `&mut vm::Ctx` as first argument, i.e. the presence of the `&mut vm::Ctx` argument is optional. - [#915](https://github.com/wasmerio/wasmer/pull/915) All backends share the same definition of `Trampoline` (defined in `wasmer-runtime-core`). From 42b02bee7175bf9228aeb655eb2ce79cf114451f Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 14 Nov 2019 14:37:06 +0100 Subject: [PATCH 5/6] fix(runtime-c-api) Write macros at column 0. --- lib/runtime-c-api/build.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/runtime-c-api/build.rs b/lib/runtime-c-api/build.rs index 1978c9934c5..7750b00813d 100644 --- a/lib/runtime-c-api/build.rs +++ b/lib/runtime-c-api/build.rs @@ -14,19 +14,21 @@ fn main() { const WASMER_PRE_HEADER: &str = r#" #if !defined(WASMER_H_MACROS) - #define WASMER_H_MACROS - #if defined(MSVC) - #if defined(_M_AMD64) - #define ARCH_X86_64 - #endif - #endif +#define WASMER_H_MACROS - #if defined(GCC) || defined(__clang__) - #if defined(__x86_64__) - #define ARCH_X86_64 - #endif - #endif +#if defined(MSVC) +#if defined(_M_AMD64) +#define ARCH_X86_64 #endif +#endif + +#if defined(GCC) || defined(__clang__) +#if defined(__x86_64__) +#define ARCH_X86_64 +#endif +#endif + +#endif // WASMER_H_MACROS "#; // Generate the C bindings in the `OUT_DIR`. out_wasmer_header_file.set_extension("h"); From 987b0765c0ea4c675af6f32203f27e2e13f1e5f1 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Thu, 14 Nov 2019 14:37:55 +0100 Subject: [PATCH 6/6] chore(runtime-c-api) Update header files. --- lib/runtime-c-api/wasmer.h | 26 ++++++++++++++------------ lib/runtime-c-api/wasmer.hh | 26 ++++++++++++++------------ 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/lib/runtime-c-api/wasmer.h b/lib/runtime-c-api/wasmer.h index e1175c1fd28..836a41df215 100644 --- a/lib/runtime-c-api/wasmer.h +++ b/lib/runtime-c-api/wasmer.h @@ -1,19 +1,21 @@ #if !defined(WASMER_H_MACROS) - #define WASMER_H_MACROS - #if defined(MSVC) - #if defined(_M_AMD64) - #define ARCH_X86_64 - #endif - #endif - - #if defined(GCC) || defined(__clang__) - #if defined(__x86_64__) - #define ARCH_X86_64 - #endif - #endif +#define WASMER_H_MACROS + +#if defined(MSVC) +#if defined(_M_AMD64) +#define ARCH_X86_64 +#endif +#endif + +#if defined(GCC) || defined(__clang__) +#if defined(__x86_64__) +#define ARCH_X86_64 +#endif #endif +#endif // WASMER_H_MACROS + #ifndef WASMER_H #define WASMER_H diff --git a/lib/runtime-c-api/wasmer.hh b/lib/runtime-c-api/wasmer.hh index b4d2c190861..79c350d6080 100644 --- a/lib/runtime-c-api/wasmer.hh +++ b/lib/runtime-c-api/wasmer.hh @@ -1,19 +1,21 @@ #if !defined(WASMER_H_MACROS) - #define WASMER_H_MACROS - #if defined(MSVC) - #if defined(_M_AMD64) - #define ARCH_X86_64 - #endif - #endif - - #if defined(GCC) || defined(__clang__) - #if defined(__x86_64__) - #define ARCH_X86_64 - #endif - #endif +#define WASMER_H_MACROS + +#if defined(MSVC) +#if defined(_M_AMD64) +#define ARCH_X86_64 +#endif +#endif + +#if defined(GCC) || defined(__clang__) +#if defined(__x86_64__) +#define ARCH_X86_64 +#endif #endif +#endif // WASMER_H_MACROS + #ifndef WASMER_H #define WASMER_H