aarch64: Fix async_fibre_swapcontext() on clang BTI builds
[openssl.git] / crypto / async / arch / async_posix.h
index eeb7774512281dfa911f6572ce848dbdce54a690..57da6e211f12340bdbd0eb74af7f56c3649b5417 100644 (file)
  */
 #   define USE_SWAPCONTEXT
 #  endif
+#  if defined(__aarch64__) && defined(__clang__) \
+    && defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1
+/*
+ * setjmp/longjmp don't currently work with BTI on all libc implementations
+ * when compiled by clang. This is because clang doesn't put a BTI after the
+ * call to setjmp where it returns the second time. This then fails on libc
+ * implementations - notably glibc - which use an indirect jump to there.
+ * So use the swapcontext implementation, which does work.
+ * See https://github.com/llvm/llvm-project/issues/48888.
+ */
+#   define USE_SWAPCONTEXT
+#  endif
 #  include <ucontext.h>
 #  ifndef USE_SWAPCONTEXT
 #   include <setjmp.h>