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

bug: link to static lib 0.14.0 encounters undefined reference to fmtt::v10::*** #3463

Closed
CaptainVincent opened this issue Jun 10, 2024 · 8 comments · Fixed by WasmEdge/wasmedge-rust-sdk#118 or WasmEdge/wasmedge-rust-sdk#123
Assignees
Labels
bug Something isn't working

Comments

@CaptainVincent
Copy link
Member

Summary

As the title, the new released version of the static library cannot be linked.

Current State

The symbols related to fmt are undefined.

Expected State

Without compile error.

Reproduction steps

  1. When releasing the current Rust SDK, we forgot to update the archives version and checksum. You could use mine for test
    https://github.com/CaptainVincent/wasmedge-rust-sdk/tree/update-archives
  2. Create a new cargo proj
    Cargo.toml
[package]
name = "test_wasmedge_static_link"
version = "0.1.0"
edition = "2021"

[dependencies]
wasmedge-sdk = { git = "https://github.com/CaptainVincent/wasmedge-rust-sdk.git", branch = "update-archives" }

[features]
default = ["standalone", "static"]
standalone = ["wasmedge-sdk/standalone"]
static = ["wasmedge-sdk/static"]
wasi_nn = ["wasmedge-sdk/wasi_nn"]

src/main.rs

use wasmedge_sdk::wasi::WasiModule;

fn main() {
    let mut _wasi = WasiModule::create(None, None, Some(vec!["/:/"])).unwrap();
    println!("Hello, world!");
}
  1. run cargo build

Screenshots

None

Any logs you want to share for showing the specific issue

err.log

Components

Rust SDK

WasmEdge Version or Commit you used

0.14.0

Operating system information

Ubuntu 22.04.4 LTS

Hardware Architecture

x86_64

Compiler flags and options

Appendix:

I tried to verify this issue in the pure WasmEdge compile flow using the following flags.

cmake -GNinja -Bbuild -DCMAKE_BUILD_TYPE=Release -DWASMEDGE_BUILD_SHARED_LIB=Off -DWASMEDGE_BUILD_STATIC_LIB=On -DWASMEDGE_LINK_TOOLS_STATIC=On -DWASMEDGE_BUILD_PLUGINS=Off -DWASMEDGE_BUILD_AOT_RUNTIME=OFF

But when I tried to compile the static library and link it to the tool, I encountered the following error, which prevented me from verifying:

ninja: error: '/usr/lib/llvm-11/lib/libPolly.a', needed by 'tools/wasmedge/wasmedgec', missing and no known rule to make it
@CaptainVincent CaptainVincent added the bug Something isn't working label Jun 10, 2024
@hydai
Copy link
Member

hydai commented Jun 10, 2024

@q82419
We have to link the fmt library statically. The runwasi project requires this statical build.

@CaptainVincent
The environment must provide the libPolly.a dependency if the AOT is needed in this asset. However, you can use WASMEDGE_USE_LLVM=OFF to turn it off as a workaround. The runwasi project will not need the AOT feature due to the execution pipeline.

@CaptainVincent CaptainVincent self-assigned this Jun 11, 2024
@CaptainVincent
Copy link
Member Author

CaptainVincent commented Jun 24, 2024

Quick update:
Try linking static libfmt.a in SDK build.rs but still get error, still trying to find possible causes.

  = note: /usr/bin/ld: /home/vincent/workspace/_docker/_ctr/test_wasmedge_static_link/target/debug/deps/libwasmedge_sys-bb01cfa1ba8bae59.rlib(section.cpp.o): in function `WasmEdge::Loader::Loader::loadSection(WasmEdge::AST::Component::CoreTypeSection&)':
          section.cpp:(.text+0x3952): undefined reference to `WasmEdge::Loader::Loader::loadType(std::variant<WasmEdge::AST::FunctionType, WasmEdge::AST::Component::ModuleType>&)'
          /usr/bin/ld: /home/vincent/workspace/_docker/_ctr/test_wasmedge_static_link/target/debug/deps/libwasmedge_sys-bb01cfa1ba8bae59.rlib(section.cpp.o): in function `WasmEdge::Loader::Loader::loadSection(WasmEdge::AST::Component::TypeSection&)':
          section.cpp:(.text+0x3bb2): undefined reference to `WasmEdge::Loader::Loader::loadType(std::variant<std::variant<WasmEdge::AST::Component::PrimValType, WasmEdge::AST::Component::Record, WasmEdge::AST::Component::VariantTy, WasmEdge::AST::Component::List, WasmEdge::AST::Component::Tuple, WasmEdge::AST::Component::Flags, WasmEdge::AST::Component::Enum, WasmEdge::AST::Component::Option, WasmEdge::AST::Component::Result, WasmEdge::AST::Component::Own, WasmEdge::AST::Component::Borrow>, WasmEdge::AST::Component::FuncType, WasmEdge::AST::Component::ComponentType, WasmEdge::AST::Component::InstanceType>&)'
          /usr/bin/ld: /home/vincent/workspace/_docker/_ctr/test_wasmedge_static_link/target/debug/deps/libwasmedge_sys-bb01cfa1ba8bae59.rlib(import_export.cpp.o): in function `WasmEdge::Loader::Loader::loadImport(WasmEdge::AST::Component::Import&)':
          import_export.cpp:(.text+0x18): undefined reference to `WasmEdge::Loader::Loader::loadImportName(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
          /usr/bin/ld: import_export.cpp:(.text+0x33): undefined reference to `WasmEdge::Loader::Loader::loadExternDesc(std::variant<WasmEdge::AST::Component::DescTypeIndex, std::optional<unsigned int>, std::variant<WasmEdge::AST::Component::PrimValType, unsigned int> >&)'
          /usr/bin/ld: /home/vincent/workspace/_docker/_ctr/test_wasmedge_static_link/target/debug/deps/libwasmedge_sys-bb01cfa1ba8bae59.rlib(import_export.cpp.o): in function `WasmEdge::Loader::Loader::loadExport(WasmEdge::AST::Component::Export&)':
          import_export.cpp:(.text+0xcd): undefined reference to `WasmEdge::Loader::Loader::loadExportName(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
          /usr/bin/ld: /home/vincent/workspace/_docker/_ctr/test_wasmedge_static_link/target/debug/deps/libwasmedge_sys-bb01cfa1ba8bae59.rlib(import_export.cpp.o): in function `std::_Function_handler<cxx20::expected<void, WasmEdge::ErrCode> (std::variant<WasmEdge::AST::Component::DescTypeIndex, std::optional<unsigned int>, std::variant<WasmEdge::AST::Component::PrimValType, unsigned int> >&), WasmEdge::Loader::Loader::loadExport(WasmEdge::AST::Component::Export&)::$_0>::_M_invoke(std::_Any_data const&, std::variant<WasmEdge::AST::Component::DescTypeIndex, std::optional<unsigned int>, std::variant<WasmEdge::AST::Component::PrimValType, unsigned int> >&)':
          import_export.cpp:(.text+0x35d): undefined reference to `WasmEdge::Loader::Loader::loadExternDesc(std::variant<WasmEdge::AST::Component::DescTypeIndex, std::optional<unsigned int>, std::variant<WasmEdge::AST::Component::PrimValType, unsigned int> >&)'
          collect2: error: ld returned 1 exit status

@hydai
Copy link
Member

hydai commented Jul 13, 2024

Hi @CaptainVincent
Is this fixed?

@jprendes
Copy link
Contributor

Using the latest released build (0.14.0) and statically linking against libfmt, I see the same result as @CaptainVincent

  = note: /usr/bin/ld: /home/jprendes/Projects/runwasi2/target/x86_64-unknown-linux-gnu/debug/deps/libwasmedge_sys-33d272e10155aeef.rlib(section.cpp.o): in function `WasmEdge::Loader::Loader::loadSection(WasmEdge::AST::Component::CoreTypeSection&)':
          section.cpp:(.text+0x3952): undefined reference to `WasmEdge::Loader::Loader::loadType(std::variant<WasmEdge::AST::FunctionType, WasmEdge::AST::Component::ModuleType>&)'
          /usr/bin/ld: /home/jprendes/Projects/runwasi2/target/x86_64-unknown-linux-gnu/debug/deps/libwasmedge_sys-33d272e10155aeef.rlib(section.cpp.o): in function `WasmEdge::Loader::Loader::loadSection(WasmEdge::AST::Component::TypeSection&)':
          section.cpp:(.text+0x3bb2): undefined reference to `WasmEdge::Loader::Loader::loadType(std::variant<std::variant<WasmEdge::AST::Component::PrimValType, WasmEdge::AST::Component::Record, WasmEdge::AST::Component::VariantTy, WasmEdge::AST::Component::List, WasmEdge::AST::Component::Tuple, WasmEdge::AST::Component::Flags, WasmEdge::AST::Component::Enum, WasmEdge::AST::Component::Option, WasmEdge::AST::Component::Result, WasmEdge::AST::Component::Own, WasmEdge::AST::Component::Borrow>, WasmEdge::AST::Component::FuncType, WasmEdge::AST::Component::ComponentType, WasmEdge::AST::Component::InstanceType>&)'
          /usr/bin/ld: /home/jprendes/Projects/runwasi2/target/x86_64-unknown-linux-gnu/debug/deps/libwasmedge_sys-33d272e10155aeef.rlib(import_export.cpp.o): in function `WasmEdge::Loader::Loader::loadImport(WasmEdge::AST::Component::Import&)':
          import_export.cpp:(.text+0x18): undefined reference to `WasmEdge::Loader::Loader::loadImportName(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
          /usr/bin/ld: import_export.cpp:(.text+0x33): undefined reference to `WasmEdge::Loader::Loader::loadExternDesc(std::variant<WasmEdge::AST::Component::DescTypeIndex, std::optional<unsigned int>, std::variant<WasmEdge::AST::Component::PrimValType, unsigned int> >&)'
          /usr/bin/ld: /home/jprendes/Projects/runwasi2/target/x86_64-unknown-linux-gnu/debug/deps/libwasmedge_sys-33d272e10155aeef.rlib(import_export.cpp.o): in function `WasmEdge::Loader::Loader::loadExport(WasmEdge::AST::Component::Export&)':
          import_export.cpp:(.text+0xcd): undefined reference to `WasmEdge::Loader::Loader::loadExportName(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
          /usr/bin/ld: /home/jprendes/Projects/runwasi2/target/x86_64-unknown-linux-gnu/debug/deps/libwasmedge_sys-33d272e10155aeef.rlib(import_export.cpp.o): in function `std::_Function_handler<cxx20::expected<void, WasmEdge::ErrCode> (std::variant<WasmEdge::AST::Component::DescTypeIndex, std::optional<unsigned int>, std::variant<WasmEdge::AST::Component::PrimValType, unsigned int> >&), WasmEdge::Loader::Loader::loadExport(WasmEdge::AST::Component::Export&)::$_0>::_M_invoke(std::_Any_data const&, std::variant<WasmEdge::AST::Component::DescTypeIndex, std::optional<unsigned int>, std::variant<WasmEdge::AST::Component::PrimValType, unsigned int> >&)':
          import_export.cpp:(.text+0x35d): undefined reference to `WasmEdge::Loader::Loader::loadExternDesc(std::variant<WasmEdge::AST::Component::DescTypeIndex, std::optional<unsigned int>, std::variant<WasmEdge::AST::Component::PrimValType, unsigned int> >&)'
          collect2: error: ld returned 1 exit status
          
  = note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)

@jprendes
Copy link
Contributor

There's still an issue with missing symbols for WasmEdge::Loader. Has that also been fixed?

@L-jasmine L-jasmine reopened this Jul 29, 2024
@CaptainVincent
Copy link
Member Author

CaptainVincent commented Jul 29, 2024

Yes Not yet, wait for the next WasmEdge 0.14.1 release, which will include commit a498fb1.

@Mossaka
Copy link

Mossaka commented Nov 17, 2024

@CaptainVincent It looks like WasmEdge 0.14.1 was released in Sep: https://github.com/WasmEdge/WasmEdge/releases/tag/0.14.1

Would you say this issue is resolved? If so, can you please take a look at this one from runwasi: containerd/runwasi#607? 🙏🙏

@CaptainVincent
Copy link
Member Author

Got the message, I’ll pin our colleague responsible for releasing the WasmEdge SDK to check when they can help release the Rust crate that includes lib version 0.14.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
5 participants