Skip to content

Commit 65d3860

Browse files
Fixes for Bionic on x64 (#95313)
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.
1 parent a0dfc1a commit 65d3860

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ The .NET Foundation licenses this file to you under the MIT license.
3434

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

3839
<CrossCompileArch />
3940
<CrossCompileArch Condition="$(CrossCompileRid.EndsWith('-x64'))">x86_64</CrossCompileArch>

src/coreclr/nativeaot/Runtime/amd64/InteropThunksHelpers.S

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ LEAF_ENTRY RhCommonStub, _TEXT
1414
alloc_stack SIZEOF_FP_REGS
1515
SAVE_FLOAT_ARGUMENT_REGISTERS 0
1616

17+
#ifdef FEATURE_EMULATED_TLS
18+
call C_FUNC(RhpGetThunkData)
19+
#else
1720
INLINE_GET_TLS_VAR tls_thunkData
21+
#endif
1822

1923
RESTORE_FLOAT_ARGUMENT_REGISTERS 0
2024
free_stack SIZEOF_FP_REGS
@@ -36,10 +40,12 @@ LEAF_ENTRY RhGetCommonStubAddress, _TEXT
3640
LEAF_END RhGetCommonStubAddress, _TEXT
3741

3842

43+
#ifndef FEATURE_EMULATED_TLS
3944
LEAF_ENTRY RhGetCurrentThunkContext, _TEXT
4045

4146
INLINE_GET_TLS_VAR tls_thunkData
4247

4348
mov rax, qword ptr [rax]
4449
ret
4550
LEAF_END RhGetCurrentThunkContext, _TEXT
51+
#endif //FEATURE_EMULATED_TLS

src/coreclr/nativeaot/Runtime/unix/unixasmmacrosamd64.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,12 @@ C_FUNC(\Name):
300300

301301

302302
.macro INLINE_GETTHREAD
303+
#ifdef FEATURE_EMULATED_TLS
304+
call C_FUNC(RhpGetThread)
305+
#else
303306
// Inlined version of call C_FUNC(RhpGetThread)
304307
INLINE_GET_TLS_VAR tls_CurrentThread
308+
#endif
305309
.endm
306310

307311
.macro INLINE_THREAD_UNHIJACK threadReg, trashReg1, trashReg2

0 commit comments

Comments
 (0)