Skip to content

Commit

Permalink
Fixes for Bionic on x64 (#95313)
Browse files Browse the repository at this point in the history
Fixes #93942. Works around #95223 (a better but more risky fix is in #95312, so I'm not going to resolve that with this PR).

The first issue is that we don't consider x64 Windows (or x64 Linux) to x64 Bionic build a crossbuild. The crossbuild detection only looks at architecture, not at the OS. The fix is very conservative so that we can backport to 8.0. Bionic is always a crossbuild.

The second part is a port of dotnet/corert#8323 to x64. It is a lot less work than on arm64 because x64 Linux already has to assume `INLINE_GETTHREAD` could be a call so everything is setup for it.

I tested this all on a x64 Bionic hello world. I also ran all of smoke tests on x64 Linux with `FEATURE_EMULATED_TLS` enabled. All of this looks very non-risky so I'm going to ask for a backport.
  • Loading branch information
MichalStrehovsky committed Nov 29, 2023
1 parent a0dfc1a commit 65d3860
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The .NET Foundation licenses this file to you under the MIT license.

<CrossCompileRid />
<CrossCompileRid Condition="!$(RuntimeIdentifier.EndsWith('-$(_hostArchitecture)'))">$(RuntimeIdentifier)</CrossCompileRid>
<CrossCompileRid Condition="'$(CrossCompileRid)' == '' and '$(_linuxLibcFlavor)' == 'bionic'">$(RuntimeIdentifier)</CrossCompileRid>

<CrossCompileArch />
<CrossCompileArch Condition="$(CrossCompileRid.EndsWith('-x64'))">x86_64</CrossCompileArch>
Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/nativeaot/Runtime/amd64/InteropThunksHelpers.S
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ LEAF_ENTRY RhCommonStub, _TEXT
alloc_stack SIZEOF_FP_REGS
SAVE_FLOAT_ARGUMENT_REGISTERS 0

#ifdef FEATURE_EMULATED_TLS
call C_FUNC(RhpGetThunkData)
#else
INLINE_GET_TLS_VAR tls_thunkData
#endif

RESTORE_FLOAT_ARGUMENT_REGISTERS 0
free_stack SIZEOF_FP_REGS
Expand All @@ -36,10 +40,12 @@ LEAF_ENTRY RhGetCommonStubAddress, _TEXT
LEAF_END RhGetCommonStubAddress, _TEXT


#ifndef FEATURE_EMULATED_TLS
LEAF_ENTRY RhGetCurrentThunkContext, _TEXT

INLINE_GET_TLS_VAR tls_thunkData

mov rax, qword ptr [rax]
ret
LEAF_END RhGetCurrentThunkContext, _TEXT
#endif //FEATURE_EMULATED_TLS
4 changes: 4 additions & 0 deletions src/coreclr/nativeaot/Runtime/unix/unixasmmacrosamd64.inc
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,12 @@ C_FUNC(\Name):


.macro INLINE_GETTHREAD
#ifdef FEATURE_EMULATED_TLS
call C_FUNC(RhpGetThread)
#else
// Inlined version of call C_FUNC(RhpGetThread)
INLINE_GET_TLS_VAR tls_CurrentThread
#endif
.endm

.macro INLINE_THREAD_UNHIJACK threadReg, trashReg1, trashReg2
Expand Down

0 comments on commit 65d3860

Please sign in to comment.