Skip to content

Commit 3f4883f

Browse files
authored
Merge pull request #23 from dhil/wasmfx-merge
Merge up to release v0.30.0
2 parents 6cb4d00 + 363b011 commit 3f4883f

File tree

17 files changed

+99
-180
lines changed

17 files changed

+99
-180
lines changed

.github/actions/install-wasi-sdk/action.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,22 @@ runs:
55
using: composite
66
steps:
77
- run: |
8-
curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0-linux.tar.gz -L | tar xzvf -
9-
echo "WASI_SDK_PATH=`pwd`/wasi-sdk-22.0" >> $GITHUB_ENV
8+
curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-24/wasi-sdk-24.0-x86_64-linux.tar.gz -L | tar xzvf -
9+
echo "WASI_SDK_PATH=`pwd`/wasi-sdk-24.0-x86_64-linux" >> $GITHUB_ENV
1010
if: runner.os == 'Linux'
1111
shell: bash
1212
- run: |
13-
curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0-macos.tar.gz -L | tar xzvf -
14-
echo "WASI_SDK_PATH=`pwd`/wasi-sdk-22.0" >> $GITHUB_ENV
13+
curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-24/wasi-sdk-24.0-x86_64-macos.tar.gz -L | tar xzvf -
14+
echo "WASI_SDK_PATH=`pwd`/wasi-sdk-24.0-x86_64-macos" >> $GITHUB_ENV
1515
if: runner.os == 'macOS'
1616
shell: bash
1717
- run: |
18-
curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0.m-mingw64.tar.gz -L | tar xzvf -
19-
echo "WASI_SDK_PATH=`pwd`/wasi-sdk-22.0+m" >> $GITHUB_ENV
18+
curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-24/wasi-sdk-24.0-x86_64-windows.tar.gz -L | tar xzvf -
19+
echo "WASI_SDK_PATH=`pwd`/wasi-sdk-24.0-x86_64-windows" >> $GITHUB_ENV
2020
if: runner.os == 'Windows'
2121
shell: bash
2222
- name: Setup `wasm-tools`
2323
uses: bytecodealliance/actions/wasm-tools/setup@v1
2424
with:
25-
version: "1.0.60"
25+
version: "1.215.0"
2626
github_token: ${{ github.token }}

Cargo.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ resolver = "2"
1818

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

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

41-
wit-bindgen-core = { path = 'crates/core', version = '0.29.0' }
42-
wit-bindgen-c = { path = 'crates/c', version = '0.29.0' }
43-
wit-bindgen-rust = { path = "crates/rust", version = "0.29.0" }
44-
wit-bindgen-teavm-java = { path = 'crates/teavm-java', version = '0.29.0' }
45-
wit-bindgen-go = { path = 'crates/go', version = '0.29.0' }
46-
wit-bindgen-csharp = { path = 'crates/csharp', version = '0.29.0' }
47-
wit-bindgen-markdown = { path = 'crates/markdown', version = '0.29.0' }
48-
wit-bindgen = { path = 'crates/guest-rust', version = '0.29.0', default-features = false }
41+
wit-bindgen-core = { path = 'crates/core', version = '0.30.0' }
42+
wit-bindgen-c = { path = 'crates/c', version = '0.30.0' }
43+
wit-bindgen-rust = { path = "crates/rust", version = "0.30.0" }
44+
wit-bindgen-teavm-java = { path = 'crates/teavm-java', version = '0.30.0' }
45+
wit-bindgen-go = { path = 'crates/go', version = '0.30.0' }
46+
wit-bindgen-csharp = { path = 'crates/csharp', version = '0.30.0' }
47+
wit-bindgen-markdown = { path = 'crates/markdown', version = '0.30.0' }
48+
wit-bindgen = { path = 'crates/guest-rust', version = '0.30.0', default-features = false }
4949

5050
[[bin]]
5151
name = "wit-bindgen"

crates/csharp/src/component_type_object.rs

Lines changed: 0 additions & 58 deletions
This file was deleted.

crates/csharp/src/csproj.rs

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -77,51 +77,27 @@ impl CSProjectLLVMBuilder {
7777
<PublishTrimmed>true</PublishTrimmed>
7878
<AssemblyName>{name}</AssemblyName>
7979
</PropertyGroup>
80+
8081
<ItemGroup>
81-
<NativeLibrary Include=\"{camel}_component_type.o\" />
82-
<NativeLibrary Include=\"$(MSBuildProjectDirectory)/{camel}_cabi_realloc.o\" />
82+
<RdXmlFile Include=\"rd.xml\" />
8383
</ItemGroup>
8484
8585
<ItemGroup>
86-
<RdXmlFile Include=\"rd.xml\" />
86+
<CustomLinkerArg Include=\"-Wl,--component-type,{camel}_component_type.wit\" />
8787
</ItemGroup>
8888
"
8989
);
9090

9191
if self.aot {
92-
//TODO: Is this handled by the source generator? (Temporary just to test with numbers and strings)
9392
csproj.push_str(
9493
r#"
9594
<ItemGroup>
96-
<CustomLinkerArg Include="-Wl,--export,_initialize" />
97-
<CustomLinkerArg Include="-Wl,--no-entry" />
98-
<CustomLinkerArg Include="-mexec-model=reactor" />
99-
</ItemGroup>
100-
101-
<ItemGroup>
102-
<PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" Version="9.0.0-*" />
103-
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler.LLVM" Version="9.0.0-*" />
95+
<PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" Version="9.0.0-rc.1.24412.1" />
96+
<PackageReference Include="runtime.win-x64.Microsoft.DotNet.ILCompiler.LLVM" Version="9.0.0-rc.1.24412.1" />
10497
</ItemGroup>
105-
106-
<Target Name="CheckWasmSdks">
107-
<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"
108-
Condition="'$(WASI_SDK_PATH)' == ''" />
109-
<Warning Text="The WASI SDK version is too low. Please use WASI SDK 22 or newer with a 64 bit Clang."
110-
Condition="!Exists('$(WASI_SDK_PATH)/VERSION')" />
111-
</Target>
11298
"#,
11399
);
114100

115-
csproj.push_str(&format!("
116-
<Target Name=\"CompileCabiRealloc\" BeforeTargets=\"IlcCompile\" DependsOnTargets=\"CheckWasmSdks\"
117-
Inputs=\"$(MSBuildProjectDirectory)/{camel}_cabi_realloc.c\"
118-
Outputs=\"$(MSBuildProjectDirectory)/{camel}_cabi_realloc.o\"
119-
>
120-
<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;\"/>
121-
</Target>
122-
"
123-
));
124-
125101
fs::write(
126102
self.dir.join("nuget.config"),
127103
r#"<?xml version="1.0" encoding="utf-8"?>

crates/csharp/src/lib.rs

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
mod component_type_object;
2-
31
use anyhow::Result;
42
use heck::{ToLowerCamelCase, ToShoutySnakeCase, ToUpperCamelCase};
53
use indexmap::IndexMap;
@@ -692,31 +690,6 @@ impl WorldGenerator for CSharp {
692690
}
693691

694692
if !self.opts.skip_support_files {
695-
let cabi_relloc_src = r#"
696-
#include <stdlib.h>
697-
698-
/* Done in C so we can avoid initializing the dotnet runtime and hence WASI libc */
699-
/* It would be preferable to do this in C# but the constraints of cabi_realloc and the demands */
700-
/* of WASI libc prevent us doing so. */
701-
/* See https://github.com/bytecodealliance/wit-bindgen/issues/777 */
702-
/* and https://github.com/WebAssembly/wasi-libc/issues/452 */
703-
/* The component model `start` function might be an alternative to this depending on whether it */
704-
/* has the same constraints as `cabi_realloc` */
705-
__attribute__((__weak__, __export_name__("cabi_realloc")))
706-
void *cabi_realloc(void *ptr, size_t old_size, size_t align, size_t new_size) {
707-
(void) old_size;
708-
if (new_size == 0) return (void*) align;
709-
void *ret = realloc(ptr, new_size);
710-
if (!ret) abort();
711-
return ret;
712-
}
713-
"#;
714-
715-
files.push(
716-
&format!("{name}World_cabi_realloc.c"),
717-
indent(cabi_relloc_src).as_bytes(),
718-
);
719-
720693
//TODO: This is currently needed for mono even if it's built as a library.
721694
if self.opts.runtime == CSharpRuntime::Mono {
722695
files.push(
@@ -779,13 +752,6 @@ impl WorldGenerator for CSharp {
779752
);
780753
}
781754

782-
files.push(
783-
&format!("{world_namespace}_component_type.o",),
784-
component_type_object::object(resolve, id, self.opts.string_encoding)
785-
.unwrap()
786-
.as_slice(),
787-
);
788-
789755
// TODO: remove when we switch to dotnet 9
790756
let mut wasm_import_linakge_src = String::new();
791757

@@ -1012,6 +978,8 @@ impl InterfaceGenerator<'_> {
1012978
}
1013979
};
1014980

981+
let access = self.gen.access_modifier();
982+
1015983
let extra_modifiers = extra_modifiers(func, &camel_name);
1016984

1017985
let interop_camel_name = func.item_name().to_upper_camel_case();
@@ -1140,7 +1108,7 @@ impl InterfaceGenerator<'_> {
11401108
uwrite!(
11411109
target,
11421110
r#"
1143-
internal {extra_modifiers} {modifiers} unsafe {result_type} {camel_name}({params})
1111+
{access} {extra_modifiers} {modifiers} unsafe {result_type} {camel_name}({params})
11441112
{{
11451113
{src}
11461114
//TODO: free alloc handle (interopString) if exists

crates/guest-rust/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Used when compiling Rust programs to the component model.
1212
"""
1313

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

1818
[features]
1919
default = ["macros", "realloc"]

crates/guest-rust/macro/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ impl Parse for Config {
137137
Opt::Features(f) => {
138138
features.extend(f.into_iter().map(|f| f.value()));
139139
}
140+
Opt::DisableCustomSectionLinkHelpers(disable) => {
141+
opts.disable_custom_section_link_helpers = disable.value();
142+
}
140143
}
141144
}
142145
} else {
@@ -309,6 +312,7 @@ mod kw {
309312
syn::custom_keyword!(pub_export_macro);
310313
syn::custom_keyword!(generate_unused_types);
311314
syn::custom_keyword!(features);
315+
syn::custom_keyword!(disable_custom_section_link_helpers);
312316
}
313317

314318
#[derive(Clone)]
@@ -361,6 +365,7 @@ enum Opt {
361365
PubExportMacro(syn::LitBool),
362366
GenerateUnusedTypes(syn::LitBool),
363367
Features(Vec<syn::LitStr>),
368+
DisableCustomSectionLinkHelpers(syn::LitBool),
364369
}
365370

366371
impl Parse for Opt {
@@ -504,6 +509,10 @@ impl Parse for Opt {
504509
syn::bracketed!(contents in input);
505510
let list = Punctuated::<_, Token![,]>::parse_terminated(&contents)?;
506511
Ok(Opt::Features(list.into_iter().collect()))
512+
} else if l.peek(kw::disable_custom_section_link_helpers) {
513+
input.parse::<kw::disable_custom_section_link_helpers>()?;
514+
input.parse::<Token![:]>()?;
515+
Ok(Opt::DisableCustomSectionLinkHelpers(input.parse()?))
507516
} else {
508517
Err(l.error())
509518
}

0 commit comments

Comments
 (0)