From c18a4eddf5526f3858c7c252628f1718aecea1a3 Mon Sep 17 00:00:00 2001 From: Pramod Kumbhar Date: Sun, 7 Mar 2021 10:06:19 +0100 Subject: [PATCH] Fix build issue on Apple M1 with AppleClang (#528) * Currently catch2 is header directly added in the project - Before switching to submodule (in separate PR), copying minimal fix from the upstream: https://github.com/catchorg/Catch2/pull/1971/ * Update INSTALL.md for Apple M1 fixes #527 --- INSTALL.md | 6 ++++++ ext/catch/catch.hpp | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index e987a9d8c5..f384a6d1d1 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -46,6 +46,12 @@ Make sure to have latest flex/bison in $PATH : export PATH=/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:/usr/local/bin/:$PATH ``` +On Apple M1, corresponding brew paths are under `/opt/homebrew/opt/`: + +```sh +export PATH=/opt/homebrew/opt/flex/bin:/opt/homebrew/opt/bison/bin:$PATH +``` + ### On Ubuntu On Ubuntu (>=16.04) flex/bison versions are recent enough and are installed along with the system toolchain: diff --git a/ext/catch/catch.hpp b/ext/catch/catch.hpp index 362f8693f7..47b620d68d 100644 --- a/ext/catch/catch.hpp +++ b/ext/catch/catch.hpp @@ -1368,7 +1368,11 @@ namespace Catch { #ifdef CATCH_PLATFORM_MAC - #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */ + #if defined(__i386__) || defined(__x86_64__) + #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */ + #elif defined(__aarch64__) + #define CATCH_TRAP() __asm__(".inst 0xd4200000") + #endif #elif defined(CATCH_PLATFORM_LINUX) // If we can use inline assembler, do it because this allows us to break