diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-03-31 16:00:34 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-04-03 03:57:40 -0400 |
commit | 7b090b53fea065d2cfd967ea919426af9ba8d737 (patch) | |
tree | 28355676cf97c1b2d8e081379d74c25ceccd2def /aclocal.m4 | |
parent | bf6dbe3d1046573cb71fd534a326a9a0e6f1b220 (diff) | |
download | haskell-7b090b53fea065d2cfd967ea919426af9ba8d737.tar.gz |
configure: Always use AC_LINK_ELSEIF when testing against assembler
This fixes #16440, where the build system incorrectly concluded that the
`.subsections_via_symbols` assembler directive was supported on a Linux
system. This was caused by the fact that gcc was invoked with `-flto`;
when so-configured gcc does not call the assembler but rather simply
serialises its AST for compilation during the final link.
This is described in Note [autoconf assembler checks and -flto].
Diffstat (limited to 'aclocal.m4')
-rw-r--r-- | aclocal.m4 | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/aclocal.m4 b/aclocal.m4 index 5b037326be..d2d42f243b 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -288,11 +288,31 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS], esac } + dnl Note [autoconf assembler checks and -flto] + dnl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + dnl + dnl Autoconf's AC_COMPILE_IFELSE macro is fragile in the case of checks + dnl which require that the assembler is run. Specifically, GCC does not run + dnl the assembler if invoked with `-c -flto`; it merely dumps its internal + dnl AST to the object file, to be compiled and assembled during the final + dnl link. + dnl + dnl This can cause configure checks like that for the + dnl .subsections_via_symbols directive to pass unexpected (see #16440), + dnl leading the build system to incorrectly conclude that the directive is + dnl supported. + dnl + dnl For this reason, it is important that configure checks that rely on the + dnl assembler failing use AC_LINK_IFELSE rather than AC_COMPILE_IFELSE, + dnl ensuring that the assembler sees the check. + dnl + dnl ** check for Apple-style dead-stripping support dnl (.subsections-via-symbols assembler directive) AC_MSG_CHECKING(for .subsections_via_symbols) - AC_COMPILE_IFELSE( + dnl See Note [autoconf assembler checks and -flto] + AC_LINK_IFELSE( [AC_LANG_PROGRAM([], [__asm__ (".subsections_via_symbols");])], [AC_MSG_RESULT(yes) HaskellHaveSubsectionsViaSymbols=True @@ -305,8 +325,9 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS], dnl ** check for .ident assembler directive AC_MSG_CHECKING(whether your assembler supports .ident directive) - AC_COMPILE_IFELSE( - [AC_LANG_SOURCE([__asm__ (".ident \"GHC x.y.z\"");])], + dnl See Note [autoconf assembler checks and -flto] + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([__asm__ (".ident \"GHC x.y.z\"");], [])], [AC_MSG_RESULT(yes) HaskellHaveIdentDirective=True], [AC_MSG_RESULT(no) @@ -330,8 +351,15 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS], ;; esac AC_MSG_CHECKING(for GNU non-executable stack support) - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([__asm__ (".section .note.GNU-stack,\"\",$progbits");], [0])], + dnl See Note [autoconf assembler checks and -flto] + AC_LINK_IFELSE( + dnl the `main` function is placed after the .note.GNU-stack directive + dnl so we need to ensure that the active segment is correctly set, + dnl otherwise `main` will be placed in the wrong segment. + [AC_LANG_PROGRAM([ + __asm__ (".section .note.GNU-stack,\"\",$progbits"); + __asm__ (".section .text"); + ], [0])], [AC_MSG_RESULT(yes) HaskellHaveGnuNonexecStack=True], [AC_MSG_RESULT(no) |