bytecodealliance / componentize-py

Apache License 2.0
130 stars 13 forks source link

Unresolved symbols when building from source #86

Closed alec-deason closed 2 months ago

alec-deason commented 2 months ago

I'm trying to build the repo from source following the instructions in CONTRIBUTING.md and it works, including running cargo run -- --help and also the bindings command but when I try to run componentize I get the following error:

> cargo run --release -- -d hello.wit -w hello componentize app -o app.wasm
warning: componentize-py@0.13.3: using seed f0dd8d4b7597bc894379cc4d111aed752baa62cfc70fb22e8d4bb2810a9ade4b (set COMPONENTIZE_PY_TEST_SEED env var to override)
warning: componentize-py@0.13.3: using count 10 (set COMPONENTIZE_PY_TEST_COUNT env var to override)
warning: field `package` is never read
  --> src/summary.rs:76:9
   |
74 | pub struct MyInterface<'a> {
   |            ----------- field in this struct
75 |     pub id: InterfaceId,
76 |     pub package: Option<PackageName<'a>>,
   |         ^^^^^^^
   |
   = note: `MyInterface` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis
   = note: `#[warn(dead_code)]` on by default

warning: `componentize-py` (lib) generated 1 warning
    Finished `release` profile [optimized] target(s) in 0.26s
     Running `target/release/componentize-py -d hello.wit -w hello componentize app -o app.wasm`
Error: unresolved symbol(s):
    libcomponentize_py_runtime.so needs _PyUnicode_Ready (function [I32] -> [I32])
    libcomponentize_py_runtime.so needs _CLOCK_PROCESS_CPUTIME_ID (global I32)
    libcomponentize_py_runtime.so needs _CLOCK_THREAD_CPUTIME_ID (global I32)

When I build the package with maturin and install it I see the same error but the version installed using pip works in the same virtualenv.

I'm on Arch linux with Python 3.11.8 and the latest nightly for rust stuff.

dicej commented 2 months ago

Thanks for reporting this, @alec-deason. It looks like a recent Rust nightly update has broken the build. The warnings are easy enough to fix, but the unresolved symbols will require some digging. I'll look into it and post a PR once I've figured it out.

dicej commented 2 months ago

BTW, building the top-level project using nightly isn't really supported, since it can include experimental (and possibly broken) compiler warnings that might not actually make it into a stable release. The only part that needs nightly is the libcomponentize_py_runtime.so build, and the build.rs script will take care of that automatically. In other words: you should build componentize-py using a stable Rust release and also have nightly installed so the build script can use it where it's necessary.

That said, you'll hit the unresolved symbols issue either way, so this is definitely a real issue that needs fixing.