From d5524ca87b4c6ce0d96475082376c81b741f3a86 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Nov 2013 18:21:22 +0100 Subject: [PATCH] * configure.ac: Run linker tests without -Werror. Define TARGET_LDFLAGS_STATIC_LIBGCC and TARGET_LIBGCC. Change all occurences of -static-libgcc resp -lgcc to TARGET_LDFLAGS_STATIC_LIBGCC resp TARGET_LIBGCC. --- ChangeLog | 7 +++ conf/Makefile.common | 20 +------- configure.ac | 98 ++++++++++++++++++++----------------- grub-core/Makefile.core.def | 16 +++--- 4 files changed, 71 insertions(+), 70 deletions(-) diff --git a/ChangeLog b/ChangeLog index e87616cac..0bec55059 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2013-11-07 Vladimir Serbinenko + + * configure.ac: Run linker tests without -Werror. + Define TARGET_LDFLAGS_STATIC_LIBGCC and TARGET_LIBGCC. + Change all occurences of -static-libgcc resp -lgcc to + TARGET_LDFLAGS_STATIC_LIBGCC resp TARGET_LIBGCC. + 2013-11-07 Vladimir Serbinenko * configure.ac: Don't add -no-itegrated-as on clang on non-x86. diff --git a/conf/Makefile.common b/conf/Makefile.common index f1d9a558a..921e57682 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -37,26 +37,10 @@ CPPFLAGS_DEFAULT += -I$(top_srcdir)/grub-core/lib/libgcrypt-grub/src/ CCASFLAGS_DEFAULT = $(CPPFLAGS_DEFAULT) -DASM_FILE=1 BUILD_CPPFLAGS += $(CPPFLAGS_DEFAULT) -LDADD_KERNEL = - -if ! COND_i386_pc -if ! COND_i386_efi -if ! COND_i386_qemu -if ! COND_i386_coreboot -if ! COND_i386_multiboot -if ! COND_i386_ieee1275 -if ! COND_x86_64_efi -LDADD_KERNEL += -lgcc -endif -endif -endif -endif -endif -endif -endif +LDADD_KERNEL = $(TARGET_LIBGCC) CFLAGS_KERNEL = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding -LDFLAGS_KERNEL = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -static-libgcc +LDFLAGS_KERNEL = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) $(TARGET_LDFLAGS_STATIC_LIBGCC) CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) if COND_CYGWIN diff --git a/configure.ac b/configure.ac index d8bf76ffb..a2b5ce9ec 100644 --- a/configure.ac +++ b/configure.ac @@ -796,47 +796,6 @@ if test "$target_cpu" = arm; then fi fi -AC_ARG_ENABLE([werror], - [AS_HELP_STRING([--disable-werror], - [do not use -Werror when building GRUB])]) -if test x"$enable_werror" != xno ; then - TARGET_CFLAGS="$TARGET_CFLAGS -Werror" - HOST_CFLAGS="$HOST_CFLAGS -Werror" -fi - -TARGET_CPP="$TARGET_CC -E" -TARGET_CCAS=$TARGET_CC - -GRUB_TARGET_CPU="${target_cpu}" -GRUB_PLATFORM="${platform}" - -AC_SUBST(GRUB_TARGET_CPU) -AC_SUBST(GRUB_PLATFORM) - -AC_SUBST(TARGET_OBJCONV) -AC_SUBST(TARGET_CPP) -AC_SUBST(TARGET_CCAS) -AC_SUBST(TARGET_OBJ2ELF) -AC_SUBST(TARGET_APPLE_CC) -AC_SUBST(TARGET_MODULE_FORMAT) - -AC_SUBST(TARGET_CFLAGS) -AC_SUBST(TARGET_LDFLAGS) -AC_SUBST(TARGET_CPPFLAGS) -AC_SUBST(TARGET_CCASFLAGS) - -AC_SUBST(TARGET_IMG_LDSCRIPT) -AC_SUBST(TARGET_IMG_LDFLAGS) -AC_SUBST(TARGET_IMG_CFLAGS) -AC_SUBST(TARGET_IMG_BASE_LDOPT) - -AC_SUBST(HOST_CFLAGS) -AC_SUBST(HOST_LDFLAGS) -AC_SUBST(HOST_CPPFLAGS) -AC_SUBST(HOST_CCASFLAGS) - -AC_SUBST(BUILD_LIBM) - # Set them to their new values for the tests below. CC="$TARGET_CC" if test "x$TARGET_APPLE_CC" = x1 ; then @@ -845,12 +804,14 @@ else CFLAGS="$TARGET_CFLAGS -nostdlib -Wl,--defsym,___main=0x8100 -Wno-error" fi CPPFLAGS="$TARGET_CPPFLAGS" -if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 ; then -LIBS= +if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes ; then +TARGET_LIBGCC= else -LIBS=-lgcc +TARGET_LIBGCC=-lgcc fi +LIBS="$TARGET_LIBGCC" + grub_ASM_USCORE if test x$grub_cv_asm_uscore = xyes; then CFLAGS="$TARGET_CFLAGS -Wl,--defsym,_abort=_main" @@ -1356,6 +1317,55 @@ AC_SUBST(PACKAGE) AC_SUBST(VERSION) AC_SUBST(NEED_REGISTER_FRAME_INFO) +AC_ARG_ENABLE([werror], + [AS_HELP_STRING([--disable-werror], + [do not use -Werror when building GRUB])]) +if test x"$enable_werror" != xno ; then + TARGET_CFLAGS="$TARGET_CFLAGS -Werror" + HOST_CFLAGS="$HOST_CFLAGS -Werror" +fi + +if test "x$grub_cv_cc_target_clang" = xno; then + TARGET_LDFLAGS_STATIC_LIBGCC="-static-libgcc" +else + TARGET_LDFLAGS_STATIC_LIBGCC= +fi + +TARGET_CPP="$TARGET_CC -E" +TARGET_CCAS=$TARGET_CC + +GRUB_TARGET_CPU="${target_cpu}" +GRUB_PLATFORM="${platform}" + +AC_SUBST(GRUB_TARGET_CPU) +AC_SUBST(GRUB_PLATFORM) + +AC_SUBST(TARGET_OBJCONV) +AC_SUBST(TARGET_LIBGCC) +AC_SUBST(TARGET_LDFLAGS_STATIC_LIBGCC) +AC_SUBST(TARGET_CPP) +AC_SUBST(TARGET_CCAS) +AC_SUBST(TARGET_OBJ2ELF) +AC_SUBST(TARGET_APPLE_CC) +AC_SUBST(TARGET_MODULE_FORMAT) + +AC_SUBST(TARGET_CFLAGS) +AC_SUBST(TARGET_LDFLAGS) +AC_SUBST(TARGET_CPPFLAGS) +AC_SUBST(TARGET_CCASFLAGS) + +AC_SUBST(TARGET_IMG_LDSCRIPT) +AC_SUBST(TARGET_IMG_LDFLAGS) +AC_SUBST(TARGET_IMG_CFLAGS) +AC_SUBST(TARGET_IMG_BASE_LDOPT) + +AC_SUBST(HOST_CFLAGS) +AC_SUBST(HOST_LDFLAGS) +AC_SUBST(HOST_CPPFLAGS) +AC_SUBST(HOST_CCASFLAGS) + +AC_SUBST(BUILD_LIBM) + # # Automake conditionals # diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 199016103..7f3bae3c6 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -409,9 +409,9 @@ image = { cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1'; objcopyflags = '-O binary'; - mips_ldflags = '-static-libgcc -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)'; - ldadd = '-lgcc'; - cflags = '-Wno-unreachable-code -static-libgcc'; + mips_ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)'; + ldadd = '$(TARGET_LIBGCC)'; + cflags = '-Wno-unreachable-code $(TARGET_LDFLAGS_STATIC_LIBGCC)'; enable = mips; }; @@ -423,9 +423,9 @@ image = { cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1'; objcopyflags = '-O binary'; - mips_ldflags = '-static-libgcc -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)'; - ldadd = '-lgcc'; - cflags = '-static-libgcc'; + mips_ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)'; + ldadd = '$(TARGET_LIBGCC)'; + cflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC)'; enable = mips; }; @@ -443,7 +443,7 @@ image = { name = fwstart; mips_loongson = boot/mips/loongson/fwstart.S; objcopyflags = '-O binary'; - ldflags = '-static-libgcc -lgcc -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic'; + ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) $(TARGET_LIBGCC) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic'; enable = mips_loongson; }; @@ -451,7 +451,7 @@ image = { name = fwstart_fuloong2f; mips_loongson = boot/mips/loongson/fuloong2f.S; objcopyflags = '-O binary'; - ldflags = '-static-libgcc -lgcc -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic'; + ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) $(TARGET_LIBGCC) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic'; enable = mips_loongson; };