blob: 36a418fc6a74a0088d5274b7fec4ec3a52eb27c2 [file] [log] [blame]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001configure.ac: Check if the current compiler supports the transactions
2
3Some distributions appear to have compilers that are built without support
4for transactions, even though they are GCC 4.7 or newer.
5
6Upstream-Status: Submitted [RPM5 maintainer]
7
8Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
9
10Index: rpm-5.4.15/configure.ac
11===================================================================
12--- rpm-5.4.15.orig/configure.ac
13+++ rpm-5.4.15/configure.ac
14@@ -425,9 +425,34 @@ dnl # --- other optimizations
15 rpm_CFLAGS_ADD([-D_FORTIFY_SOURCE=2 -fstack-protector], [RPM_CFLAGS])
16 dnl # rpm_CFLAGS_ADD([-fstack-protector-all],[RPM_CFLAGS])
17
18- if test \( ".`$CC --version 2>&1 | grep 'GCC'`" != . \); then
19- rpm_CFLAGS_ADD([-fgnu-tm], [RPM_CFLAGS])
20- fi
21+dnl # Check if the current gcc supports -fgnu-tm and __transaction_atomic
22+AC_MSG_CHECKING([If the compiler supports __transaction_atomic])
23+save_CFLAGS="$CFLAGS"
24+save_LDFLAGS="$LDFLAGS"
25+CFLAGS="${CFLAGS} -fgnu-tm -litm"
26+LDFLAGS="${LDFLAGS} -litm"
27+AC_LINK_IFELSE([AC_LANG_SOURCE([[
28+int
29+main()
30+{
31+#if !__clang__ && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 7) || (__GNUC__ > 4)) /* XXX gud enuf? */
32+ int i = 0;
33+ __transaction_atomic { i++; }
34+#else
35+# error Compiler does not support __transaction_atomic
36+#endif
37+ return 0;
38+}
39+]])], [
40+ AC_DEFINE([HAVE_GNUC_TM_ATOMIC], [1],
41+ [Define to 1 if the compiler supports __transaction_atomic.])
42+ AC_MSG_RESULT([yes])
43+], [
44+ CFLAGS="$save_CFLAGS"
45+ LDFLAGS="$save_LDFLAGS"
46+ AC_MSG_RESULT([no])
47+])
48+
49
50 dnl # --- options below are added to RPM_CFLAGS but _NOT_ added to CFLAGS
51 CPPFLAGS="$CPPFLAGS $RPM_CPPFLAGS"
52Index: rpm-5.4.15/rpmio/rpmutil.h
53===================================================================
54--- rpm-5.4.15.orig/rpmio/rpmutil.h
55+++ rpm-5.4.15/rpmio/rpmutil.h
56@@ -105,7 +105,7 @@
57 # define RPM_GNUC_INTERNAL
58 #endif
59
60-#if !__clang__ && __GNUC__ == 4 && __GNUC_MINOR__ >= 7 /* XXX gud enuf? */
61+#ifdef HAVE_GNUC_TM_ATOMIC
62 # define RPM_GNUC_TM_SAFE __attribute__((transaction_safe))
63 # define RPM_GNUC_TM_PURE __attribute__((transaction_pure))
64 # define RPM_GNUC_TM_CALLABLE __attribute__((transaction_callable))