File 0187-erts-Fix-spectre-mitigation-configure-test.patch of Package erlang
From 13e1b297d5402ee79bf80727d8025b6b9a0d4a2f Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Tue, 9 Jan 2024 09:39:32 +0100
Subject: [PATCH] erts: Fix spectre mitigation configure test
On Ubuntu 20.04 and later gcc adds -fcf-protection=full by
default, which cannot be used together with -mbranch-protect.
So we set -fcf-protection=none so that we can use -mbranch-protect.
---
erts/configure | 21 +++++++++++++++++++++
erts/configure.ac | 8 +++++++-
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/erts/configure b/erts/configure
index a09c84ff09..0920227ad8 100755
--- a/erts/configure
+++ b/erts/configure
@@ -5301,6 +5301,24 @@ printf %s "checking for spectre mitigation... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
+int
+main (void)
+{
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
+else $as_nop
+
+ CFLAGS="$CFLAGS -fcf-protection=none"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
int
main (void)
{
@@ -5315,6 +5333,9 @@ then :
printf "%s\n" "yes" >&6; }
else $as_nop
as_fn_error $? "no" "$LINENO" 5
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
diff --git a/erts/configure.ac b/erts/configure.ac
index 540cc4b3cb..aa1785ec9c 100644
--- a/erts/configure.ac
+++ b/erts/configure.ac
@@ -390,7 +390,13 @@ AS_IF([test X"$with_spectre_mitigation" != X"no"],
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[]],[[return 0;]])],
[AC_MSG_RESULT([yes])],
- [AC_MSG_ERROR([no])])
+ [
+ CFLAGS="$CFLAGS -fcf-protection=none"
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[]],[[return 0;]])],
+ [AC_MSG_RESULT([yes])],
+ [AC_MSG_ERROR([no])])
+ ])
AS_IF([test X"$with_spectre_mitigation" = X"incomplete"],
[
--
2.35.3