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

[NativeAOT-LLVM] Implement most of globalization #2490

Merged
merged 6 commits into from
Jan 22, 2024

Conversation

SingleAccretion
Copy link

@SingleAccretion SingleAccretion commented Jan 18, 2024

How this works:

  1. At runtime build time, we receive a transport package with the ICU libraries and data (icudt.dat and friends).
  2. We package the data file into a static library with some inline assembly magic. We add a bit of code to the shim to locate the symbol in this static library, and tweak the CoreLib code to invoke that path on NativeAOT+WASM.
  3. We package all of the resulting ICU static libraries into the runtime package, just like libSystem.Native.a and friends.
  4. We link in the necessary pieces with the usual mechanism.

Overall few changes are required, but this is notably different from what Mono does, which runs some code at runtime startup that locates the ICU data (either by downloading it, or from the file system, or from the single-file bundle). It means that our DotNetJsApi case will still use the static data, but do that startup thing too. We can cross the bridge of reconciling these two approaches once DotNetJsApi gets a little more mature.

Another part not yet working is the time zone data, which uses Mono-specific bundling mechanism. It is the last undefined symbol for HelloWasm targeting WASI, I will tackle it separately (in #2491).

@SingleAccretion SingleAccretion changed the title [NativeAOT-LLVM] Implement globalization [NativeAOT-LLVM] Implement most of globalization Jan 18, 2024
Comment on lines +33 to +44
<Target Name="BuildNativeCommon"
DependsOnTargets="GenerateNativeVersionFile">
<ItemGroup>
<_IcuArtifacts Condition="'$(_IcuDir)' != '' and '$(TargetsAppleMobile)' != 'true'"
Include="$(_IcuDir)/lib/libicuuc.a;
$(_IcuDir)/lib/libicui18n.a;
$(_IcuDir)/lib/libicudata.a;
$(_IcuDir)/lib/*.dat" />
</ItemGroup>

<Copy SourceFiles="@(_IcuArtifacts)" DestinationFolder="$([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'native', '$(_BuildNativeOutConfig)'))" SkipUnchangedFiles="true" />
</Target>
Copy link
Author

Choose a reason for hiding this comment

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

I hope to upstream changes to this file, and perhaps remove the duplicate copying done by wasm.proj/wasi.proj.

Comment on lines 565 to 566
<!-- We want to put 'warn-unresolved-symbols' here, but wasm-ld crashs on that. Oops. -->
<CustomLinkerArg Include="-Wl,--unresolved-symbols=ignore-all" />
Copy link
Author

@SingleAccretion SingleAccretion Jan 18, 2024

Choose a reason for hiding this comment

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

Will have to debug and file a bug on LLVM about this (if it hasn't been fixed already)...

Edit: there is one already - llvm/llvm-project#53987.

@jkotas jkotas added the area-NativeAOT-LLVM LLVM generation for Native AOT compilation (including Web Assembly) label Jan 18, 2024
@SingleAccretion SingleAccretion marked this pull request as ready for review January 18, 2024 22:20
@SingleAccretion
Copy link
Author

@dotnet/nativeaot-llvm

@jkotas
Copy link
Member

jkotas commented Jan 19, 2024

FYI: Likely conflict with dotnet/runtime#97216

In ".align X", "X" is a power of two.

Also, use a zero-sized end symbol.
Symbols need not have > 0 sizes.
Copy link
Contributor

@yowl yowl left a comment

Choose a reason for hiding this comment

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

Nice, thanks

@jkotas jkotas merged commit 507fccb into dotnet:feature/NativeAOT-LLVM Jan 22, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-NativeAOT-LLVM LLVM generation for Native AOT compilation (including Web Assembly)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants