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

Added wasi-sdk flow #307

Merged
merged 36 commits into from
Jan 26, 2023
Merged

Added wasi-sdk flow #307

merged 36 commits into from
Jan 26, 2023

Conversation

mkhamoyan
Copy link
Member

@mkhamoyan mkhamoyan commented Jan 17, 2023

Contributes to dotnet/runtime#65895

Allows to build icu for wasm using wasi-sdk.

eng/icu.mk Show resolved Hide resolved
@mkhamoyan mkhamoyan marked this pull request as ready for review January 20, 2023 12:27
Copy link
Member

@steveisok steveisok left a comment

Choose a reason for hiding this comment

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

LGTM! Have you been able to use it yet in the wasi runtime build?

@mkhamoyan
Copy link
Member Author

LGTM! Have you been able to use it yet in the wasi runtime build?

not yet. Once this will be merged I will do changes in wasi runtime build

Copy link
Member

@pavelsavara pavelsavara left a comment

Choose a reason for hiding this comment

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

the changes which are also in patch need to be removed from the PR, right ?

@mkhamoyan
Copy link
Member Author

the changes which are also in patch need to be removed from the PR, right ?

I checked with other patches and they were applied to the code that is why I didn't remove from PR. Also if I remove these changes , I didn't find code which will apply the patch before running on CI. Maybe @directhex or @akoeplinger will know?

inputs:
targetPath: 'artifacts/bin'
artifactName: Artifacts_Wasi_Threading
condition: and(succeeded(), ne(variables['System.TeamProject'], 'public'), ne(variables['Build.Reason'], 'PullRequest'))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
condition: and(succeeded(), ne(variables['System.TeamProject'], 'public'), ne(variables['Build.Reason'], 'PullRequest'))
condition: and(succeeded(), ne(variables['System.TeamProject'], 'public'), ne(variables['Build.Reason'], 'PullRequest'))

eng/icu.proj Outdated Show resolved Hide resolved
eng/icu.proj Outdated
</ReadLinesFromFile>

<PropertyGroup>
<WASI_SDK_PATH>$(RepoRoot)\artifacts</WASI_SDK_PATH>
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed here? What is using it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed, was not used.

eng/icu.proj Outdated
<WASI_SDK_PATH>$(RepoRoot)\artifacts</WASI_SDK_PATH>
<WasiLocalPath>$(RepoRoot)\artifacts</WasiLocalPath>
<WasiSdkVersion>%(_VersionLines.Identity)</WasiSdkVersion>
<WasiSdkUrl>https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-linux.tar.gz</WasiSdkUrl>
Copy link
Member

Choose a reason for hiding this comment

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

Condition for OS here too. And we can use <Error if the url is not set, eg. on windows.

eng/icu.proj Outdated
Comment on lines 47 to 49
<WasiLocalPath>$(RepoRoot)\artifacts</WasiLocalPath>
<WasiSdkVersion>%(_VersionLines.Identity)</WasiSdkVersion>
<WasiSdkUrl>https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-linux.tar.gz</WasiSdkUrl>
Copy link
Member

Choose a reason for hiding this comment

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

These properties are only for private use, so prepend _ to the names like _WasiLocalPath.

eng/icu.proj Outdated
<WasiSdkUrl Condition="$([MSBuild]::IsOSPlatform('OSX'))" >https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-$(WasiSdkVersion)/wasi-sdk-$(WasiSdkVersion).0-macos.tar.gz</WasiSdkUrl>
</PropertyGroup>

<Exec Command="rm -rf wasi-sdk-*/ wasi-sdk/ &amp;&amp; curl -L -o- $(WasiSdkUrl) | tar -xvz &amp;&amp; mv wasi-sdk-$(WasiSdkVersion).*/ wasi-sdk/"
Copy link
Member

Choose a reason for hiding this comment

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

This won't show any errors with downloading the tarball. Add --fail -S to the curl command.

Copy link
Member

Choose a reason for hiding this comment

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

I guess we could do the same improvements on runtime repo

eng/icu.wasi.mk Outdated
Comment on lines 22 to 26
CFLAGS="-Oz -fno-exceptions -Wno-sign-compare $(THREADS_FLAG) $(ICU_DEFINES)" \
CXXFLAGS="-Oz -fno-exceptions -Wno-sign-compare $(THREADS_FLAG) $(ICU_DEFINES)" \
CC="$(WASI_SDK_PATH)/bin/clang --sysroot=$(WASI_SDK_PATH)/share/wasi-sysroot" \
CXX="$(WASI_SDK_PATH)/bin/clang++ --sysroot=$(WASI_SDK_PATH)/share/wasi-sysroot" \
--host=$(HOST_PLATFORM) --build=wasm32
Copy link
Member

Choose a reason for hiding this comment

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

spaces -> tabs for make file.

Suggested change
CFLAGS="-Oz -fno-exceptions -Wno-sign-compare $(THREADS_FLAG) $(ICU_DEFINES)" \
CXXFLAGS="-Oz -fno-exceptions -Wno-sign-compare $(THREADS_FLAG) $(ICU_DEFINES)" \
CC="$(WASI_SDK_PATH)/bin/clang --sysroot=$(WASI_SDK_PATH)/share/wasi-sysroot" \
CXX="$(WASI_SDK_PATH)/bin/clang++ --sysroot=$(WASI_SDK_PATH)/share/wasi-sysroot" \
--host=$(HOST_PLATFORM) --build=wasm32
CFLAGS="-Oz -fno-exceptions -Wno-sign-compare $(THREADS_FLAG) $(ICU_DEFINES)" \
CXXFLAGS="-Oz -fno-exceptions -Wno-sign-compare $(THREADS_FLAG) $(ICU_DEFINES)" \
CC="$(WASI_SDK_PATH)/bin/clang --sysroot=$(WASI_SDK_PATH)/share/wasi-sysroot" \
CXX="$(WASI_SDK_PATH)/bin/clang++ --sysroot=$(WASI_SDK_PATH)/share/wasi-sysroot" \
--host=$(HOST_PLATFORM) --build=wasm32

eng/icu.wasi.mk Outdated
--host=$(HOST_PLATFORM) --build=wasm32

check-env:
:
Copy link
Member

Choose a reason for hiding this comment

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

space -> tab

Suggested change
:
:

@@ -188,6 +235,14 @@ stages:
inputs:
artifact: Artifacts_Browser_Threading
path: 'artifacts/bin/browser-threading'
- task: DownloadPipelineArtifact@2
Copy link
Member

Choose a reason for hiding this comment

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

For a future PR: This Publish Packages job should run for PRs too, and generate the packages, but skip the publishing part itself. This would ensure that the PR doesn't break packaging.

@pavelsavara
Copy link
Member

the changes which are also in patch need to be removed from the PR, right ?

I checked with other patches and they were applied to the code that is why I didn't remove from PR. Also if I remove these changes , I didn't find code which will apply the patch before running on CI. Maybe @directhex or @akoeplinger will know?

Does anyone know why we have both the patch files and the changes in files ?

@akoeplinger
Copy link
Member

The patch files in icu-patches/ are from the upstream Microsoft fork of the ICU repo, not ours in dotnet. We haven't been keeping patch files for our changes, but just committing directly (with the disadvantage of having to go back and reapply changes when we move to a new ICU branch).

pavelsavara

This comment was marked as outdated.

@pavelsavara pavelsavara dismissed their stale review January 24, 2023 14:58

got explanation already

eng/icu.proj Outdated
@@ -37,4 +39,18 @@
Lines="@(_ItemsFromEmscriptenVersionFile->Replace('&quot;', ''))"
Overwrite="true" />
</Target>
<Target Name="PatchWasiSdk" Condition="'$(TargetOS)' == 'Wasi'">
Copy link
Member

Choose a reason for hiding this comment

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

Please rename to DownloadWasiSdk. Also I'm not clear if this is necessary when running on docker image with wasi SDK already in place.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated, now it will download wasi sdk only when needed.

@mkhamoyan mkhamoyan enabled auto-merge (squash) January 26, 2023 07:31
@mkhamoyan mkhamoyan merged commit 4d40948 into dotnet:dotnet/main Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants