Skip to content

Commit

Permalink
Merge #960
Browse files Browse the repository at this point in the history
960: feat(runtime-c-api) Add support for clang in `WASMER_H_MACROS` r=MarkMcCaskey a=Hywan

In #952, the `WASMER_H_MACROS` constant has been defined. The `ARCH_X86_64` constant is defined under 2 conditions: If the compiler is MSVC + `_M_AMD64` is defined, or if the compiler is GCC + `__x86_64__` is defined.

Clang is missing. And it breaks some projects (like https://github.com/wasmerio/php-ext-wasm or https://github.com/wasmerio/go-ext-wasm for instance).

This patch supports Clang.

Co-authored-by: Ivan Enderlin <[email protected]>
  • Loading branch information
bors[bot] and Hywan authored Nov 14, 2019
2 parents fff16c0 + 074a8f9 commit 69f8bad
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`).
Expand Down
12 changes: 7 additions & 5 deletions lib/runtime-c-api/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@ fn main() {
out_wasmer_header_file.push("wasmer");

const WASMER_PRE_HEADER: &str = r#"
#ifndef WASMER_H_MACROS
#if !defined(WASMER_H_MACROS)
#define WASMER_H_MACROS
#if MSVC
#ifdef _M_AMD64
#if defined(MSVC)
#if defined(_M_AMD64)
#define ARCH_X86_64
#endif
#endif
#if GCC
#ifdef __x86_64__
#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`.
Expand Down
12 changes: 7 additions & 5 deletions lib/runtime-c-api/wasmer.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@

#ifndef WASMER_H_MACROS
#if !defined(WASMER_H_MACROS)
#define WASMER_H_MACROS
#if MSVC
#ifdef _M_AMD64

#if defined(MSVC)
#if defined(_M_AMD64)
#define ARCH_X86_64
#endif
#endif

#if GCC
#ifdef __x86_64__
#if defined(GCC) || defined(__clang__)
#if defined(__x86_64__)
#define ARCH_X86_64
#endif
#endif

#endif // WASMER_H_MACROS


Expand Down
12 changes: 7 additions & 5 deletions lib/runtime-c-api/wasmer.hh
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@

#ifndef WASMER_H_MACROS
#if !defined(WASMER_H_MACROS)
#define WASMER_H_MACROS
#if MSVC
#ifdef _M_AMD64

#if defined(MSVC)
#if defined(_M_AMD64)
#define ARCH_X86_64
#endif
#endif

#if GCC
#ifdef __x86_64__
#if defined(GCC) || defined(__clang__)
#if defined(__x86_64__)
#define ARCH_X86_64
#endif
#endif

#endif // WASMER_H_MACROS


Expand Down

0 comments on commit 69f8bad

Please sign in to comment.