WasmEdge / WasmEdge

WasmEdge is a lightweight, high-performance, and extensible WebAssembly runtime for cloud native, edge, and decentralized applications. It powers serverless apps, embedded functions, microservices, smart contracts, and IoT devices.
https://WasmEdge.org
Apache License 2.0
8.5k stars 765 forks source link

bug: wasmedge 0.14.0 build failure [Homebrew] #3427

Closed chenrui333 closed 2 months ago

chenrui333 commented 5 months ago

Summary

👋 trying to build the latest release, but run into some build issue. The error log is as below:

error build log ``` [99/105] : && /opt/homebrew/Cellar/cmake/3.29.3/bin/cmake -E rm -f lib/driver/libwasmedgeDriver.a && "/opt/homebrew/Cellar/llvm/18.1.6/bin/llvm-ar" qc lib/driver/libwasmedgeDriver.a lib/driver/CMakeFiles/wasmedgeDriver.dir/compilerTool.cpp.o lib/driver/CMakeFiles/wasmedgeDriver.dir/runtimeTool.cpp.o lib/driver/CMakeFiles/wasmedgeDriver.dir/fuzzTool.cpp.o lib/driver/CMakeFiles/wasmedgeDriver.dir/fuzzPO.cpp.o lib/driver/CMakeFiles/wasmedgeDriver.dir/uniTool.cpp.o && "/opt/homebrew/Cellar/llvm/18.1.6/bin/llvm-ranlib" lib/driver/libwasmedgeDriver.a && /opt/homebrew/Cellar/cmake/3.29.3/bin/cmake -E touch lib/driver/libwasmedgeDriver.a && : [100/105] : && /opt/homebrew/opt/llvm/bin/clang++ -stdlib=libc++ -O3 -DNDEBUG -flto=thin -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -dynamiclib -Wl,-headerpad_max_install_names -stdlib=libc++ -lc++abi -current_version 0.1.0 -o lib/api/libwasmedge.0.1.0.dylib -install_name @rpath/libwasmedge.0.dylib lib/api/CMakeFiles/wasmedgeCAPI.dir/wasmedge.cpp.o -Wl,-rpath,/opt/homebrew/opt/llvm/lib /opt/homebrew/lib/libspdlog.1.13.0.dylib lib/driver/libwasmedgeDriver.a lib/vm/libwasmedgeVM.a lib/plugin/libwasmedgePlugin.a lib/validator/libwasmedgeValidator.a lib/executor/libwasmedgeExecutor.a lib/host/wasi/libwasmedgeHostModuleWasi.a lib/loader/libwasmedgeLoader.a lib/loader/libwasmedgeLoaderFileMgr.a -ldl lib/po/libwasmedgePO.a lib/aot/libwasmedgeAOT.a thirdparty/blake3/libutilBlake3.a lib/llvm/libwasmedgeLLVM.a lib/system/libwasmedgeSystem.a lib/common/libwasmedgeCommon.a /opt/homebrew/lib/libspdlog.1.13.0.dylib /opt/homebrew/lib/libfmt.10.2.1.dylib /opt/homebrew/opt/llvm/lib/liblldMachO.a /opt/homebrew/opt/llvm/lib/liblldCommon.a /opt/homebrew/opt/llvm/lib/libLLVM.dylib /opt/homebrew/lib/libfmt.10.2.1.dylib && : FAILED: lib/api/libwasmedge.0.1.0.dylib : && /opt/homebrew/opt/llvm/bin/clang++ -stdlib=libc++ -O3 -DNDEBUG -flto=thin -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -dynamiclib -Wl,-headerpad_max_install_names -stdlib=libc++ -lc++abi -current_version 0.1.0 -o lib/api/libwasmedge.0.1.0.dylib -install_name @rpath/libwasmedge.0.dylib lib/api/CMakeFiles/wasmedgeCAPI.dir/wasmedge.cpp.o -Wl,-rpath,/opt/homebrew/opt/llvm/lib /opt/homebrew/lib/libspdlog.1.13.0.dylib lib/driver/libwasmedgeDriver.a lib/vm/libwasmedgeVM.a lib/plugin/libwasmedgePlugin.a lib/validator/libwasmedgeValidator.a lib/executor/libwasmedgeExecutor.a lib/host/wasi/libwasmedgeHostModuleWasi.a lib/loader/libwasmedgeLoader.a lib/loader/libwasmedgeLoaderFileMgr.a -ldl lib/po/libwasmedgePO.a lib/aot/libwasmedgeAOT.a thirdparty/blake3/libutilBlake3.a lib/llvm/libwasmedgeLLVM.a lib/system/libwasmedgeSystem.a lib/common/libwasmedgeCommon.a /opt/homebrew/lib/libspdlog.1.13.0.dylib /opt/homebrew/lib/libfmt.10.2.1.dylib /opt/homebrew/opt/llvm/lib/liblldMachO.a /opt/homebrew/opt/llvm/lib/liblldCommon.a /opt/homebrew/opt/llvm/lib/libLLVM.dylib /opt/homebrew/lib/libfmt.10.2.1.dylib && : Undefined symbols for architecture arm64: "std::exception_ptr::__from_native_exception_pointer(void*)", referenced from: std::__1::promise, WasmEdge::ValType>, std::__1::allocator, WasmEdge::ValType>>>, WasmEdge::ErrCode>>::~promise() in "___cxa_init_primary_exception", referenced from: std::__1::promise, WasmEdge::ValType>, std::__1::allocator, WasmEdge::ValType>>>, WasmEdge::ErrCode>>::~promise() in ld: symbol(s) not found for architecture arm64 clang++: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed. ```

full build log, https://github.com/Homebrew/homebrew-core/actions/runs/9231184943/job/25400682180?pr=172690 relates to Homebrew/homebrew-core#172690

Reproduction steps

basic cmake build

or

brew install -s https://raw.githubusercontent.com/Homebrew/homebrew-core/b80715459bf7318851374a6d48057172ca8dcc37/Formula/w/wasmedge.rb

Components

CLI

WasmEdge Version or Commit you used

0.14.0

Operating system information

macos

Hardware Architecture

x86 and aarch64

Compiler flags and options

==> cmake -S . -B build -G Ninja -DWASMEDGE_BUILD_TESTS=OFF -DWASMEDGE_BUILD_TOOLS=ON -DCMAKE_MESSAGE_LOG_LEVEL=DEBUG -DCMAKE_INSTALL_PREFIX=/opt/homebrew/Cellar/wasmedge/0.14.0 -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=/opt/homebrew/Library/Homebrew/cmake/trap_fetchcontent_provider.cmake -Wno-dev -DBUILD_TESTING=OFF -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk
-- The CXX compiler identification is Clang 18.1.6
-- The C compiler identification is Clang 18.1.6
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/homebrew/opt/llvm/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/homebrew/opt/llvm/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
fatal: not a git repository (or any of the parent directories): .git
-- 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
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Looking for mmap
-- Looking for mmap - found
-- Looking for C++ include pwd.h
-- Looking for C++ include pwd.h - found
-- Performing Test HAVE_FFI_CALL
-- Performing Test HAVE_FFI_CALL - Success
-- Found FFI: /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/lib/libffi.tbd
-- Looking for histedit.h
-- Looking for histedit.h - found
-- Found LibEdit: /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include (found version "2.11")
-- Performing Test Terminfo_LINKABLE
-- Performing Test Terminfo_LINKABLE - Success
-- Found Terminfo: /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/lib/libcurses.tbd
-- Found ZLIB: /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/lib/libz.tbd (found version "1.2.12")
-- Found zstd: /opt/homebrew/lib/libzstd.dylib
-- Found LibXml2: /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/lib/libxml2.tbd (found version "2.9.13")
-- Linker detection: Apple
-- Performing Test SUPPORT_EXCLUDE_LIBS
-- Performing Test SUPPORT_EXCLUDE_LIBS - Failed
-- The ASM compiler identification is Clang with GNU-like command-line
-- Found assembler: /opt/homebrew/opt/llvm/bin/clang
-- Configuring done (3.3s)
-- Generating done (0.0s)
hydai commented 4 months ago

Hi @chenrui333 Thanks for letting us know. I am checking this.

However, I cannot reproduce your second command:

brew install -s https://raw.githubusercontent.com/Homebrew/homebrew-core/b80715459bf7318851374a6d48057172ca8dcc37/Formula/w/wasmedge.rb

==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> New Formulae
vedic
==> New Casks
font-playwrite-au-nsw      font-playwrite-ca          font-playwrite-id          font-playwrite-mx          font-playwrite-us-trad
font-playwrite-au-qld      font-playwrite-de-la       font-playwrite-ie          font-playwrite-ng-modern   font-playwrite-za
font-playwrite-au-sa       font-playwrite-es          font-playwrite-in          font-playwrite-nz          hopper-disassembler
font-playwrite-au-tas      font-playwrite-es-deco     font-playwrite-it-moderna  font-playwrite-tz          mac-mouse-fix@2
font-playwrite-au-vic      font-playwrite-fr-moderne  font-playwrite-it-trad     font-playwrite-us-modern

You have 36 outdated formulae and 1 outdated cask installed.

Error: Non-checksummed download of wasmedge formula file from an arbitrary URL is unsupported! `brew extract` or `brew create` and `brew tap-new` to create a formula file in a tap on GitHub instead.

And for the cmake command, should I use cmake -S . -B build -G Ninja -DWASMEDGE_BUILD_TESTS=OFF -DWASMEDGE_BUILD_TOOLS=ON -DCMAKE_MESSAGE_LOG_LEVEL=DEBUG -DCMAKE_INSTALL_PREFIX=/opt/homebrew/Cellar/wasmedge/0.14.0 -DCMAKE_INSTALL_LIBDIR=lib -DCMAKE_BUILD_TYPE=Release -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=/opt/homebrew/Library/Homebrew/cmake/trap_fetchcontent_provider.cmake -Wno-dev -DBUILD_TESTING=OFF -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk?

I got the following output:

-- The CXX compiler identification is AppleClang 15.0.0.15000309
-- The C compiler identification is AppleClang 15.0.0.15000309
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- 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
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Looking for mmap
-- Looking for mmap - found
-- Looking for C++ include pwd.h
-- Looking for C++ include pwd.h - found
-- Performing Test HAVE_FFI_CALL
-- Performing Test HAVE_FFI_CALL - Success
-- Found FFI: /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/lib/libffi.tbd
-- Looking for histedit.h
-- Looking for histedit.h - found
-- Found LibEdit: /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include (found version "2.11")
-- Performing Test Terminfo_LINKABLE
-- Performing Test Terminfo_LINKABLE - Success
-- Found Terminfo: /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/lib/libcurses.tbd
-- Found ZLIB: /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/lib/libz.tbd (found version "1.2.12")
-- Found zstd: /opt/homebrew/lib/libzstd.dylib
-- Found LibXml2: /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/lib/libxml2.tbd (found version "2.9.13")
-- Linker detection: Apple
-- Performing Test SUPPORT_EXCLUDE_LIBS
-- Performing Test SUPPORT_EXCLUDE_LIBS - Failed
-- Trying FETCHCONTENT_MAKEAVAILABLE_SERIAL dependency provider for fmt
CMake Error at /opt/homebrew/Library/Homebrew/cmake/trap_fetchcontent_provider.cmake:10 (message):
  Refusing to populate dependency 'fmt' with FetchContent while building in
  Homebrew, please use a formula dependency or add a resource to the formula.
Call Stack (most recent call first):
  /opt/homebrew/Cellar/cmake/3.29.2/share/cmake/Modules/FetchContent.cmake:2017:EVAL:1 (trap_fetchcontent_provider)
  /opt/homebrew/Cellar/cmake/3.29.2/share/cmake/Modules/FetchContent.cmake:2017 (cmake_language)
  lib/common/CMakeLists.txt:13 (FetchContent_MakeAvailable)

-- Configuring incomplete, errors occurred!

It seems we should change the way to get fmt library.

chenrui333 commented 4 months ago

interesting I dont see it, if you use spdlog you dont need to pull fmt dep, according to your cmake file.

hydai commented 4 months ago

Do you have detailed commands, environments, or toolchains on macOS so I can reproduce the Undefined symbols for architecture arm64 error?

Here is my command on macOS to build wasmedge, but I cannot run into the same error:

Configure

``` $ cmake -Bbuild -GNinja . -- The CXX compiler identification is AppleClang 15.0.0.15000309 -- The C compiler identification is AppleClang 15.0.0.15000309 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- 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 -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE -- Looking for mmap -- Looking for mmap - found -- Looking for C++ include pwd.h -- Looking for C++ include pwd.h - found -- Performing Test HAVE_FFI_CALL -- Performing Test HAVE_FFI_CALL - Success -- Found FFI: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/lib/libffi.tbd -- Looking for histedit.h -- Looking for histedit.h - found -- Found LibEdit: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/include (found version "2.11") -- Performing Test Terminfo_LINKABLE -- Performing Test Terminfo_LINKABLE - Success -- Found Terminfo: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/lib/libcurses.tbd -- Found ZLIB: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/lib/libz.tbd (found version "1.2.12") -- Found zstd: /opt/homebrew/lib/libzstd.dylib -- Found LibXml2: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/lib/libxml2.tbd (found version "2.9.13") -- Linker detection: Apple -- Performing Test SUPPORT_EXCLUDE_LIBS -- Performing Test SUPPORT_EXCLUDE_LIBS - Failed -- Version: 10.2.1 -- Build type: RelWithDebInfo -- Performing Test HAS_NULLPTR_WARNING -- Performing Test HAS_NULLPTR_WARNING - Success -- Build spdlog: 1.13.0 -- Build type: RelWithDebInfo -- The ASM compiler identification is AppleClang -- Found assembler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- Configuring done (20.9s) -- Generating done (0.1s) -- Build files have been written to: /Users/hydai/workspace/WasmEdge/build ```

Build

``` cmake --build build [110/115] Linking CXX shared library lib/api/libwasmedge.0.1.0.dylib ld: warning: ignoring duplicate libraries: '_deps/spdlog-build/libspdlog.a' [115/115] Linking CXX executable tools/wasmedge/wasmedge ```
chenrui333 commented 4 months ago

I am basically seeing the same thing on the ci, https://github.com/Homebrew/homebrew-core/actions/runs/9231184943/job/25400681826?pr=172690#step:3:746

let me see if I can add some CI in here so that we can make it more reproducible

ibmibmibm commented 4 months ago

looks like clang is using libc++ from brew, but links to libc++ form macosx sdk. that undefined symbol is provided in newest libc++, but not in macosx sdk.

chenrui333 commented 2 months ago

close via https://github.com/Homebrew/homebrew-core/pull/178696

chenrui333 commented 2 months ago

Thanks for the helpful notes. 👍