Does not link `env` module when compiling libs with `[no_std]`

オープン
#333 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
rust, wasm
領域
build-system, cli

調査の方向性

提供された src/lib.rs と wit/world.wit の例を使用して、cargo component build で失敗を再現してください。コマンドが component world をどのようにデコードし、env import interface をどのように処理するかを追跡してください。完了条件は、no_std の例が missing-interface error なしで正常にコンパイルできることです。

索引モデルが issue の本文から書いたものです。

説明

cargo component build fails to compile Rust libraries with [no_std] flags because it cannot resolve the env import interface:

error: failed to decode world from module

Caused by:
    0: module was not valid
    1: module requires an import interface named `env`

Minimum reproducible example:

src/lib.rs (it uses an allocator from the lol_alloc crate)

#![no_std]

extern crate alloc;
extern crate lol_alloc;

#[allow(warnings)]
mod bindings;

#[global_allocator]
static ALLOCATOR : lol_alloc::FailAllocator = lol_alloc::FailAllocator;

#[panic_handler]
fn panic(_i : &core::panic::PanicInfo) -> ! {
    core::arch::wasm32::unreachable()
}

use bindings::Guest;
use alloc::string::{String, ToString};

struct Component;

impl Guest for Component {
    /// Say hello!
    fn hello_world() -> String {
        "Hello, World!".to_string()
    }
}

bindings::export!(Component with_types_in bindings);

wit/world.wit

package component:nostd;

/// An example world for the component to target.
world example {
    export hello-world: func() -> string;
}
主要言語
Rust
スター
593
フォーク
68
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

bytecodealliance/cargo-component のほかの issue

bytecodealliance/cargo-component の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。