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

Merge up to release v0.30.0 #23

Merged
merged 8 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/actions/install-wasi-sdk/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ runs:
using: composite
steps:
- run: |
curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0-linux.tar.gz -L | tar xzvf -
echo "WASI_SDK_PATH=`pwd`/wasi-sdk-22.0" >> $GITHUB_ENV
curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-24/wasi-sdk-24.0-x86_64-linux.tar.gz -L | tar xzvf -
echo "WASI_SDK_PATH=`pwd`/wasi-sdk-24.0-x86_64-linux" >> $GITHUB_ENV
if: runner.os == 'Linux'
shell: bash
- run: |
curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0-macos.tar.gz -L | tar xzvf -
echo "WASI_SDK_PATH=`pwd`/wasi-sdk-22.0" >> $GITHUB_ENV
curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-24/wasi-sdk-24.0-x86_64-macos.tar.gz -L | tar xzvf -
echo "WASI_SDK_PATH=`pwd`/wasi-sdk-24.0-x86_64-macos" >> $GITHUB_ENV
if: runner.os == 'macOS'
shell: bash
- run: |
curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0.m-mingw64.tar.gz -L | tar xzvf -
echo "WASI_SDK_PATH=`pwd`/wasi-sdk-22.0+m" >> $GITHUB_ENV
curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-24/wasi-sdk-24.0-x86_64-windows.tar.gz -L | tar xzvf -
echo "WASI_SDK_PATH=`pwd`/wasi-sdk-24.0-x86_64-windows" >> $GITHUB_ENV
if: runner.os == 'Windows'
shell: bash
- name: Setup `wasm-tools`
uses: bytecodealliance/actions/wasm-tools/setup@v1
with:
version: "1.0.60"
version: "1.215.0"
github_token: ${{ github.token }}
22 changes: 11 additions & 11 deletions Cargo.lock

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

18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ resolver = "2"

[workspace.package]
edition = "2021"
version = "0.29.0"
version = "0.30.0"
license = "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT"
repository = "https://github.com/bytecodealliance/wasi-rs"

Expand All @@ -38,14 +38,14 @@ wasm-encoder = { git = "https://github.com/wasmfx/wasmfx-tools", tag = "v1.215.
wit-parser = { git = "https://github.com/wasmfx/wasmfx-tools", tag = "v1.215.0" }
wit-component = { git = "https://github.com/wasmfx/wasmfx-tools", tag = "v1.215.0" }

wit-bindgen-core = { path = 'crates/core', version = '0.29.0' }
wit-bindgen-c = { path = 'crates/c', version = '0.29.0' }
wit-bindgen-rust = { path = "crates/rust", version = "0.29.0" }
wit-bindgen-teavm-java = { path = 'crates/teavm-java', version = '0.29.0' }
wit-bindgen-go = { path = 'crates/go', version = '0.29.0' }
wit-bindgen-csharp = { path = 'crates/csharp', version = '0.29.0' }
wit-bindgen-markdown = { path = 'crates/markdown', version = '0.29.0' }
wit-bindgen = { path = 'crates/guest-rust', version = '0.29.0', default-features = false }
wit-bindgen-core = { path = 'crates/core', version = '0.30.0' }
wit-bindgen-c = { path = 'crates/c', version = '0.30.0' }
wit-bindgen-rust = { path = "crates/rust", version = "0.30.0" }
wit-bindgen-teavm-java = { path = 'crates/teavm-java', version = '0.30.0' }
wit-bindgen-go = { path = 'crates/go', version = '0.30.0' }
wit-bindgen-csharp = { path = 'crates/csharp', version = '0.30.0' }
wit-bindgen-markdown = { path = 'crates/markdown', version = '0.30.0' }
wit-bindgen = { path = 'crates/guest-rust', version = '0.30.0', default-features = false }

[[bin]]
name = "wit-bindgen"
Expand Down
58 changes: 0 additions & 58 deletions crates/csharp/src/component_type_object.rs

This file was deleted.

34 changes: 5 additions & 29 deletions crates/csharp/src/csproj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,51 +77,27 @@ impl CSProjectLLVMBuilder {
<PublishTrimmed>true</PublishTrimmed>
<AssemblyName>{name}</AssemblyName>
</PropertyGroup>

<ItemGroup>
<NativeLibrary Include=\"{camel}_component_type.o\" />
<NativeLibrary Include=\"$(MSBuildProjectDirectory)/{camel}_cabi_realloc.o\" />
<RdXmlFile Include=\"rd.xml\" />
</ItemGroup>

<ItemGroup>
<RdXmlFile Include=\"rd.xml\" />
<CustomLinkerArg Include=\"-Wl,--component-type,{camel}_component_type.wit\" />
</ItemGroup>
"
);

if self.aot {
//TODO: Is this handled by the source generator? (Temporary just to test with numbers and strings)
csproj.push_str(
r#"
<ItemGroup>
<CustomLinkerArg Include="-Wl,--export,_initialize" />
<CustomLinkerArg Include="-Wl,--no-entry" />
<CustomLinkerArg Include="-mexec-model=reactor" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" Version="9.0.0-*" />
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler.LLVM" Version="9.0.0-*" />
<PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" Version="9.0.0-rc.1.24412.1" />
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler.LLVM" Version="9.0.0-rc.1.24412.1" />
</ItemGroup>

<Target Name="CheckWasmSdks">
<Error Text="Wasi SDK not found, not compiling to WebAssembly. To enable WebAssembly compilation, install Wasi SDK and ensure the WASI_SDK_PATH environment variable points to the directory containing share/wasi-sysroot"
Condition="'$(WASI_SDK_PATH)' == ''" />
<Warning Text="The WASI SDK version is too low. Please use WASI SDK 22 or newer with a 64 bit Clang."
Condition="!Exists('$(WASI_SDK_PATH)/VERSION')" />
</Target>
"#,
);

csproj.push_str(&format!("
<Target Name=\"CompileCabiRealloc\" BeforeTargets=\"IlcCompile\" DependsOnTargets=\"CheckWasmSdks\"
Inputs=\"$(MSBuildProjectDirectory)/{camel}_cabi_realloc.c\"
Outputs=\"$(MSBuildProjectDirectory)/{camel}_cabi_realloc.o\"
>
<Exec Command=\"&quot;$(WASI_SDK_PATH)/bin/clang&quot; --target=wasm32-wasi &quot;$(MSBuildProjectDirectory)/{camel}_cabi_realloc.c&quot; -c -o &quot;$(MSBuildProjectDirectory)/{camel}_cabi_realloc.o&quot;\"/>
</Target>
"
));

fs::write(
self.dir.join("nuget.config"),
r#"<?xml version="1.0" encoding="utf-8"?>
Expand Down
38 changes: 3 additions & 35 deletions crates/csharp/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
mod component_type_object;

use anyhow::Result;
use heck::{ToLowerCamelCase, ToShoutySnakeCase, ToUpperCamelCase};
use indexmap::IndexMap;
Expand Down Expand Up @@ -692,31 +690,6 @@ impl WorldGenerator for CSharp {
}

if !self.opts.skip_support_files {
let cabi_relloc_src = r#"
#include <stdlib.h>

/* Done in C so we can avoid initializing the dotnet runtime and hence WASI libc */
/* It would be preferable to do this in C# but the constraints of cabi_realloc and the demands */
/* of WASI libc prevent us doing so. */
/* See https://github.com/bytecodealliance/wit-bindgen/issues/777 */
/* and https://github.com/WebAssembly/wasi-libc/issues/452 */
/* The component model `start` function might be an alternative to this depending on whether it */
/* has the same constraints as `cabi_realloc` */
__attribute__((__weak__, __export_name__("cabi_realloc")))
void *cabi_realloc(void *ptr, size_t old_size, size_t align, size_t new_size) {
(void) old_size;
if (new_size == 0) return (void*) align;
void *ret = realloc(ptr, new_size);
if (!ret) abort();
return ret;
}
"#;

files.push(
&format!("{name}World_cabi_realloc.c"),
indent(cabi_relloc_src).as_bytes(),
);

//TODO: This is currently needed for mono even if it's built as a library.
if self.opts.runtime == CSharpRuntime::Mono {
files.push(
Expand Down Expand Up @@ -779,13 +752,6 @@ impl WorldGenerator for CSharp {
);
}

files.push(
&format!("{world_namespace}_component_type.o",),
component_type_object::object(resolve, id, self.opts.string_encoding)
.unwrap()
.as_slice(),
);

// TODO: remove when we switch to dotnet 9
let mut wasm_import_linakge_src = String::new();

Expand Down Expand Up @@ -1012,6 +978,8 @@ impl InterfaceGenerator<'_> {
}
};

let access = self.gen.access_modifier();

let extra_modifiers = extra_modifiers(func, &camel_name);

let interop_camel_name = func.item_name().to_upper_camel_case();
Expand Down Expand Up @@ -1140,7 +1108,7 @@ impl InterfaceGenerator<'_> {
uwrite!(
target,
r#"
internal {extra_modifiers} {modifiers} unsafe {result_type} {camel_name}({params})
{access} {extra_modifiers} {modifiers} unsafe {result_type} {camel_name}({params})
{{
{src}
//TODO: free alloc handle (interopString) if exists
Expand Down
4 changes: 2 additions & 2 deletions crates/guest-rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Used when compiling Rust programs to the component model.
"""

[dependencies]
wit-bindgen-rust-macro = { path = "./macro", optional = true, version = "0.29.0" }
wit-bindgen-rt = { path = "./rt", version = "0.29.0", features = ["bitflags"] }
wit-bindgen-rust-macro = { path = "./macro", optional = true, version = "0.30.0" }
wit-bindgen-rt = { path = "./rt", version = "0.30.0", features = ["bitflags"] }

[features]
default = ["macros", "realloc"]
Expand Down
9 changes: 9 additions & 0 deletions crates/guest-rust/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ impl Parse for Config {
Opt::Features(f) => {
features.extend(f.into_iter().map(|f| f.value()));
}
Opt::DisableCustomSectionLinkHelpers(disable) => {
opts.disable_custom_section_link_helpers = disable.value();
}
}
}
} else {
Expand Down Expand Up @@ -309,6 +312,7 @@ mod kw {
syn::custom_keyword!(pub_export_macro);
syn::custom_keyword!(generate_unused_types);
syn::custom_keyword!(features);
syn::custom_keyword!(disable_custom_section_link_helpers);
}

#[derive(Clone)]
Expand Down Expand Up @@ -361,6 +365,7 @@ enum Opt {
PubExportMacro(syn::LitBool),
GenerateUnusedTypes(syn::LitBool),
Features(Vec<syn::LitStr>),
DisableCustomSectionLinkHelpers(syn::LitBool),
}

impl Parse for Opt {
Expand Down Expand Up @@ -504,6 +509,10 @@ impl Parse for Opt {
syn::bracketed!(contents in input);
let list = Punctuated::<_, Token![,]>::parse_terminated(&contents)?;
Ok(Opt::Features(list.into_iter().collect()))
} else if l.peek(kw::disable_custom_section_link_helpers) {
input.parse::<kw::disable_custom_section_link_helpers>()?;
input.parse::<Token![:]>()?;
Ok(Opt::DisableCustomSectionLinkHelpers(input.parse()?))
} else {
Err(l.error())
}
Expand Down
Loading
Loading