Skip to content

Conversation

@MichalStrehovsky
Copy link
Member

@MichalStrehovsky MichalStrehovsky commented Jun 15, 2023

Contributes to #87340.

Doesn't actually work E2E because the inline threadstatics work broke our Android support (the Android support code added in dotnet/corert#8323).

  C:\Users\michals\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\8.0.0-preview.6.23307.4/r
  untimes/linux-bionic-arm64/\native\libRuntime.WorkstationGC.a(MiscStubs.S.o): In function `RhpGetInlinedThreadStaticB
  ase':
  /__w/1/s/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S:12: undefined reference to `tls_InlinedThreadStatics'
  /__w/1/s/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S:12: undefined reference to `tls_InlinedThreadStatics'
  /__w/1/s/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S:12: undefined reference to `tls_InlinedThreadStatics'
  /__w/1/s/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S:12: undefined reference to `tls_InlinedThreadStatics'

The general instructions on Bionic once all of the PRs merge:

  • Download Android NDK and make sure clang from the NDK is first on the PATH
  • dotnet publish -r linux-bionic-arm64 /p:DisableUnsupportedError=true /p:PublishAotUsingRuntimePack=true

This is of course blocked on the TLS issue. The fix is probably along the lines of #77475 but because #87148 is in flight, I don't know what to do about it. I was hoping this would be previewable in .NET 8 Preview 6.

Cc @dotnet/ilc-contrib

Doesn't actually work E2E because the inline threadstatics work broke our Android support (the one added in dotnet/corert#8323).

```
  C:\Users\michals\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\8.0.0-preview.6.23307.4/r
  untimes/linux-bionic-arm64/\native\libRuntime.WorkstationGC.a(MiscStubs.S.o): In function `RhpGetInlinedThreadStaticB
  ase':
  /__w/1/s/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S:12: undefined reference to `tls_InlinedThreadStatics'
  /__w/1/s/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S:12: undefined reference to `tls_InlinedThreadStatics'
  /__w/1/s/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S:12: undefined reference to `tls_InlinedThreadStatics'
  /__w/1/s/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S:12: undefined reference to `tls_InlinedThreadStatics'
```
@ghost
Copy link

ghost commented Jun 15, 2023

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

Doesn't actually work E2E because the inline threadstatics work broke our Android support (the Android support code added in dotnet/corert#8323).

  C:\Users\michals\.nuget\packages\microsoft.netcore.app.runtime.nativeaot.linux-bionic-arm64\8.0.0-preview.6.23307.4/r
  untimes/linux-bionic-arm64/\native\libRuntime.WorkstationGC.a(MiscStubs.S.o): In function `RhpGetInlinedThreadStaticB
  ase':
  /__w/1/s/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S:12: undefined reference to `tls_InlinedThreadStatics'
  /__w/1/s/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S:12: undefined reference to `tls_InlinedThreadStatics'
  /__w/1/s/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S:12: undefined reference to `tls_InlinedThreadStatics'
  /__w/1/s/src/coreclr/nativeaot/Runtime/arm64/MiscStubs.S:12: undefined reference to `tls_InlinedThreadStatics'

The general instructions on Bionic once all of the PRs merge:

  • Download Android NDK and make sure clang from the NDK is first on the PATH
  • dotnet publish -r linux-bionic-arm64 /p:DisableUnsupportedError=true /p:PublishAotUsingRuntimePack=true

This is of course blocked on the TLS issue. The fix is probably along the lines of #77475 but because #87148 is in flight, I don't know what to do about it. I was hoping this would be previewable in .NET 8 Preview 6.

Cc @dotnet/ilc-contrib

Author: MichalStrehovsky
Assignees: -
Labels:

area-NativeAOT-coreclr

Milestone: -

<Exec Command="command -v &quot;$(CppLinker)&quot;" IgnoreExitCode="true" StandardOutputImportance="Low">
<PropertyGroup>
<_CommandProbe>command -v</_CommandProbe>
<_CommandProbe Condition="$([MSBuild]::IsOSPlatform('Windows'))">where</_CommandProbe>
Copy link
Member

Choose a reason for hiding this comment

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

This file is not used on Windows, right? (i.e. we don't support cross-OS publishing in cross build mode)

Copy link
Member Author

Choose a reason for hiding this comment

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

I ran the above dotnet publish -r linux-bionic-arm64 /p:DisableUnsupportedError=true /p:PublishAotUsingRuntimePack=true with this on Windows. Worked fine with this change.

@jkotas
Copy link
Member

jkotas commented Jun 15, 2023

The fix is probably along the lines of #77475 but because #87148 is in flight, I don't know what to do about it.

You can make it jump directly to the slow path with emulated TLS for now.

<NetCoreAppNativeLibrary Include="System.Globalization.Native" Condition="'$(StaticICULinking)' != 'true' and '$(InvariantGlobalization)' != 'true'" />
<NetCoreAppNativeLibrary Include="System.IO.Compression.Native" />
<NetCoreAppNativeLibrary Include="System.Net.Security.Native" />
<NetCoreAppNativeLibrary Include="System.Net.Security.Native" Condition="'$(_linuxLibcFlavor)' != 'bionic'" />
Copy link
Member

Choose a reason for hiding this comment

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

If I am reading the correctly, uses of System.Net.Security.Native are not ifdefed out for linux-bionic in

<UseManagedNtlm Condition="'$(TargetPlatformIdentifier)' == 'android' or '$(TargetPlatformIdentifier)' == 'tvos'">true</UseManagedNtlm>

Do we need a matching fix in the libraries too?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know. Looking at the latest Bionic Mono build, we're not building this library there either so this can't be a NativeAOT specific problem, if it is a problem:

https://dnceng.visualstudio.com/7ea9116e-9fac-403d-b258-b31fcf1bb293/_apis/build/builds/2202215/logs/1188

2023-06-16T01:47:31.0970341Z   Install the project...
2023-06-16T01:47:31.1000197Z   -- Install configuration: "RELEASE"
2023-06-16T01:47:31.1000861Z   -- Installing: /__w/1/s/artifacts/bin/native/net8.0-linux-Release-arm64/./libSystem.IO.Compression.Native.so.dbg
2023-06-16T01:47:31.1019420Z   -- Installing: /__w/1/s/artifacts/bin/native/net8.0-linux-Release-arm64/./libSystem.IO.Compression.Native.so
2023-06-16T01:47:31.1028723Z   -- Installing: /__w/1/s/artifacts/bin/native/net8.0-linux-Release-arm64/./libSystem.IO.Compression.Native.a
2023-06-16T01:47:31.1064467Z   -- Installing: /__w/1/s/artifacts/bin/native/net8.0-linux-Release-arm64/./libSystem.Native.so.dbg
2023-06-16T01:47:31.1070650Z   -- Installing: /__w/1/s/artifacts/bin/native/net8.0-linux-Release-arm64/./libSystem.Native.so
2023-06-16T01:47:31.1074222Z   -- Installing: /__w/1/s/artifacts/bin/native/net8.0-linux-Release-arm64/./libSystem.Native.a
2023-06-16T01:47:31.1085002Z   -- Installing: /__w/1/s/artifacts/bin/native/net8.0-linux-Release-arm64/./libSystem.Globalization.Native.so.dbg
2023-06-16T01:47:31.1089764Z   -- Installing: /__w/1/s/artifacts/bin/native/net8.0-linux-Release-arm64/./libSystem.Globalization.Native.so
2023-06-16T01:47:31.1092925Z   -- Installing: /__w/1/s/artifacts/bin/native/net8.0-linux-Release-arm64/./libSystem.Globalization.Native.a
2023-06-16T01:47:31.1101678Z   -- Installing: /__w/1/s/artifacts/bin/native/net8.0-linux-Release-arm64/./libSystem.Security.Cryptography.Native.OpenSsl.so.dbg
2023-06-16T01:47:31.1107872Z   -- Installing: /__w/1/s/artifacts/bin/native/net8.0-linux-Release-arm64/./libSystem.Security.Cryptography.Native.OpenSsl.so
2023-06-16T01:47:31.1114082Z   -- Installing: /__w/1/s/artifacts/bin/native/net8.0-linux-Release-arm64/./libSystem.Security.Cryptography.Native.OpenSsl.a
2023-06-16T01:47:31.1130823Z   /__w/1/s/src/native/libs

I currently can't even test this enough to run a hello world so I'm not able to answer this question. It won't be much worse than Mono-Bionic.

Copy link
Member

Choose a reason for hiding this comment

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

We may want to open an issue on it since it looks like a problem.

Copy link
Member Author

Choose a reason for hiding this comment

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

Filed #87665. It looks like System.Net.Security tests are disabled on Bionic due to "Timeout on Helix, cannot repro locally".

@VSadov
Copy link
Member

VSadov commented Jun 15, 2023

The fix is probably along the lines of #77475 but because #87148 is in flight, I don't know what to do about it.

You can make it jump directly to the slow path with emulated TLS for now.

You can also disable TLS inlining for Bionic in the ILC.
The uninlined scenario has fewer platform dependencies and could be more suitable for platform bring-up.

@MichalStrehovsky MichalStrehovsky merged commit a7f4677 into dotnet:main Jun 16, 2023
@MichalStrehovsky MichalStrehovsky deleted the buildbionic branch June 16, 2023 05:25
@ghost ghost locked as resolved and limited conversation to collaborators Jul 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants