From 2962ef477ff6843b6ebadac0509d4408dc32df3c Mon Sep 17 00:00:00 2001 From: Yuya Hamada Date: Wed, 26 Jul 2023 13:08:45 +0900 Subject: [PATCH 1/2] Fix '++nothing+crc' is not a recognized feature for target when compiling M1 / M2 macOS `#pragma GCC target("+nothing+crc")` is means clear outs aarch64_isa_flags. However, `#pragma clang attribute push(__attribute__((target("+nothing+crc")` is not means any, then displays ignore feature. (Not reproduce Linux on ARM (ex: Raspberry Pi)) Therefore, Compiling on M1/M2 macOS add new `#pragma`. --- ext/standard/crc32.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/standard/crc32.c b/ext/standard/crc32.c index 602ce3eeb6e2b..512bbc4c3dc89 100644 --- a/ext/standard/crc32.c +++ b/ext/standard/crc32.c @@ -68,6 +68,8 @@ static inline int has_crc32_insn(void) { # if!defined(__clang__) # pragma GCC push_options # pragma GCC target ("+nothing+crc") +# elif defined(__APPLE__) +# pragma clang attribute push(__attribute__((target("crc"))), apply_to=function) # else # pragma clang attribute push(__attribute__((target("+nothing+crc"))), apply_to=function) # endif From fd23751625949a429c036aedb1546a1822674864 Mon Sep 17 00:00:00 2001 From: Yuya Hamada Date: Fri, 28 Jul 2023 16:07:13 +0900 Subject: [PATCH 2/2] Fix pragma pop --- ext/standard/crc32.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/standard/crc32.c b/ext/standard/crc32.c index 512bbc4c3dc89..d9a4a00d9caef 100644 --- a/ext/standard/crc32.c +++ b/ext/standard/crc32.c @@ -98,6 +98,8 @@ static uint32_t crc32_aarch64(uint32_t crc, const char *p, size_t nr) { # if defined(__GNUC__) # if !defined(__clang__) # pragma GCC pop_options +# elif defined(__APPLE__) +# pragma clang attribute pop # else # pragma clang attribute pop # endif