blob: 73b3e9575a53496afe7d76d4809ca786862284ec [file] [log] [blame]
Pau Espin Pedrole188b8c2019-08-05 13:46:33 +02001# OS#4062 (https://osmocom.org/issues/4062)
2# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81142
3# SYS#4628
4
5# Check if We need to apply workaround for TLS bug on ARM platform for GCC < 7.3.0.
6# TLS_GCC_ARM_BUG_CFLAGS is filled with required workaround bits if needed.
7
8AC_DEFUN([CHECK_TLS_GCC_ARM_BUG], [
9 TLS_GCC_ARM_BUG_CFLAGS=""
10 AC_MSG_CHECKING([whether to workaround TLS bug in old gcc on ARM platforms])
11 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
12 [[
13 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
14 /* Check for ARM 32 bit and gcc smaller than 7.3.0 */
15 /* We need to explicitly exclude GNUC compatible compilers, since they also define GNUC related tokens */
16 #if __arm__ && \
17 !defined(__clang__) && !defined(__llvm__) && !defined(__INTEL_COMPILER) && \
18 defined(__GNUC__) && GCC_VERSION < 70300
19 #error TLS bug present!
20 #endif
21 ]])],
22 [tls_bug_present=no],
23 [tls_bug_present=yes])
24 AS_IF([test "x$tls_bug_present" = "xyes"],[
25 TLS_GCC_ARM_BUG_CFLAGS="-mtls-dialect=gnu2"
26 ])
27 AC_SUBST([TLS_GCC_ARM_BUG_CFLAGS])
28 AC_MSG_RESULT([$TLS_GCC_ARM_BUG_CFLAGS])
29])