1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

build: Test '-flto' on both compiler and linker.

Before the change ./configure incorrectly enabled -flto on toolchains
that support -flto on compiler side but don't support -flto on linker
side. This caused incorrect type size detection on nixpkgs' Darwin:

 configure:54594: checking size of size_t
 configure:54600: clang -std=gnu11 -o conftest -g -O2 -flto   conftest.c  >&5
 ld: warning: ignoring file /private/tmp/nix-build-guile-3.0.8.drv-0/conftest-00e93d.o,
   building for macOS-x86_64 but attempting to link with file built
   for unknown-unsupported file format ( 0xDE 0xC0 0x17 0x0B 0x00 0x00 0x00 0x00 0x14 0x00 0x00 0x00 0x80 0x1A 0x00 0x00 )
 Undefined symbols for architecture x86_64:
   "_main", referenced from:
      implicit entry/start for main executable
 ld: symbol(s) not found for architecture x86_64
 clang-11: error: linker command failed with exit code 1 (use -v to see invocation)

Taken from https://github.com/NixOS/nixpkgs/pull/160051#issuecomment-1046105041

The change makes sure -flto support tests basic support of just for
object file generation but for linker as well.

* configure.ac: use AC_LINK_IFELSE instead of AC_COMPILE_IFELSE.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Sergei Trofimovich 2022-02-20 09:39:59 +00:00 committed by Ludovic Courtès
parent 347321ece9
commit f047133e7b
2 changed files with 2 additions and 1 deletions

1
NEWS
View file

@ -13,6 +13,7 @@ Changes in 3.0.9 (since 3.0.8)
(https://bugs.gnu.org/54198) (https://bugs.gnu.org/54198)
** psyntax honors source properties coming from read hash extensions ** psyntax honors source properties coming from read hash extensions
(https://bugs.gnu.org/54003) (https://bugs.gnu.org/54003)
** ./configure checks whether the linker supports '-flto' (needed on macOS)
Changes in 3.0.8 (since 3.0.7) Changes in 3.0.8 (since 3.0.7)

View file

@ -69,7 +69,7 @@ AC_MSG_CHECKING([whether the compiler supports -flto])
old_CFLAGS="$CFLAGS" old_CFLAGS="$CFLAGS"
LTO_CFLAGS="-flto" LTO_CFLAGS="-flto"
CFLAGS="$CFLAGS $LTO_CFLAGS" CFLAGS="$CFLAGS $LTO_CFLAGS"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int foo;])],, [LTO_CFLAGS=]) AC_LINK_IFELSE([AC_LANG_PROGRAM([int foo;], [])],, [LTO_CFLAGS=])
CFLAGS="$old_CFLAGS" CFLAGS="$old_CFLAGS"
if test -n "$LTO_CFLAGS"; then if test -n "$LTO_CFLAGS"; then
AC_MSG_RESULT([yes]) AC_MSG_RESULT([yes])