Skip to content

Commit

Permalink
wasm_export.h: Use "default" visibility for gcc and clang (bytecodeal…
Browse files Browse the repository at this point in the history
…liance#3957)

Since the top-level CMakelists.txt is appending `-fvisibility=hidden` to
the compile options, no public symbols are exported by default. This
forbids users from linking against the shared library.

Using `gcc/clang` attributes [1], it is possible to override the definition
for `WASM_RUNTIME_API_EXTERN` so that only required symbols are
correctly exported.

[1]: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes
  • Loading branch information
midokura-xavi92 authored Dec 19, 2024
1 parent 9563909 commit 296c3cc
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/iwasm/include/wasm_export.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#else
#define WASM_RUNTIME_API_EXTERN __declspec(dllimport)
#endif
#elif defined(__GNUC__) || defined(__clang__)
#define WASM_RUNTIME_API_EXTERN __attribute__((visibility("default")))
#else
#define WASM_RUNTIME_API_EXTERN
#endif
Expand Down

0 comments on commit 296c3cc

Please sign in to comment.