From 12c8ae2541b654a09bd6a2f264856f6fc0089a23 Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 27 Aug 2015 01:26:14 +0200 Subject: Added an availability check for the -rdynamic linker option - Fixes an issue preventing to compile on non-ELF systems (i.e. OS X) using recent gcc versions (such as 5.2) that are unable to filter out this option where it's not needed. - Thanks to Smokexyz for reporting the issue. Signed-off-by: Haru --- configure.in | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'configure.in') diff --git a/configure.in b/configure.in index de709bede..5bb0dff65 100644 --- a/configure.in +++ b/configure.in @@ -487,8 +487,7 @@ AC_LANG([C]) CFLAGS="$CFLAGS -pipe -ffast-math -fvisibility=hidden -Wall -Wextra -Wno-sign-compare" CPPFLAGS="$CPPFLAGS -I../common" -LDFLAGS="$LDFLAGS -rdynamic" - +LDFLAGS="$LDFLAGS" AC_C_BIGENDIAN( [AC_MSG_ERROR([[bigendian is not supported... stopping]])], @@ -590,6 +589,32 @@ AC_RUN_IFELSE( ] ) +# +# Check if the linker supports/accepts -rdynamic +# Generally only needed by the ELF linker, in order to produce backtraces. +# On non-ELF platforms, some compilers (i.e. gcc < 5 and clang on OSX) are able to ignore it, others will error out. +# +OLD_LDFLAGS="$LDFLAGS" +LDFLAGS="$LDFLAGS -rdynamic" +AC_MSG_CHECKING([whether $CC accepts -rdynamic]) +AC_LINK_IFELSE( + [AC_LANG_SOURCE([ + int main(int argc, char **argv) + { + return 0; + } + ])], + [ + AC_MSG_RESULT([yes]) + ], + [ + AC_MSG_RESULT([no]) + LDFLAGS="$OLD_LDFLAGS" + ], + [ + AC_MSG_RESULT([guessing no]) + ] +) # # LTO Support test -- cgit v1.2.3-60-g2f50