From 89c3d0b86928c48fc788fc7147f27c4ace2706b7 Mon Sep 17 00:00:00 2001 From: HyukWoo Park Date: Mon, 28 Aug 2023 16:16:52 +0900 Subject: [PATCH] Fix minor build error in export Signed-off-by: HyukWoo Park --- build/target.cmake | 16 +++++++--------- src/api/wasm.h | 6 +++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/build/target.cmake b/build/target.cmake index 18190237f..b00ba2f50 100644 --- a/build/target.cmake +++ b/build/target.cmake @@ -40,8 +40,8 @@ IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR ${COMPILER_CLANG_CL}) ENDIF() SET (WALRUS_CXXFLAGS_SHAREDLIB) SET (WALRUS_LDFLAGS_SHAREDLIB) - SET (WALRUS_CXXFLAGS_STATICLIB /DWALRUS_EXPORT) - SET (WALRUS_CXXFLAGS_SHELL /DWALRUS_EXPORT /std:c++17) + SET (WALRUS_CXXFLAGS_STATICLIB /DWASM_API_EXTERN) + SET (WALRUS_CXXFLAGS_SHELL /DWASM_API_EXTERN /std:c++17) ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") SET (WALRUS_CXXFLAGS ${WALRUS_CXXFLAGS} @@ -63,7 +63,6 @@ ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") SET (WALRUS_CXXFLAGS_DEBUG -O0 -Wall -Wextra -Werror) SET (WALRUS_CXXFLAGS_RELEASE -O2 -fno-stack-protector -fno-omit-frame-pointer) SET (WALRUS_THIRDPARTY_CFLAGS -w -g3 -fdata-sections -ffunction-sections -fno-omit-frame-pointer -fvisibility=hidden) - SET (WALRUS_DEFINITIONS ${WALRUS_DEFINITIONS} "WASM_API_EXTERN=__attribute__((visibility(\"default\")))") IF (WALRUS_SMALL_CONFIG) SET (WALRUS_CXXFLAGS_RELEASE ${WALRUS_CXXFLAGS_RELEASE} -Os) @@ -73,8 +72,8 @@ ELSEIF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") ENDIF() SET (WALRUS_CXXFLAGS_SHAREDLIB -fPIC) SET (WALRUS_LDFLAGS_SHAREDLIB -ldl) - SET (WALRUS_CXXFLAGS_STATICLIB -fPIC -DWALRUS_EXPORT=) - SET (WALRUS_CXXFLAGS_SHELL -DWALRUS_EXPORT= -frtti -std=c++17) + SET (WALRUS_CXXFLAGS_STATICLIB -fPIC -DWASM_API_EXTERN=) + SET (WALRUS_CXXFLAGS_SHELL -DWASM_API_EXTERN= -frtti -std=c++17) ELSEIF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # Clang and AppleClang SET (WALRUS_CXXFLAGS @@ -94,7 +93,6 @@ ELSEIF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # Clang and AppleClang SET (WALRUS_CXXFLAGS_DEBUG -O0 -Wall -Wextra -Werror) SET (WALRUS_CXXFLAGS_RELEASE -O2 -fno-stack-protector -fno-omit-frame-pointer) SET (WALRUS_THIRDPARTY_CFLAGS -w -g3 -fdata-sections -ffunction-sections -fno-omit-frame-pointer -fvisibility=hidden) - SET (WALRUS_DEFINITIONS ${WALRUS_DEFINITIONS} "WASM_API_EXTERN=__attribute__((visibility(\"default\")))") IF (WALRUS_SMALL_CONFIG) SET (WALRUS_CXXFLAGS_RELEASE ${WALRUS_CXXFLAGS_RELEASE} -Os) @@ -104,8 +102,8 @@ ELSEIF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # Clang and AppleClang ENDIF() SET (WALRUS_CXXFLAGS_SHAREDLIB -fPIC) SET (WALRUS_LDFLAGS_SHAREDLIB -ldl) - SET (WALRUS_CXXFLAGS_STATICLIB -fPIC -DWALRUS_EXPORT=) - SET (WALRUS_CXXFLAGS_SHELL -DWALRUS_EXPORT= -frtti -std=c++17) + SET (WALRUS_CXXFLAGS_STATICLIB -fPIC -DWASM_API_EXTERN=) + SET (WALRUS_CXXFLAGS_SHELL -DWASM_API_EXTERN= -frtti -std=c++17) ELSE() MESSAGE (FATAL_ERROR ${CMAKE_CXX_COMPILER_ID} " is Unsupported Compiler") ENDIF() @@ -219,4 +217,4 @@ ELSEIF (WALRUS_BUILD_64BIT) SET (WALRUS_DEFINITIONS ${WALRUS_DEFINITIONS} -DWALRUS_64=1) ELSE() MESSAGE (FATAL_ERROR "unsupported mode") -ENDIF() \ No newline at end of file +ENDIF() diff --git a/src/api/wasm.h b/src/api/wasm.h index 4700be671..dff6ce884 100644 --- a/src/api/wasm.h +++ b/src/api/wasm.h @@ -10,10 +10,10 @@ #include #ifndef WASM_API_EXTERN -#ifdef _WIN32 -#define WASM_API_EXTERN __declspec(dllimport) +#ifdef _MSC_VER +#define WASM_API_EXTERN __declspec(dllexport) #else -#define WASM_API_EXTERN +#define WASM_API_EXTERN __attribute__((visibility("default"))) #endif #endif