Skip to content

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

Merged
mkhamoyan merged 16 commits into
dotnet:mainfrom
mkhamoyan:wasm_library_mode
Jun 7, 2024
Merged

[wasm][wasi] Allow to build wasi in library mode#102806
mkhamoyan merged 16 commits into
dotnet:mainfrom
mkhamoyan:wasm_library_mode

Conversation

@mkhamoyan

@mkhamoyan mkhamoyan commented May 29, 2024

Copy link
Copy Markdown
Contributor

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

@ghost ghost added the area-Build-mono label May 29, 2024
@mkhamoyan mkhamoyan added arch-wasm WebAssembly architecture os-wasi Related to WASI variant of arch-wasm labels May 29, 2024
Comment thread src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs Outdated
Comment thread eng/testing/tests.wasi.targets Outdated
Comment thread src/mono/wasm/build/WasmApp.Common.targets Outdated
Comment thread src/mono/sample/wasi/native/Wasi.Native.Sample.csproj Outdated
@ilonatommy

Copy link
Copy Markdown
Member

Doesn't it fix #89577 as well?

@mkhamoyan

mkhamoyan commented Jun 3, 2024

Copy link
Copy Markdown
Contributor Author

Doesn't it fix #89577 as well?

No, these changes are for wasi.

Comment thread src/mono/nuget/Microsoft.NET.Runtime.WebAssembly.Wasi.Sdk/Sdk/Sdk.props Outdated
Comment thread src/mono/sample/wasi/Directory.Build.targets Outdated
Comment thread src/mono/wasi/Wasi.Build.Tests/WasiLibraryModeTests.cs
Comment thread src/mono/wasm/build/WasmApp.Common.targets Outdated
Comment thread src/mono/wasm/build/WasmApp.Common.targets Outdated
@lewing

lewing commented Jun 5, 2024

Copy link
Copy Markdown
Member

Is this waiting for other changes or ready to go?

Comment thread src/mono/wasi/runtime/main.c
@mkhamoyan

Copy link
Copy Markdown
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.

Comment thread src/mono/wasi/runtime/main.c

@maraf maraf left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor Author

Failures are not related to PR changes.

@mkhamoyan mkhamoyan merged commit 8fdba2b into dotnet:main Jun 7, 2024
@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