Skip to content

Commit

Permalink
Merge branch 'main' into vigoo/durability-host-functions-2
Browse files Browse the repository at this point in the history
  • Loading branch information
vigoo committed Jan 14, 2025
2 parents d30705c + f818644 commit 5c00540
Show file tree
Hide file tree
Showing 155 changed files with 404 additions and 273 deletions.
54 changes: 36 additions & 18 deletions golem-cli/src/diagnose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ impl Tool {
Tool::Cargo => ToolMetadata {
short_name: "cargo",
description: "Rust package manager",
version_requirement: MinimumVersion("1.80.1"),
version_requirement: MinimumVersion("1.84.0"),
instructions:
"See the rustup step above (https://www.rust-lang.org/learn/get-started)",
},
Expand Down Expand Up @@ -343,10 +343,10 @@ impl Tool {
Tool::ComponentizePy => ToolMetadata {
short_name: "componentize-py",
description: "Tool for converting Python applications to WebAssembly components",
version_requirement: ExactVersion("0.13.5"),
version_requirement: ExactVersion("0.16.0"),
instructions: indoc! {"
Install the following specific version:
pip install componentize-py==0.13.5
pip install componentize-py==0.16.0
For more information see:
https://github.com/bytecodealliance/componentize-py
Expand All @@ -363,7 +363,7 @@ impl Tool {
Tool::GolemSdkGo => ToolMetadata {
short_name: "golem-go",
description: "Golem SDK for Go",
version_requirement: MinimumVersion("0.7.0"),
version_requirement: MinimumVersion("1.1.0"),
instructions: indoc! {"
Add latest golem-go as dependency:
go get github.com/golemcloud/golem-go
Expand All @@ -375,7 +375,7 @@ impl Tool {
Tool::GolemSdkRust => ToolMetadata {
short_name: "golem-rust",
description: "Golem SDK for Rust",
version_requirement: MinimumVersion("1.0.0"),
version_requirement: MinimumVersion("1.1.0"),
instructions: indoc! {"
Add latest golem-rust as dependency:
cargo add golem-rust
Expand All @@ -384,7 +384,7 @@ impl Tool {
Tool::GolemSdkTypeScript => ToolMetadata {
short_name: "golem-ts",
description: "Golem SDK for JavaScript and TypeScript",
version_requirement: MinimumVersion("0.2.0"),
version_requirement: MinimumVersion("1.1.0"),
instructions: indoc! {"
Add latest golem-ts as dependency:
npm install --save-dev @golemcloud/golem-ts
Expand Down Expand Up @@ -443,7 +443,7 @@ impl Tool {
Tool::Rustc => ToolMetadata {
short_name: "rustc",
description: "Rust compiler",
version_requirement: MinimumVersion("1.80.1"),
version_requirement: MinimumVersion("1.84.0"),
instructions: indoc! {"
See the rustup step above (https://www.rust-lang.org/learn/get-started),
then install latest stable rust:
Expand Down Expand Up @@ -476,7 +476,7 @@ impl Tool {
Tool::TinyGo => ToolMetadata {
short_name: "tinygo",
description: "Go compiler for WebAssembly (and embedded systems)",
version_requirement: MinimumVersion("0.33"),
version_requirement: MinimumVersion("0.35"),
instructions: indoc! {"
Install latest TinyGo:
https://tinygo.org/getting-started/install/
Expand All @@ -489,8 +489,7 @@ impl Tool {
Tool::WasiSdk => ToolMetadata {
short_name: "wasi-sdk",
description: "WebAssembly toolchain for C and C++",
// NOTE: Version is not detectable currently, from 24.0 it will be stored in a version file
version_requirement: ExactByNameVersion("WASI_SDK set"),
version_requirement: MinimumVersion("25.0"),
instructions: indoc! {"
Install WASI SDK 23.0:
https://github.com/WebAssembly/wasi-sdk
Expand All @@ -501,25 +500,25 @@ impl Tool {
Tool::WasmTools => ToolMetadata {
short_name: "wasm-tools",
description: "Tools for manipulation of WebAssembly modules",
version_requirement: ExactVersion("1.210.0"),
version_requirement: ExactVersion("1.223.0"),
instructions: indoc! {"
Install the following specific version of wasm-tools:
cargo install --force --locked wasm-tools@1.210.0
cargo install --force --locked wasm-tools@1.223.0
"},
},
Tool::WitBindgen => ToolMetadata {
short_name: "wit-bindgen",
description: "Guest language bindings generator for WIT",
version_requirement: ExactVersion("0.26.0"),
version_requirement: ExactVersion("0.37.0"),
instructions: indoc! {"
Install the following specific version of wit-bindgen:
cargo install --force --locked wit-bindgen-cli@0.26.0
cargo install --force --locked wit-bindgen-cli@0.37.0
"},
},
Tool::Zig => ToolMetadata {
short_name: "zig",
description: "Zig language tooling",
version_requirement: MinimumVersion("0.13.0"),
version_requirement: MinimumVersion("0.14.0"),
instructions: indoc! {"
Install latest version of Zig:
https://ziglang.org/learn/getting-started/#installing-zig
Expand Down Expand Up @@ -604,9 +603,28 @@ impl Tool {
Tool::Rustup => cmd_version(dir, "rustup", vec!["--version"], &version_regex),
Tool::RustTargetWasm32WasiP1 => rust_target(dir, "wasm32-wasip1"),
Tool::TinyGo => cmd_version(dir, "tinygo", vec!["version"], &version_regex),
Tool::WasiSdk => std::env::var("WASI_SDK")
.map(|_| "WASI_SDK set".to_string())
.map_err(|_| "WASI_SDK no set".to_string()),
Tool::WasiSdk => {
let wasi_sdk_path = std::env::var("WASI_SDK_PATH")
.map_err(|_| "WASI_SDK_PATH not set".to_string())?;
let wasi_sdk_version_file = Path::new(&wasi_sdk_path).join("VERSION");
let versions = std::fs::read_to_string(&wasi_sdk_version_file).map_err(|err| {
format!(
"Failed to open {}: {}",
wasi_sdk_version_file.to_string_lossy(),
err
)
})?;
versions
.lines()
.next()
.ok_or_else(|| {
format!(
"Version not found in {}",
wasi_sdk_version_file.to_string_lossy()
)
})
.map(|version| version.to_string())
}
Tool::WasmTools => cmd_version(dir, "wasm-tools", vec!["--version"], &version_regex),
Tool::WitBindgen => cmd_version(dir, "wit-bindgen", vec!["--version"], &version_regex),
Tool::Zig => cmd_version(dir, "zig", vec!["version"], &version_regex),
Expand Down
8 changes: 8 additions & 0 deletions golem-worker-executor-base/tests/guest_languages1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ async fn grain_example_1(
check!(third_line.parse::<i64>().unwrap() < (epoch + hour));
}

// NOTE: disabled for now:
// - rebuilt with teavm 0.27.0 and 0.28.0, and both is failing with (previously used _some_ 0.27.0-SNAPSHOT)
// - with both it is failing with: meth_otr_ExceptionHandling_throwException in !meth_oti_Memory_realloc
#[ignore]
#[test]
#[tracing::instrument]
async fn java_example_1(
Expand Down Expand Up @@ -299,6 +303,10 @@ async fn java_example_1(
check!(result == vec![Value::U32("Hello Golem!".len() as u32)]);
}

// NOTE: disabled for now:
// - rebuilt with teavm 0.27.0 and 0.28.0, and both is failing with (previously used _some_ 0.27.0-SNAPSHOT)
// - with both it is failing with: meth_otr_ExceptionHandling_throwException in !meth_oti_Memory_realloc
#[ignore]
#[test]
#[tracing::instrument]
async fn java_shopping_cart(
Expand Down
1 change: 1 addition & 0 deletions test-components/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.zig-cache
2 changes: 1 addition & 1 deletion test-components/auction-example/auction/wit/auction.wit
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface api {
auction-id: auction-id,
name: string,
description: string,
limit-price: float32,
limit-price: f32,
expiration: deadline,
}

Expand Down
Binary file modified test-components/auction_registry_composed.wasm
Binary file not shown.
Binary file modified test-components/blob-store-service.wasm
Binary file not shown.
6 changes: 3 additions & 3 deletions test-components/blob-store-service/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test-components/blob-store-service/cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ opt-level = 's'
strip = true

[dependencies]
wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] }
wit-bindgen-rt = { version = "0.37.0", features = ["bitflags"] }

[package.metadata.component.target]
path = "wit"
Expand Down
44 changes: 37 additions & 7 deletions test-components/build-components.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'

rust_test_components=("write-stdout" "write-stderr" "read-stdin" "clocks" "shopping-cart" "file-write-read-delete" "file-service" "http-client" "directories" "environment-service" "promise" "interruption" "clock-service"
"option-service" "flags-service" "http-client-2" "stdio-cc" "failing-component" "variant-service" "key-value-service" "blob-store-service" "runtime-service" "networking" "shopping-cart-resource"
Expand All @@ -12,7 +14,9 @@ dotnet_test_components=("csharp-1")
swift_test_components=("swift-1")
c_test_components=("c-1" "large-initial-memory" "large-dynamic-memory")
python_test_components=("python-1" "py-echo")
ts_test_components=("ts-rpc")

rust_test_apps=("auction-example" "rpc" "rust-service/rpc")
ts_test_apps=("ts-rpc")

# Optional arguments:
# - rebuild: clean all projects before building them
Expand Down Expand Up @@ -107,6 +111,28 @@ if [ "$single_lang" = "false" ] || [ "$lang" = "rust" ]; then
done
fi

if [ "$single_lang" = "false" ] || [ "$lang" = "rust" ]; then
echo "Building the Rust test apps"
for subdir in "${rust_test_apps[@]}"; do
echo "Building $subdir..."
pushd "$subdir" || exit

if [ "$update_wit" = true ] && [ -f "wit/deps.toml" ]; then
wit-deps update
fi

if [ "$rebuild" = true ]; then
golem-cli app clean
cargo clean
fi

golem-cli app -b release build
golem-cli app -b release copy

popd || exit
done
fi

if [ "$single_lang" = "false" ] || [ "$lang" = "zig" ]; then
echo "Building the Zig test components"
for subdir in "${zig_test_components[@]}"; do
Expand Down Expand Up @@ -279,7 +305,7 @@ if [ "$single_lang" = "false" ] || [ "$lang" = "swift" ]; then
if [ "$rebuild" = true ]; then
rm *.wasm
fi
/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swiftc -target wasm32-unknown-wasi main.swift -o main.wasm -sdk /Library/Developer/Toolchains/swift-wasm-5.7.3-RELEASE.xctoolchain/usr/share/wasi-sysroot/
/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin/swiftc -target wasm32-unknown-wasi main.swift -o main.wasm -sdk /Library/Developer/Toolchains/swift-latest.xctoolchain/usr/share/wasi-sysroot/
wasm-opt -Os main.wasm -o main.opt.wasm

echo "Turning the module into a WebAssembly Component..."
Expand All @@ -306,7 +332,8 @@ if [ "$single_lang" = "false" ] || [ "$lang" = "c" ]; then
rm *.wasm
fi
wit-bindgen c --autodrop-borrows yes ./wit
~/wasi-sdk-20.0/bin/clang --sysroot ~/wasi-sdk-20.0/share/wasi-sysroot main.c c_api1.c c_api1_component_type.o -o main.wasm
# last built with wasi-sdk-0.25.0
$WASI_SDK_PATH/bin/clang --sysroot $WASI_SDK_PATH/share/wasi-sysroot main.c c_api1.c c_api1_component_type.o -o main.wasm

echo "Turning the module into a WebAssembly Component..."
target="../$subdir.wasm"
Expand Down Expand Up @@ -334,6 +361,7 @@ if [ "$single_lang" = "false" ] || [ "$lang" = "python" ]; then
fi

echo "Compiling the python code into a WebAssembly Component..."
rm -rf bindings
componentize-py bindings bindings
componentize-py componentize test -o "${subdir}_full.wasm"
wasm-tools strip "${subdir}_full.wasm" -o "${subdir}.wasm"
Expand All @@ -349,8 +377,8 @@ if [ "$single_lang" = "false" ] || [ "$lang" = "python" ]; then
fi

if [ "$single_lang" = "false" ] || [ "$lang" = "ts" ]; then
echo "Building the TS test components"
for subdir in ${ts_test_components[@]}; do
echo "Building the TS test apps"
for subdir in ${ts_test_apps[@]}; do
echo "Building $subdir..."
pushd "$subdir" || exit

Expand All @@ -359,10 +387,12 @@ if [ "$single_lang" = "false" ] || [ "$lang" = "ts" ]; then
fi

if [ "$rebuild" = true ]; then
golem-cli app build
golem-cli app copy
golem-cli app clean
fi

golem-cli app build
golem-cli app copy

popd || exit
done
fi
Binary file modified test-components/c-1.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions test-components/c-1/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ int32_t main(void) {
return 0;
}

int32_t c_api1_run(void) {
int32_t exports_c_api1_run(void) {
printf("Hello World!\n");
return 100;
}

void c_api1_print(c_api1_string_t *s) {
void exports_c_api1_print(c_api1_string_t *s) {
char* buf = malloc(s->len + 1);
memset(buf, 0, s->len + 1);
strncpy(buf, s->ptr, s->len);
Expand Down
Binary file modified test-components/caller-composed-ts.wasm
Binary file not shown.
Binary file modified test-components/caller-ts.wasm
Binary file not shown.
Binary file modified test-components/clock-service.wasm
Binary file not shown.
6 changes: 3 additions & 3 deletions test-components/clock-service/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test-components/clock-service/cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ strip = true
[dependencies]
once_cell = "1.17.1"
rand = "0.8.5"
wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] }
wit-bindgen-rt = { version = "0.37.0", features = ["bitflags"] }

[package.metadata.component.target]
path = "wit"
Expand Down
Binary file modified test-components/clocks.wasm
Binary file not shown.
6 changes: 3 additions & 3 deletions test-components/clocks/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test-components/clocks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ opt-level = 's'
strip = true

[dependencies]
wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] }
wit-bindgen-rt = { version = "0.37.0", features = ["bitflags"] }
time = { version = "0.3.36", features = ["formatting"] }

[package.metadata.component]
Expand Down
Binary file modified test-components/counter-ts.wasm
Binary file not shown.
Binary file modified test-components/csharp-1.wasm
Binary file not shown.
Binary file modified test-components/directories.wasm
Binary file not shown.
6 changes: 3 additions & 3 deletions test-components/directories/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5c00540

Please sign in to comment.