Skip to content

Commit 230ae23

Browse files
committed
builtins: adjust code for ARM64 on MSVC harder
This addresses additional compilation issues that were highlighted by trying to build the builtins for Windows ARM64 on the Swift rebranch.
1 parent 8c2a65f commit 230ae23

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

compiler-rt/lib/builtins/aarch64/fp_mode.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
// For soft float targets, allow changing rounding mode by overriding the weak
2525
// __aarch64_fe_default_rmode symbol.
2626
#if defined(_MSC_VER)
27+
extern CRT_FE_ROUND_MODE __default_rmode;
2728
CRT_FE_ROUND_MODE __default_rmode = CRT_FE_TONEAREST;
2829
#pragma comment(linker, "/alternatename:__aarch64_fe_default_rmode=__default_rmode")
2930
#else

compiler-rt/lib/builtins/aarch64/lse.S

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@
2828
.arch armv8-a
2929
#endif
3030

31-
#if !defined(__APPLE__)
32-
HIDDEN(__aarch64_have_lse_atomics)
33-
#else
34-
HIDDEN(___aarch64_have_lse_atomics)
35-
#endif
31+
HIDDEN(SYMBOL_NAME(__aarch64_have_lse_atomics))
3632

3733
// Generate mnemonics for
3834
// L_cas: SIZE: 1,2,4,8,16 MODEL: 1,2,3,4,5
@@ -131,13 +127,8 @@ HIDDEN(___aarch64_have_lse_atomics)
131127

132128
// Macro for branch to label if no LSE available
133129
.macro JUMP_IF_NOT_LSE label
134-
#if !defined(__APPLE__)
135-
adrp x(tmp0), __aarch64_have_lse_atomics
136-
ldrb w(tmp0), [x(tmp0), :lo12:__aarch64_have_lse_atomics]
137-
#else
138-
adrp x(tmp0), ___aarch64_have_lse_atomics@page
139-
ldrb w(tmp0), [x(tmp0), ___aarch64_have_lse_atomics@pageoff]
140-
#endif
130+
adrp x(tmp0), SYMBOL_NAME(__aarch64_have_lse_atomics)
131+
ldrb w(tmp0), [x(tmp0), :lo12:SYMBOL_NAME(__aarch64_have_lse_atomics)]
141132
cbz w(tmp0), \label
142133
.endm
143134

compiler-rt/lib/builtins/cpu_model/aarch64.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ typedef struct __ifunc_arg_t {
3030

3131
// LSE support detection for out-of-line atomics
3232
// using HWCAP and Auxiliary vector
33-
_Bool __aarch64_have_lse_atomics
34-
__attribute__((visibility("hidden"), nocommon)) = false;
33+
#if defined(_MSC_VER)
34+
__declspec(allocate(".data"))
35+
#else
36+
__attribute__((__visibility__("hidden"), __nocommon__))
37+
#endif
38+
_Bool __aarch64_have_lse_atomics = false;
3539

3640
#if defined(__FreeBSD__)
3741
// clang-format off: should not reorder sys/auxv.h alphabetically
@@ -54,12 +58,18 @@ _Bool __aarch64_have_lse_atomics
5458

5559
#if !defined(DISABLE_AARCH64_FMV)
5660

57-
// Architecture features used
58-
// in Function Multi Versioning
61+
// Architecture features used in function multi-versioning
62+
#if defined(_MSC_VER)
63+
__declspec(allocate(".data"))
64+
#endif
5965
struct {
6066
unsigned long long features;
6167
// As features grows new fields could be added
62-
} __aarch64_cpu_features __attribute__((visibility("hidden"), nocommon));
68+
} __aarch64_cpu_features
69+
#if !defined(_MSC_VER)
70+
__attribute__((__visibility__("hidden"), __nocommon__))
71+
#endif
72+
;
6373

6474
// The formatter wants to re-order these includes, but doing so is incorrect:
6575
// clang-format off

0 commit comments

Comments
 (0)