Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android armv7 is supported or not #1889

Closed
morn-0 opened this issue Oct 2, 2022 · 15 comments · Fixed by #3247
Closed

android armv7 is supported or not #1889

morn-0 opened this issue Oct 2, 2022 · 15 comments · Fixed by #3247

Comments

@morn-0
Copy link

morn-0 commented Oct 2, 2022

Description

Current State

I would like to know if it is currently possible to compile and run on android armv7

Expected

Environment

  • Hardware Architecture: armv7
  • Operating system: Android

The following information is optional. Please provide them only if you have built from source.

  • C++ Compiler version:
  • CMake version:
  • CMake flags: -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_BUILD_AOT_RUNTIME=ON
  • Boost version:

Steps to Reproduce

@juntao
Copy link
Member

juntao commented Oct 2, 2022

@morn-0
Copy link
Author

morn-0 commented Oct 2, 2022

@juntao
Copy link
Member

juntao commented Oct 2, 2022

Can you build it in Ubuntu with boost installed? I have not tried arch Linux and there might be dependency issues.

@morn-0
Copy link
Author

morn-0 commented Oct 2, 2022

Can you build it in Ubuntu with boost installed? I have not tried arch Linux and there might be dependency issues.

Ok I will try, so is it currently supported to compile to armv7-a android?

@hydai
Copy link
Member

hydai commented Oct 3, 2022

Hi @morn-0

Short answer: Nope. We don't guarantee that WasmEdge can be fully supported on armv7-a android.

We provide a CI workflow to build and test on the armv8 android only. It has been a long time since we tried to support the armv7-a android platform. Due to the lack of user numbers, we don't focus on this platform currently.

However, according to your log, looks like the boost is not installed or found on your system.

@hydai
Copy link
Member

hydai commented Oct 4, 2022

Hi @morn-0
Just for the following up:
If you are interested, we have an external contributor to submit the OHOS support, which should use the armv7-a arch.

https://github.com/WasmEdge/WasmEdge/blob/master/utils/ohos/build_for_ohos.sh

You may check this for more detailed.

@morn-0
Copy link
Author

morn-0 commented Oct 4, 2022

diff --git a/include/common/types.h b/include/common/types.h
index b5aeefb8..08772bce 100644
--- a/include/common/types.h
+++ b/include/common/types.h
@@ -62,7 +62,8 @@ class FunctionInstance;
 }
 struct FuncRef {
 #if __INTPTR_WIDTH__ == 32
-  const uint32_t Padding = -1;
+//  const uint32_t Padding = -1;
+  uint32_t Padding = -1;
 #endif
   const Runtime::Instance::FunctionInstance *Ptr = nullptr;
   FuncRef() = default;
@@ -72,7 +73,8 @@ struct FuncRef {
 /// ExternRef definition.
 struct ExternRef {
 #if __INTPTR_WIDTH__ == 32
-  const uint32_t Padding = -1;
+//  const uint32_t Padding = -1;
+  uint32_t Padding = -1;
 #endif
   void *Ptr = nullptr;
   ExternRef() = default;
diff --git a/include/host/wasi/environ.h b/include/host/wasi/environ.h
index 37d97fd4..1c6bc60a 100644
--- a/include/host/wasi/environ.h
+++ b/include/host/wasi/environ.h
@@ -1017,7 +1017,7 @@ public:
   WasiExpect<void> sockGetOpt(__wasi_fd_t Fd,
                               __wasi_sock_opt_level_t SockOptLevel,
                               __wasi_sock_opt_so_t SockOptName, void *FlagPtr,
-                              uint32_t *FlagSizePtr) const noexcept {
+                              socklen_t *FlagSizePtr) const noexcept {
     auto Node = getNodeOrNull(Fd);
     if (unlikely(!Node)) {
       return WasiUnexpect(__WASI_ERRNO_BADF);
diff --git a/include/host/wasi/inode.h b/include/host/wasi/inode.h
index 151b1cc7..a0cd7ae2 100644
--- a/include/host/wasi/inode.h
+++ b/include/host/wasi/inode.h
@@ -595,7 +595,7 @@ public:

   WasiExpect<void> sockGetOpt(__wasi_sock_opt_level_t SockOptLevel,
                               __wasi_sock_opt_so_t SockOptName, void *FlagPtr,
-                              uint32_t *FlagSizePtr) const noexcept;
+                              socklen_t *FlagSizePtr) const noexcept;

   WasiExpect<void> sockSetOpt(__wasi_sock_opt_level_t SockOptLevel,
                               __wasi_sock_opt_so_t SockOptName, void *FlagPtr,
diff --git a/include/host/wasi/vinode.h b/include/host/wasi/vinode.h
index d47bf368..8bda57e4 100644
--- a/include/host/wasi/vinode.h
+++ b/include/host/wasi/vinode.h
@@ -654,7 +654,7 @@ public:

   WasiExpect<void> sockGetOpt(__wasi_sock_opt_level_t SockOptLevel,
                               __wasi_sock_opt_so_t SockOptName, void *FlagPtr,
-                              uint32_t *FlagSizePtr) const noexcept {
+                              socklen_t *FlagSizePtr) const noexcept {
     return Node.sockGetOpt(SockOptLevel, SockOptName, FlagPtr, FlagSizePtr);
   }

diff --git a/include/host/wasi/wasifunc.h b/include/host/wasi/wasifunc.h
index 2b8953e8..ad1f0969 100644
--- a/include/host/wasi/wasifunc.h
+++ b/include/host/wasi/wasifunc.h
@@ -454,7 +454,7 @@ public:

   Expect<uint32_t> body(const Runtime::CallingFrame &Frame, int32_t Fd,
                         uint32_t SockOptLevel, uint32_t SockOptName,
-                        uint32_t FlagPtr, uint32_t FlagSizePtr);
+                        uint32_t FlagPtr, socklen_t FlagSizePtr);
 };

 class WasiSockSetOpt : public Wasi<WasiSockSetOpt> {
diff --git a/lib/host/wasi/CMakeLists.txt b/lib/host/wasi/CMakeLists.txt
index 2f49c618..77ea798a 100644
--- a/lib/host/wasi/CMakeLists.txt
+++ b/lib/host/wasi/CMakeLists.txt
@@ -29,12 +29,12 @@ target_link_libraries(wasmedgeHostModuleWasi
   wasmedgeSystem
 )

-if(NOT APPLE AND NOT WIN32 AND NOT ANDROID)
-  target_link_libraries(wasmedgeHostModuleWasi
-    PUBLIC
-    rt
-  )
-endif()
+#if(NOT APPLE AND NOT WIN32 AND NOT ANDROID)
+#  target_link_libraries(wasmedgeHostModuleWasi
+#    PUBLIC
+#    rt
+#  )
+#endif()

 if(WIN32)
   target_link_libraries(wasmedgeHostModuleWasi
diff --git a/lib/host/wasi/inode-linux.cpp b/lib/host/wasi/inode-linux.cpp
index a3ed7004..fc31c691 100644
--- a/lib/host/wasi/inode-linux.cpp
+++ b/lib/host/wasi/inode-linux.cpp
@@ -1146,7 +1146,7 @@ WasiExpect<void> INode::sockShutdown(__wasi_sdflags_t SdFlags) const noexcept {
 WasiExpect<void> INode::sockGetOpt(__wasi_sock_opt_level_t SockOptLevel,
                                    __wasi_sock_opt_so_t SockOptName,
                                    void *FlagPtr,
-                                   uint32_t *FlagSizePtr) const noexcept {
+                                   socklen_t *FlagSizePtr) const noexcept {
   auto SysSockOptLevel = toSockOptLevel(SockOptLevel);
   auto SysSockOptName = toSockOptSoName(SockOptName);
   if (SockOptName == __WASI_SOCK_OPT_SO_ERROR) {
diff --git a/lib/host/wasi/linux.h b/lib/host/wasi/linux.h
index 05820b88..4c1f7dc4 100644
--- a/lib/host/wasi/linux.h
+++ b/lib/host/wasi/linux.h
@@ -319,7 +319,11 @@ inline constexpr int toAdvice(__wasi_advice_t Advice) noexcept {
   }
 }

+#if !defined __ANDROID__ || defined __aarch64__ || defined __x86_64__
 inline constexpr __wasi_filetype_t fromFileType(mode_t Mode) noexcept {
+#else
+inline constexpr __wasi_filetype_t fromFileType(unsigned int Mode) noexcept {
+#endif
   switch (Mode & S_IFMT) {
   case S_IFBLK:
     return __WASI_FILETYPE_BLOCK_DEVICE;
diff --git a/lib/host/wasi/wasifunc.cpp b/lib/host/wasi/wasifunc.cpp
index d7c3b99c..60f201fa 100644
--- a/lib/host/wasi/wasifunc.cpp
+++ b/lib/host/wasi/wasifunc.cpp
@@ -2089,7 +2089,7 @@ Expect<uint32_t> WasiSockShutdown::body(const Runtime::CallingFrame &,
 Expect<uint32_t> WasiSockGetOpt::body(const Runtime::CallingFrame &Frame,
                                       int32_t Fd, uint32_t SockOptLevel,
                                       uint32_t SockOptName, uint32_t FlagPtr,
-                                      uint32_t FlagSizePtr) {
+                                      socklen_t FlagSizePtr) {
   auto *MemInst = Frame.getMemoryByIndex(0);
   if (MemInst == nullptr) {
     return __WASI_ERRNO_FAULT;
@@ -2109,7 +2109,7 @@ Expect<uint32_t> WasiSockGetOpt::body(const Runtime::CallingFrame &Frame,
     WasiSockOptName = *Res;
   }

-  uint32_t *InnerFlagSizePtr = MemInst->getPointer<uint32_t *>(FlagSizePtr);
+  socklen_t *InnerFlagSizePtr = MemInst->getPointer<socklen_t *>(FlagSizePtr);
   if (InnerFlagSizePtr == nullptr) {
     return __WASI_ERRNO_FAULT;
   }
diff --git a/lib/system/allocator.cpp b/lib/system/allocator.cpp
index d20b5e19..4b91b98e 100644
--- a/lib/system/allocator.cpp
+++ b/lib/system/allocator.cpp
@@ -52,8 +52,11 @@ namespace WasmEdge {

 namespace {
 static inline constexpr const uint64_t kPageSize = UINT64_C(65536);
+#if defined(HAVE_MMAP) && defined(__x86_64__) || defined(__aarch64__) ||       \
+    WASMEDGE_OS_WINDOWS
 static inline constexpr const uint64_t k4G = UINT64_C(0x100000000);
 static inline constexpr const uint64_t k12G = UINT64_C(0x300000000);
+#endif

 } // namespace

diff --git a/utils/android/standalone/build_for_android.sh b/utils/android/standalone/build_for_android.sh
index 6f50107d..fa9ee8ee 100755
--- a/utils/android/standalone/build_for_android.sh
+++ b/utils/android/standalone/build_for_android.sh
@@ -11,7 +11,7 @@ WASMEDGE_ROOT_PATH=$(dirname $(dirname $(dirname $(dirname $0))))

 cd ${WASMEDGE_ROOT_PATH}

-if ! cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_BUILD_AOT_RUNTIME=OFF -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=23 -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a -DCMAKE_ANDROID_NDK=$ANDROID_NDK_HOME -DCMAKE_ANDROID_STL_TYPE=c++_static; then
+if ! cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_BUILD_AOT_RUNTIME=OFF -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=23 -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a -DCMAKE_ANDROID_NDK=$ANDROID_NDK_HOME -DCMAKE_ANDROID_STL_TYPE=c++_static; then
     echo === CMakeOutput.log ===
     cat build/CMakeFiles/CMakeOutput.log
     echo === CMakeError.log ===

armv7-patch.txt

This patch allowed me to compile armv7 correctly.
Well, I don't know much about c++, would you consider merging it into the main line if it doesn't affect it?

@hydai
Copy link
Member

hydai commented Oct 5, 2022

We can have this in a PR, however, there is something that needs to be modified such as changing the build_for_android.sh should be compatible with both armv8 and armv7-a.

@hydai
Copy link
Member

hydai commented Jun 13, 2023

Hi @morn-0
We fixed the building issues on the armv7l platform: https://github.com/WasmEdge/WasmEdge/pull/2573/files and planned to ship it in the 0.13.0 release. Please let me know if this fixes your issue. Thanks.

@hangedfish
Copy link
Collaborator

Hi @morn-0 We fixed the building issues on the armv7l platform: https://github.com/WasmEdge/WasmEdge/pull/2573/files and planned to ship it in the 0.13.0 release. Please let me know if this fixes your issue. Thanks.

Failed to build in WameEdge-0.13.4 source code.

NDK Version is 26b

vscode ➜ /workspaces/WasmEdge-0.13.4 $ cmake -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_BUILD_PACKAGE="TGZ" -DWASMEDGE_BUILD_AOT_RUNTIME=OFF -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=23 -DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a -DCMAKE_ANDROID_NDK=$ANDROID_NDK_HOME -DCMAKE_ANDROID_STL_TYPE=c++_static
-- Android: Targeting API '23' with architecture 'arm', ABI 'armeabi-v7a', and processor 'armv7-a'
-- Android: Selected unified Clang toolchain
-- The C compiler identification is Clang 17.0.2
-- The CXX compiler identification is Clang 17.0.2
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
fatal: not a git repository (or any parent up to mount point /workspaces)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
-- Looking for C++ include filesystem
-- Looking for C++ include filesystem - found
-- Performing Test CXX_FILESYSTEM_NO_LINK_NEEDED
-- Performing Test CXX_FILESYSTEM_NO_LINK_NEEDED - Success
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Looking for mmap
-- Looking for mmap - found
-- Looking for C++ include pwd.h
-- Looking for C++ include pwd.h - found
-- Build spdlog: 1.11.0
-- Build type: Release
-- Configuring done
-- Generating done
-- Build files have been written to: /workspaces/WasmEdge-0.13.4/build
vscode ➜ /workspaces/WasmEdge-0.13.4 $ cmake --build build
[59/83] Building C object thirdparty/ggml/CMakeFiles/utilGgml.dir/ggml-alloc.c.o
FAILED: thirdparty/ggml/CMakeFiles/utilGgml.dir/ggml-alloc.c.o 
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=armv7-none-linux-androideabi23  -I/workspaces/WasmEdge-0.13.4/thirdparty/ggml -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -fexceptions -O3 -DNDEBUG -flto=thin -fPIC -Wall -Wextra -Werror -Wno-error=pedantic -Wno-psabi -Wno-c++20-designator -Wno-c99-extensions -Wno-covered-switch-default -Wno-documentation-unknown-command -Wno-error=nested-anon-types -Wno-error=old-style-cast -Wno-error=unused-command-line-argument -Wno-error=unknown-warning-option -Wno-ctad-maybe-unsupported -Wno-gnu-anonymous-struct -Wno-keyword-macro -Wno-language-extension-token -Wno-newline-eof -Wno-shadow-field-in-constructor -Wno-signed-enum-bitfield -Wno-switch-enum -Wno-undefined-func-template -Wno-error=shadow-field -Wno-reserved-identifier -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-function -Wno-missing-braces -MD -MT thirdparty/ggml/CMakeFiles/utilGgml.dir/ggml-alloc.c.o -MF thirdparty/ggml/CMakeFiles/utilGgml.dir/ggml-alloc.c.o.d -o thirdparty/ggml/CMakeFiles/utilGgml.dir/ggml-alloc.c.o -c /workspaces/WasmEdge-0.13.4/thirdparty/ggml/ggml-alloc.c
/workspaces/WasmEdge-0.13.4/thirdparty/ggml/ggml-alloc.c:264:45: error: implicit conversion from 'unsigned long long' to 'size_t' (aka 'unsigned int') changes value from 1099511627776 to 0 [-Werror,-Wconstant-conversion]
static const size_t MEASURE_MAX_SIZE  = 1ULL<<40; // 1 TB
                    ~~~~~~~~~~~~~~~~    ~~~~^~~~
1 error generated.
[61/83] Building CXX object lib/host/wasi/CMakeFiles/wasmedgeHostModuleWasi.dir/inode-linux.cpp.o
FAILED: lib/host/wasi/CMakeFiles/wasmedgeHostModuleWasi.dir/inode-linux.cpp.o 
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=armv7-none-linux-androideabi23 -DSPDLOG_COMPILED_LIB -I/workspaces/WasmEdge-0.13.4/thirdparty -I/workspaces/WasmEdge-0.13.4/build/lib/system -I/workspaces/WasmEdge-0.13.4/build/include -I/workspaces/WasmEdge-0.13.4/include -I/workspaces/WasmEdge-0.13.4/build/_deps/spdlog-src/include -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -fexceptions -frtti -stdlib=libc++ -O3 -DNDEBUG -flto=thin -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -Werror -Wno-error=pedantic -Wno-psabi -Wno-c++20-designator -Wno-c99-extensions -Wno-covered-switch-default -Wno-documentation-unknown-command -Wno-error=nested-anon-types -Wno-error=old-style-cast -Wno-error=unused-command-line-argument -Wno-error=unknown-warning-option -Wno-ctad-maybe-unsupported -Wno-gnu-anonymous-struct -Wno-keyword-macro -Wno-language-extension-token -Wno-newline-eof -Wno-shadow-field-in-constructor -Wno-signed-enum-bitfield -Wno-switch-enum -Wno-undefined-func-template -Wno-error=shadow-field -Wno-reserved-identifier -pthread -MD -MT lib/host/wasi/CMakeFiles/wasmedgeHostModuleWasi.dir/inode-linux.cpp.o -MF lib/host/wasi/CMakeFiles/wasmedgeHostModuleWasi.dir/inode-linux.cpp.o.d -o lib/host/wasi/CMakeFiles/wasmedgeHostModuleWasi.dir/inode-linux.cpp.o -c /workspaces/WasmEdge-0.13.4/lib/host/wasi/inode-linux.cpp
/workspaces/WasmEdge-0.13.4/lib/host/wasi/inode-linux.cpp:613:23: error: call to 'fromFileType' is ambiguous
  Filestat.filetype = fromFileType(SysFStat.st_mode);
                      ^~~~~~~~~~~~
/workspaces/WasmEdge-0.13.4/lib/host/wasi/linux.h:323:36: note: candidate function
inline constexpr __wasi_filetype_t fromFileType(mode_t Mode) noexcept {
                                   ^
/workspaces/WasmEdge-0.13.4/lib/host/wasi/linux.h:343:36: note: candidate function
inline constexpr __wasi_filetype_t fromFileType(uint8_t Type) noexcept {
                                   ^
/workspaces/WasmEdge-0.13.4/lib/host/wasi/inode-linux.cpp:1374:10: error: call to 'fromFileType' is ambiguous
  return fromFileType(Stat->st_mode);
         ^~~~~~~~~~~~
/workspaces/WasmEdge-0.13.4/lib/host/wasi/linux.h:323:36: note: candidate function
inline constexpr __wasi_filetype_t fromFileType(mode_t Mode) noexcept {
                                   ^
/workspaces/WasmEdge-0.13.4/lib/host/wasi/linux.h:343:36: note: candidate function
inline constexpr __wasi_filetype_t fromFileType(uint8_t Type) noexcept {
                                   ^
2 errors generated.
[72/83] Building CXX object lib/vm/CMakeFiles/wasmedgeVM.dir/vm.cpp.o
ninja: build stopped: subcommand failed.

@hydai
Copy link
Member

hydai commented Oct 25, 2023

Hi @hangedfish
Please use the following patch to disable the ggml dependency:

#2802 (comment)

@hangedfish
Copy link
Collaborator

Hi @hangedfish Please use the following patch to disable the ggml dependency:

#2802 (comment)

Fail to build inode-linux.cpp

vscode ➜ /workspaces/WasmEdge-0.13.4 $ cmake --build build
[62/77] Building CXX object lib/host/wasi/CMakeFiles/wasmedgeHostModuleWasi.dir/inode-linux.cpp.o
FAILED: lib/host/wasi/CMakeFiles/wasmedgeHostModuleWasi.dir/inode-linux.cpp.o 
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ --target=armv7-none-linux-androideabi23 -DSPDLOG_COMPILED_LIB -I/workspaces/WasmEdge-0.13.4/thirdparty -I/workspaces/WasmEdge-0.13.4/build/lib/system -I/workspaces/WasmEdge-0.13.4/build/include -I/workspaces/WasmEdge-0.13.4/include -I/workspaces/WasmEdge-0.13.4/build/_deps/spdlog-src/include -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -fexceptions -frtti -stdlib=libc++ -O3 -DNDEBUG -flto=thin -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -Werror -Wno-error=pedantic -Wno-psabi -Wno-c++20-designator -Wno-c99-extensions -Wno-covered-switch-default -Wno-documentation-unknown-command -Wno-error=nested-anon-types -Wno-error=old-style-cast -Wno-error=unused-command-line-argument -Wno-error=unknown-warning-option -Wno-ctad-maybe-unsupported -Wno-gnu-anonymous-struct -Wno-keyword-macro -Wno-language-extension-token -Wno-newline-eof -Wno-shadow-field-in-constructor -Wno-signed-enum-bitfield -Wno-switch-enum -Wno-undefined-func-template -Wno-error=shadow-field -Wno-reserved-identifier -pthread -MD -MT lib/host/wasi/CMakeFiles/wasmedgeHostModuleWasi.dir/inode-linux.cpp.o -MF lib/host/wasi/CMakeFiles/wasmedgeHostModuleWasi.dir/inode-linux.cpp.o.d -o lib/host/wasi/CMakeFiles/wasmedgeHostModuleWasi.dir/inode-linux.cpp.o -c /workspaces/WasmEdge-0.13.4/lib/host/wasi/inode-linux.cpp
/workspaces/WasmEdge-0.13.4/lib/host/wasi/inode-linux.cpp:613:23: error: call to 'fromFileType' is ambiguous
  Filestat.filetype = fromFileType(SysFStat.st_mode);
                      ^~~~~~~~~~~~
/workspaces/WasmEdge-0.13.4/lib/host/wasi/linux.h:323:36: note: candidate function
inline constexpr __wasi_filetype_t fromFileType(mode_t Mode) noexcept {
                                   ^
/workspaces/WasmEdge-0.13.4/lib/host/wasi/linux.h:343:36: note: candidate function
inline constexpr __wasi_filetype_t fromFileType(uint8_t Type) noexcept {
                                   ^
/workspaces/WasmEdge-0.13.4/lib/host/wasi/inode-linux.cpp:1374:10: error: call to 'fromFileType' is ambiguous
  return fromFileType(Stat->st_mode);
         ^~~~~~~~~~~~
/workspaces/WasmEdge-0.13.4/lib/host/wasi/linux.h:323:36: note: candidate function
inline constexpr __wasi_filetype_t fromFileType(mode_t Mode) noexcept {
                                   ^
/workspaces/WasmEdge-0.13.4/lib/host/wasi/linux.h:343:36: note: candidate function
inline constexpr __wasi_filetype_t fromFileType(uint8_t Type) noexcept {
                                   ^
2 errors generated.
[71/77] Building CXX object lib/vm/CMakeFiles/wasmedgeVM.dir/vm.cpp.o
ninja: build stopped: subcommand failed

@hetvishastri
Copy link
Contributor

Hi,
This is mostly caused by two same name functions fromFileType in /lib/host/wasi/linux.h. I solved this by explicitly specifying the type of the argument when calling the fromFileType from lib/host/wasi/inode-linux.cpp.

Line 613

  // Filestat.filetype = fromFileType(SysFStat.st_mode);
  Filestat.filetype = fromFileType(static_cast<mode_t>(SysFStat.st_mode));

Line 1374

__wasi_filetype_t INode::unsafeFiletype() const noexcept {
  // return fromFileType(Stat->st_mode);
  return fromFileType(static_cast<mode_t>(Stat->st_mode));
}

@hydai
Copy link
Member

hydai commented Feb 25, 2024

Hi @hetvishastri
Would you like to create a PR to fix this?

@hetvishastri
Copy link
Contributor

hetvishastri commented Feb 25, 2024

Hi @hydai,
Yes I can do this. Thank you.
After solving this error I was facing the error as mentioned in #3239.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants