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

[wasm][wasi] Allow to build wasi in library mode #102806

Merged
merged 16 commits into from
Jun 7, 2024

Conversation

mkhamoyan
Copy link
Contributor

@mkhamoyan mkhamoyan commented May 29, 2024

By this PR we are supporting library mode for wasi.

Here are all possibilites to build wasi.

  1. Create exe
    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <OutputType>Exe</OutputType>
        ...
      </PropertyGroup>
    </Project>
    
  2. Use wasi specific C# api in standard library
    <Project Sdk="Microsoft.NET.Sdk">
      <PropertyGroup>
        <OutputType>Library</OutputType>
        <RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
        ...
      </PropertyGroup>
     </Project>
    
  3. Create Wasm library
      <Project Sdk="Microsoft.NET.Sdk.WebAssembly">
        <PropertyGroup>
          <OutputType>Library</OutputType>
          <RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
          ...
        </PropertyGroup>
       </Project>
    

Fixes #96869

@mkhamoyan mkhamoyan added arch-wasm WebAssembly architecture os-wasi Related to WASI variant of arch-wasm labels May 29, 2024
src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs Outdated Show resolved Hide resolved
eng/testing/tests.wasi.targets Outdated Show resolved Hide resolved
src/mono/wasm/build/WasmApp.Common.targets Outdated Show resolved Hide resolved
src/mono/sample/wasi/native/Wasi.Native.Sample.csproj Outdated Show resolved Hide resolved
@ilonatommy
Copy link
Member

Doesn't it fix #89577 as well?

@mkhamoyan
Copy link
Contributor Author

mkhamoyan commented Jun 3, 2024

Doesn't it fix #89577 as well?

No, these changes are for wasi.

@lewing
Copy link
Member

lewing commented Jun 5, 2024

Is this waiting for other changes or ready to go?

@mkhamoyan
Copy link
Contributor Author

Is this waiting for other changes or ready to go?

@lewing It is ready to go unless there are further changes needed based on the review.

Copy link
Member

@maraf maraf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

@mkhamoyan
Copy link
Contributor Author

Failures are not related to PR changes.

@mkhamoyan mkhamoyan merged commit 8fdba2b into dotnet:main Jun 7, 2024
75 of 79 checks passed
@mkhamoyan mkhamoyan deleted the wasm_library_mode branch June 7, 2024 12:02
@github-actions github-actions bot locked and limited conversation to collaborators Jul 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-Build-mono os-wasi Related to WASI variant of arch-wasm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[wasm][wasi] No main function should be required when building a library
6 participants