From ef9a4cc99f7bd1ac5ec6386716f401737e6554f5 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Date: Wed, 11 Dec 2024 14:26:10 +0100 Subject: [PATCH] wasm_export.h: Use "default" visibility 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 --- core/iwasm/include/wasm_export.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/iwasm/include/wasm_export.h b/core/iwasm/include/wasm_export.h index aa6cfaae75..273657246d 100644 --- a/core/iwasm/include/wasm_export.h +++ b/core/iwasm/include/wasm_export.h @@ -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