lol

compiler-rt: fix build on ARMv6

compiler-rt has accumulated several regressions that prevent it from building
on ARMv6. It is important to note that there are two major versions of ARMv6:
base ARMv6 and ARMv6K. ARMv6K includes several important new instructions,
such as non-word size atomic operations (ldrexd, strexd, etc.) and the yield
instruction. Most ARMv6 CPUs actually implement ARMv6K, including all those used
in Raspberry Pis, but nixpkgs' "raspberryPi" platform targets base ARMv6.

compiler-rt versions 8-14 fail to build on ARMv6 and ARMv6K. compiler-rt 15 (not
yet in nixpkgs) builds on ARMv6K but not ARMv6. This patch fixes versions 9-14
on both ARMv6 variants. The patches don't apply cleanly to version 8, and I
figured it wasn't worth carrying another version of the patches for such an old
version.

A total of five patches are required to get compiler-rt building on ARMv6:
* armv6-mcr-dmb.patch: use `mcr` to provide the equivalent of `dmb` on ARMv6.
Included in LLVM 15.
* armv6-sync-ops-no-thumb.patch: prevent certain atomic operation functions
from using Thumb mode. Included in LLVM 15.
* armv6-no-ldrexd-strexd.patch: don't use ldrexd or strexd, which are not
available in base ARMv6. Submitted upstream by me.
* armv6-scudo-no-yield.patch: use nop instead of yield on ARMv6 in standalone
scudo. Required by versions >=13, since they enable standalone scudo.
Submitted upstream by me.
* armv6-scudo-libatomic.patch: link standlone scudo to libatomic on ARMv6 (and
any other platforms that need it). Not yet submitted because the backport is
a bit different from the upstream version and I need to test it.

+416 -1
+4
pkgs/development/compilers/llvm/10/compiler-rt/default.nix
··· 61 61 ./gnu-install-dirs.patch 62 62 ../../common/compiler-rt/libsanitizer-no-cyclades-11.patch 63 63 ./X86-support-extension.patch # backported from LLVM 11 64 + # Fix build on armv6l 65 + ../../common/compiler-rt/armv6-mcr-dmb.patch 66 + ../../common/compiler-rt/armv6-sync-ops-no-thumb.patch 67 + ../../common/compiler-rt/armv6-no-ldrexd-strexd.patch 64 68 ] ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 65 69 66 70 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
+4
pkgs/development/compilers/llvm/11/compiler-rt/default.nix
··· 66 66 ../../common/compiler-rt/libsanitizer-no-cyclades-11.patch 67 67 ../../common/compiler-rt/darwin-plistbuddy-workaround.patch 68 68 ./armv7l.patch 69 + # Fix build on armv6l 70 + ../../common/compiler-rt/armv6-mcr-dmb.patch 71 + ../../common/compiler-rt/armv6-sync-ops-no-thumb.patch 72 + ../../common/compiler-rt/armv6-no-ldrexd-strexd.patch 69 73 ]; 70 74 71 75 preConfigure = lib.optionalString stdenv.hostPlatform.isDarwin ''
+4
pkgs/development/compilers/llvm/12/compiler-rt/default.nix
··· 66 66 ./normalize-var.patch 67 67 ../../common/compiler-rt/darwin-plistbuddy-workaround.patch 68 68 ./armv7l.patch 69 + # Fix build on armv6l 70 + ../../common/compiler-rt/armv6-mcr-dmb.patch 71 + ../../common/compiler-rt/armv6-sync-ops-no-thumb.patch 72 + ../../common/compiler-rt/armv6-no-ldrexd-strexd.patch 69 73 ]; 70 74 71 75 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
+6
pkgs/development/compilers/llvm/13/compiler-rt/default.nix
··· 71 71 ./darwin-targetconditionals.patch 72 72 ../../common/compiler-rt/darwin-plistbuddy-workaround.patch 73 73 ./armv7l.patch 74 + # Fix build on armv6l 75 + ../../common/compiler-rt/armv6-mcr-dmb.patch 76 + ../../common/compiler-rt/armv6-sync-ops-no-thumb.patch 77 + ../../common/compiler-rt/armv6-no-ldrexd-strexd.patch 78 + ../../common/compiler-rt/armv6-scudo-no-yield.patch 79 + ../../common/compiler-rt/armv6-scudo-libatomic.patch 74 80 ]; 75 81 76 82 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
+6
pkgs/development/compilers/llvm/14/compiler-rt/default.nix
··· 81 81 ./darwin-targetconditionals.patch 82 82 ../../common/compiler-rt/darwin-plistbuddy-workaround.patch 83 83 ./armv7l.patch 84 + # Fix build on armv6l 85 + ../../common/compiler-rt/armv6-mcr-dmb.patch 86 + ../../common/compiler-rt/armv6-sync-ops-no-thumb.patch 87 + ../../common/compiler-rt/armv6-no-ldrexd-strexd.patch 88 + ../../common/compiler-rt/armv6-scudo-no-yield.patch 89 + ../../common/compiler-rt/armv6-scudo-libatomic.patch 84 90 ]; 85 91 86 92 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
+4
pkgs/development/compilers/llvm/9/compiler-rt/default.nix
··· 60 60 ./codesign.patch # Revert compiler-rt commit that makes codesign mandatory 61 61 ./gnu-install-dirs.patch 62 62 ../../common/compiler-rt/libsanitizer-no-cyclades-9.patch 63 + # Fix build on armv6l 64 + ../../common/compiler-rt/armv6-mcr-dmb.patch 65 + ../../common/compiler-rt/armv6-sync-ops-no-thumb.patch 66 + ../../common/compiler-rt/armv6-no-ldrexd-strexd.patch 63 67 ] ++ lib.optional stdenv.hostPlatform.isAarch32 ./armv7l.patch; 64 68 65 69 # TSAN requires XPC on Darwin, which we have no public/free source files for. We can depend on the Apple frameworks
+75
pkgs/development/compilers/llvm/common/compiler-rt/armv6-mcr-dmb.patch
··· 1 + From a11d1cc41c725ec6dee58f75e4a852a658dd7543 Mon Sep 17 00:00:00 2001 2 + From: Khem Raj <raj.khem@gmail.com> 3 + Date: Thu, 10 Mar 2022 19:30:00 -0800 4 + Subject: [PATCH] [builtins] Use mcr for dmb instruction on armv6 5 + 6 + At present compiler-rt cross compiles for armv6 ( -march=armv6 ) but includes 7 + dmb instructions which are only available in armv7+ this causes SIGILL on 8 + clang+compiler-rt compiled components on rpi0w platforms. 9 + 10 + Reviewed By: MaskRay 11 + 12 + Differential Revision: https://reviews.llvm.org/D99282 13 + --- 14 + compiler-rt/lib/builtins/arm/sync-ops.h | 8 ++++---- 15 + compiler-rt/lib/builtins/assembly.h | 8 ++++++++ 16 + 2 files changed, 12 insertions(+), 4 deletions(-) 17 + 18 + diff --git a/lib/builtins/arm/sync-ops.h b/lib/builtins/arm/sync-ops.h 19 + index c9623249e5d20..7a26170741ad2 100644 20 + --- a/lib/builtins/arm/sync-ops.h 21 + +++ b/lib/builtins/arm/sync-ops.h 22 + @@ -19,14 +19,14 @@ 23 + .thumb; \ 24 + .syntax unified; \ 25 + DEFINE_COMPILERRT_THUMB_FUNCTION(__sync_fetch_and_##op) \ 26 + - dmb; \ 27 + + DMB; \ 28 + mov r12, r0; \ 29 + LOCAL_LABEL(tryatomic_##op) : ldrex r0, [r12]; \ 30 + op(r2, r0, r1); \ 31 + strex r3, r2, [r12]; \ 32 + cmp r3, #0; \ 33 + bne LOCAL_LABEL(tryatomic_##op); \ 34 + - dmb; \ 35 + + DMB; \ 36 + bx lr 37 + 38 + #define SYNC_OP_8(op) \ 39 + @@ -35,14 +35,14 @@ 40 + .syntax unified; \ 41 + DEFINE_COMPILERRT_THUMB_FUNCTION(__sync_fetch_and_##op) \ 42 + push {r4, r5, r6, lr}; \ 43 + - dmb; \ 44 + + DMB; \ 45 + mov r12, r0; \ 46 + LOCAL_LABEL(tryatomic_##op) : ldrexd r0, r1, [r12]; \ 47 + op(r4, r5, r0, r1, r2, r3); \ 48 + strexd r6, r4, r5, [r12]; \ 49 + cmp r6, #0; \ 50 + bne LOCAL_LABEL(tryatomic_##op); \ 51 + - dmb; \ 52 + + DMB; \ 53 + pop { r4, r5, r6, pc } 54 + 55 + #define MINMAX_4(rD, rN, rM, cmp_kind) \ 56 + diff --git a/lib/builtins/assembly.h b/lib/builtins/assembly.h 57 + index 69a3d8620f924..06aa18162e3b4 100644 58 + --- a/lib/builtins/assembly.h 59 + +++ b/lib/builtins/assembly.h 60 + @@ -189,6 +189,14 @@ 61 + JMP(ip) 62 + #endif 63 + 64 + +#if __ARM_ARCH >= 7 65 + +#define DMB dmb 66 + +#elif __ARM_ARCH >= 6 67 + +#define DMB mcr p15, #0, r0, c7, c10, #5 68 + +#else 69 + +#error only supported on ARMv6+ 70 + +#endif 71 + + 72 + #if defined(USE_THUMB_2) 73 + #define WIDE(op) op.w 74 + #else 75 +
+162
pkgs/development/compilers/llvm/common/compiler-rt/armv6-no-ldrexd-strexd.patch
··· 1 + From 4fe3f21bf8b20c766877d2251d61118d0ff36688 Mon Sep 17 00:00:00 2001 2 + From: Ben Wolsieffer <benwolsieffer@gmail.com> 3 + Date: Wed, 7 Dec 2022 14:56:51 -0500 4 + Subject: [PATCH] [compiler-rt][builtins] Do not use ldrexd or strexd on ARMv6 5 + 6 + The ldrexd and strexd instructions are not available on base ARMv6, and were 7 + only added in ARMv6K (see [1]). This patch solves this problem once and for all 8 + using the __ARM_FEATURE_LDREX macro (see [2]) defined in the ARM C Language 9 + Extensions (ACLE). Although this macro is technically deprecated in the ACLE, 10 + it allows compiler-rt to reliably detect whether ldrexd and strexd are supported 11 + without complicated conditionals to detect different ARM architecture variants. 12 + 13 + [1] https://developer.arm.com/documentation/dht0008/a/ch01s02s01 14 + [2] https://arm-software.github.io/acle/main/acle.html#ldrexstrex 15 + 16 + Differential Revision: https://reviews.llvm.org/D139585 17 + --- 18 + compiler-rt/lib/builtins/arm/sync_fetch_and_add_8.S | 2 +- 19 + compiler-rt/lib/builtins/arm/sync_fetch_and_and_8.S | 2 +- 20 + compiler-rt/lib/builtins/arm/sync_fetch_and_max_8.S | 2 +- 21 + compiler-rt/lib/builtins/arm/sync_fetch_and_min_8.S | 2 +- 22 + compiler-rt/lib/builtins/arm/sync_fetch_and_nand_8.S | 2 +- 23 + compiler-rt/lib/builtins/arm/sync_fetch_and_or_8.S | 2 +- 24 + compiler-rt/lib/builtins/arm/sync_fetch_and_sub_8.S | 2 +- 25 + compiler-rt/lib/builtins/arm/sync_fetch_and_umax_8.S | 2 +- 26 + compiler-rt/lib/builtins/arm/sync_fetch_and_umin_8.S | 2 +- 27 + compiler-rt/lib/builtins/arm/sync_fetch_and_xor_8.S | 2 +- 28 + 10 files changed, 10 insertions(+), 10 deletions(-) 29 + 30 + diff --git a/lib/builtins/arm/sync_fetch_and_add_8.S b/lib/builtins/arm/sync_fetch_and_add_8.S 31 + index 18bdd875b8b7..bee6f7ba0f34 100644 32 + --- a/lib/builtins/arm/sync_fetch_and_add_8.S 33 + +++ b/lib/builtins/arm/sync_fetch_and_add_8.S 34 + @@ -13,7 +13,7 @@ 35 + 36 + #include "sync-ops.h" 37 + 38 + -#if __ARM_ARCH_PROFILE != 'M' 39 + +#if __ARM_FEATURE_LDREX & 8 40 + #define add_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) \ 41 + adds rD_LO, rN_LO, rM_LO ; \ 42 + adc rD_HI, rN_HI, rM_HI 43 + diff --git a/lib/builtins/arm/sync_fetch_and_and_8.S b/lib/builtins/arm/sync_fetch_and_and_8.S 44 + index 3716eff809d5..b4e77a54edf6 100644 45 + --- a/lib/builtins/arm/sync_fetch_and_and_8.S 46 + +++ b/lib/builtins/arm/sync_fetch_and_and_8.S 47 + @@ -13,7 +13,7 @@ 48 + 49 + #include "sync-ops.h" 50 + 51 + -#if __ARM_ARCH_PROFILE != 'M' 52 + +#if __ARM_FEATURE_LDREX & 8 53 + #define and_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) \ 54 + and rD_LO, rN_LO, rM_LO ; \ 55 + and rD_HI, rN_HI, rM_HI 56 + diff --git a/lib/builtins/arm/sync_fetch_and_max_8.S b/lib/builtins/arm/sync_fetch_and_max_8.S 57 + index 06115ab55246..1813274cc649 100644 58 + --- a/lib/builtins/arm/sync_fetch_and_max_8.S 59 + +++ b/lib/builtins/arm/sync_fetch_and_max_8.S 60 + @@ -13,7 +13,7 @@ 61 + 62 + #include "sync-ops.h" 63 + 64 + -#if __ARM_ARCH_PROFILE != 'M' 65 + +#if __ARM_FEATURE_LDREX & 8 66 + #define max_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) MINMAX_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI, gt) 67 + 68 + SYNC_OP_8(max_8) 69 + diff --git a/lib/builtins/arm/sync_fetch_and_min_8.S b/lib/builtins/arm/sync_fetch_and_min_8.S 70 + index 4f3e299d95cc..fa8f3477757b 100644 71 + --- a/lib/builtins/arm/sync_fetch_and_min_8.S 72 + +++ b/lib/builtins/arm/sync_fetch_and_min_8.S 73 + @@ -13,7 +13,7 @@ 74 + 75 + #include "sync-ops.h" 76 + 77 + -#if __ARM_ARCH_PROFILE != 'M' 78 + +#if __ARM_FEATURE_LDREX & 8 79 + #define min_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) MINMAX_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI, lt) 80 + 81 + SYNC_OP_8(min_8) 82 + diff --git a/lib/builtins/arm/sync_fetch_and_nand_8.S b/lib/builtins/arm/sync_fetch_and_nand_8.S 83 + index 425c94474af7..fb27219ee200 100644 84 + --- a/lib/builtins/arm/sync_fetch_and_nand_8.S 85 + +++ b/lib/builtins/arm/sync_fetch_and_nand_8.S 86 + @@ -13,7 +13,7 @@ 87 + 88 + #include "sync-ops.h" 89 + 90 + -#if __ARM_ARCH_PROFILE != 'M' 91 + +#if __ARM_FEATURE_LDREX & 8 92 + #define nand_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) \ 93 + bic rD_LO, rN_LO, rM_LO ; \ 94 + bic rD_HI, rN_HI, rM_HI 95 + diff --git a/lib/builtins/arm/sync_fetch_and_or_8.S b/lib/builtins/arm/sync_fetch_and_or_8.S 96 + index 4f18dcf84df9..3b077c8737b1 100644 97 + --- a/lib/builtins/arm/sync_fetch_and_or_8.S 98 + +++ b/lib/builtins/arm/sync_fetch_and_or_8.S 99 + @@ -13,7 +13,7 @@ 100 + 101 + #include "sync-ops.h" 102 + 103 + -#if __ARM_ARCH_PROFILE != 'M' 104 + +#if __ARM_FEATURE_LDREX & 8 105 + #define or_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) \ 106 + orr rD_LO, rN_LO, rM_LO ; \ 107 + orr rD_HI, rN_HI, rM_HI 108 + diff --git a/lib/builtins/arm/sync_fetch_and_sub_8.S b/lib/builtins/arm/sync_fetch_and_sub_8.S 109 + index 25a4a1076555..c171607eabd8 100644 110 + --- a/lib/builtins/arm/sync_fetch_and_sub_8.S 111 + +++ b/lib/builtins/arm/sync_fetch_and_sub_8.S 112 + @@ -13,7 +13,7 @@ 113 + 114 + #include "sync-ops.h" 115 + 116 + -#if __ARM_ARCH_PROFILE != 'M' 117 + +#if __ARM_FEATURE_LDREX & 8 118 + #define sub_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) \ 119 + subs rD_LO, rN_LO, rM_LO ; \ 120 + sbc rD_HI, rN_HI, rM_HI 121 + diff --git a/lib/builtins/arm/sync_fetch_and_umax_8.S b/lib/builtins/arm/sync_fetch_and_umax_8.S 122 + index aa5213ff1def..d1224f758049 100644 123 + --- a/lib/builtins/arm/sync_fetch_and_umax_8.S 124 + +++ b/lib/builtins/arm/sync_fetch_and_umax_8.S 125 + @@ -13,7 +13,7 @@ 126 + 127 + #include "sync-ops.h" 128 + 129 + -#if __ARM_ARCH_PROFILE != 'M' 130 + +#if __ARM_FEATURE_LDREX & 8 131 + #define umax_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) MINMAX_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI, hi) 132 + 133 + SYNC_OP_8(umax_8) 134 + diff --git a/lib/builtins/arm/sync_fetch_and_umin_8.S b/lib/builtins/arm/sync_fetch_and_umin_8.S 135 + index 8b40541ab47d..595444e6d053 100644 136 + --- a/lib/builtins/arm/sync_fetch_and_umin_8.S 137 + +++ b/lib/builtins/arm/sync_fetch_and_umin_8.S 138 + @@ -13,7 +13,7 @@ 139 + 140 + #include "sync-ops.h" 141 + 142 + -#if __ARM_ARCH_PROFILE != 'M' 143 + +#if __ARM_FEATURE_LDREX & 8 144 + #define umin_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) MINMAX_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI, lo) 145 + 146 + SYNC_OP_8(umin_8) 147 + diff --git a/lib/builtins/arm/sync_fetch_and_xor_8.S b/lib/builtins/arm/sync_fetch_and_xor_8.S 148 + index 7436eb1d4cae..9fc3d85cef75 100644 149 + --- a/lib/builtins/arm/sync_fetch_and_xor_8.S 150 + +++ b/lib/builtins/arm/sync_fetch_and_xor_8.S 151 + @@ -13,7 +13,7 @@ 152 + 153 + #include "sync-ops.h" 154 + 155 + -#if __ARM_ARCH_PROFILE != 'M' 156 + +#if __ARM_FEATURE_LDREX & 8 157 + #define xor_8(rD_LO, rD_HI, rN_LO, rN_HI, rM_LO, rM_HI) \ 158 + eor rD_LO, rN_LO, rM_LO ; \ 159 + eor rD_HI, rN_HI, rM_HI 160 + -- 161 + 2.38.1 162 +
+65
pkgs/development/compilers/llvm/common/compiler-rt/armv6-scudo-libatomic.patch
··· 1 + From a56bb19a9dc303a50ef12d83cd24c2395bf81076 Mon Sep 17 00:00:00 2001 2 + From: Ben Wolsieffer <benwolsieffer@gmail.com> 3 + Date: Wed, 7 Dec 2022 21:25:46 -0500 4 + Subject: [PATCH] [scudo][standalone] Use CheckAtomic to decide to link to 5 + libatomic 6 + 7 + Standalone scudo uses the atomic operation builtin functions, which require 8 + linking to libatomic on some platforms. Currently, this is done in an ad-hoc 9 + manner. MIPS platforms always link to libatomic, and the tests are always linked 10 + to it as well. libatomic is required on base ARMv6 (but not ARMv6K), but it is 11 + currently not linked, causing the build to fail. 12 + 13 + This patch replaces this ad-hoc logic with the CheckAtomic CMake module already 14 + used in other parts of LLVM. The CheckAtomic module checks whether std::atomic 15 + requires libatomic, which is not strictly the same as checking the atomic 16 + builtins, but should have the same results as far as I know. If this is 17 + problematic, a custom version of CheckAtomic could be used to specifically test 18 + the builtins. 19 + --- 20 + compiler-rt/lib/scudo/standalone/CMakeLists.txt | 7 +++++++ 21 + compiler-rt/lib/scudo/standalone/tests/CMakeLists.txt | 4 +--- 22 + 2 files changed, 8 insertions(+), 3 deletions(-) 23 + 24 + diff --git a/lib/scudo/standalone/CMakeLists.txt b/lib/scudo/standalone/CMakeLists.txt 25 + index ae5c354768c8..eb27374ca520 100644 26 + --- a/lib/scudo/standalone/CMakeLists.txt 27 + +++ b/lib/scudo/standalone/CMakeLists.txt 28 + @@ -1,5 +1,8 @@ 29 + add_compiler_rt_component(scudo_standalone) 30 + 31 + +include(DetermineGCCCompatible) 32 + +include(CheckAtomic) 33 + + 34 + include_directories(../.. include) 35 + 36 + set(SCUDO_CFLAGS) 37 + @@ -34,6 +37,10 @@ list(APPEND SCUDO_LINK_FLAGS -Wl,-z,defs,-z,now,-z,relro) 38 + 39 + list(APPEND SCUDO_LINK_FLAGS -ffunction-sections -fdata-sections -Wl,--gc-sections) 40 + 41 + +if(HAVE_CXX_ATOMICS_WITH_LIB OR HAVE_CXX_ATOMICS64_WITH_LIB) 42 + + list(APPEND SCUDO_LINK_FLAGS -latomic) 43 + +endif() 44 + + 45 + # We don't use the C++ standard library, so avoid including it by mistake. 46 + append_list_if(COMPILER_RT_HAS_NOSTDLIBXX_FLAG -nostdlib++ SCUDO_LINK_FLAGS) 47 + 48 + diff --git a/lib/scudo/standalone/tests/CMakeLists.txt b/lib/scudo/standalone/tests/CMakeLists.txt 49 + index 6d0936cbb5c1..70a5a7e959c1 100644 50 + --- a/lib/scudo/standalone/tests/CMakeLists.txt 51 + +++ b/lib/scudo/standalone/tests/CMakeLists.txt 52 + @@ -38,9 +38,7 @@ set(LINK_FLAGS 53 + ${SANITIZER_TEST_CXX_LIBRARIES} 54 + ) 55 + list(APPEND LINK_FLAGS -pthread) 56 + -# Linking against libatomic is required with some compilers 57 + -check_library_exists(atomic __atomic_load_8 "" COMPILER_RT_HAS_LIBATOMIC) 58 + -if (COMPILER_RT_HAS_LIBATOMIC) 59 + +if(HAVE_CXX_ATOMICS_WITH_LIB OR HAVE_CXX_ATOMICS64_WITH_LIB) 60 + list(APPEND LINK_FLAGS -latomic) 61 + endif() 62 + 63 + -- 64 + 2.38.1 65 +
+34
pkgs/development/compilers/llvm/common/compiler-rt/armv6-scudo-no-yield.patch
··· 1 + From ff0b373b959165477f45d9f5f9a8da471ae111ab Mon Sep 17 00:00:00 2001 2 + From: Ben Wolsieffer <benwolsieffer@gmail.com> 3 + Date: Wed, 7 Dec 2022 18:03:56 -0500 4 + Subject: [PATCH] [scudo][standalone] Only use yield on ARMv6K and newer 5 + 6 + The yield instruction is only available in ARMv6K and newer. It behaves as a 7 + nop on single threaded platforms anyway, so use nop instead on unsupported 8 + architectures. 9 + 10 + Differential Revision: https://reviews.llvm.org/D139600 11 + --- 12 + compiler-rt/lib/scudo/standalone/common.h | 5 +++++ 13 + 1 file changed, 5 insertions(+) 14 + 15 + diff --git a/lib/scudo/standalone/common.h b/lib/scudo/standalone/common.h 16 + index bc3dfec6dbba..862cda1d4bc4 100644 17 + --- a/lib/scudo/standalone/common.h 18 + +++ b/lib/scudo/standalone/common.h 19 + @@ -109,7 +109,12 @@ inline void yieldProcessor(u8 Count) { 20 + #elif defined(__aarch64__) || defined(__arm__) 21 + __asm__ __volatile__("" ::: "memory"); 22 + for (u8 I = 0; I < Count; I++) 23 + +#if __ARM_ARCH >= 6 && !defined(__ARM_ARCH_6__) 24 + + // yield is supported on ARMv6K and newer 25 + __asm__ __volatile__("yield"); 26 + +#else 27 + + __asm__ __volatile__("nop"); 28 + +#endif 29 + #endif 30 + __asm__ __volatile__("" ::: "memory"); 31 + } 32 + -- 33 + 2.38.1 34 +
+52
pkgs/development/compilers/llvm/common/compiler-rt/armv6-sync-ops-no-thumb.patch
··· 1 + From 5017de8ba4b1fe985169cf54590e858a9019a91f Mon Sep 17 00:00:00 2001 2 + From: Khem Raj <raj.khem@gmail.com> 3 + Date: Fri, 11 Mar 2022 16:25:49 -0800 4 + Subject: [PATCH] [builtins] Do not force thumb mode directive in 5 + arm/sync-ops.h 6 + 7 + .thumb_func was not switching mode until [1] 8 + so it did not show up but now that .thumb_func (without argument) is 9 + switching mode, its causing build failures on armv6 ( rpi0 ) even when 10 + build is explicitly asking for this file to be built with -marm (ARM 11 + mode), therefore use DEFINE_COMPILERRT_FUNCTION macro to add function 12 + header which considers arch and mode from compiler cmdline to decide if 13 + the function is built using thumb mode or arm mode. 14 + 15 + [1] https://reviews.llvm.org/D101975 16 + 17 + Note that it also needs https://reviews.llvm.org/D99282 18 + 19 + Reviewed By: peter.smith, MaskRay 20 + 21 + Differential Revision: https://reviews.llvm.org/D104183 22 + --- 23 + compiler-rt/lib/builtins/arm/sync-ops.h | 6 ++---- 24 + 1 file changed, 2 insertions(+), 4 deletions(-) 25 + 26 + diff --git a/lib/builtins/arm/sync-ops.h b/lib/builtins/arm/sync-ops.h 27 + index 7a26170741ad2..d914f9d3a1093 100644 28 + --- a/lib/builtins/arm/sync-ops.h 29 + +++ b/lib/builtins/arm/sync-ops.h 30 + @@ -16,9 +16,8 @@ 31 + 32 + #define SYNC_OP_4(op) \ 33 + .p2align 2; \ 34 + - .thumb; \ 35 + .syntax unified; \ 36 + - DEFINE_COMPILERRT_THUMB_FUNCTION(__sync_fetch_and_##op) \ 37 + + DEFINE_COMPILERRT_FUNCTION(__sync_fetch_and_##op) \ 38 + DMB; \ 39 + mov r12, r0; \ 40 + LOCAL_LABEL(tryatomic_##op) : ldrex r0, [r12]; \ 41 + @@ -31,9 +30,8 @@ 42 + 43 + #define SYNC_OP_8(op) \ 44 + .p2align 2; \ 45 + - .thumb; \ 46 + .syntax unified; \ 47 + - DEFINE_COMPILERRT_THUMB_FUNCTION(__sync_fetch_and_##op) \ 48 + + DEFINE_COMPILERRT_FUNCTION(__sync_fetch_and_##op) \ 49 + push {r4, r5, r6, lr}; \ 50 + DMB; \ 51 + mov r12, r0; \ 52 +
-1
pkgs/top-level/all-packages.nix
··· 15348 15348 /**/ if platform.isDarwin then 11 15349 15349 else if platform.isFreeBSD then 12 15350 15350 else if platform.isAndroid then 12 15351 - else if platform.system == "armv6l-linux" then 7 # This fixes armv6 cross-compilation 15352 15351 else if platform.isLinux then 11 15353 15352 else if platform.isWasm then 12 15354 15353 else latest_version;