From: Andrey Borzenkov <arvidjaar@gmail.com>
To: grub-devel@gnu.org
Cc: Beeblebrox <zaphod@berentweb.com>
Subject: [PATCH] Explicitly check for linking format to use for efiemu64 module
Date: Sun, 24 Nov 2013 21:21:04 +0400 [thread overview]
Message-ID: <1385313664-5982-1-git-send-email-arvidjaar@gmail.com> (raw)
In-Reply-To: <CAPSTsksxNk2Rz5EKHuDH3vZK1GT=WibQPjrc8GV-Anc2pu_h4g@mail.gmail.com>
Similar to check for target linking format, also check for efiemu64
instead of hardcoding -melf_x86_64. This fixes compilation on *BSD
variants. We cannot easily reuse main target check because platforms
are different (main target is 32 bit and efiemu64 - 64 bit).
This commit adds EFIEMU64_LINK_FORMAT that contains detected
link option and is used in efiemu64.o linking instead of hardcoded
value.
Reported-By: Beeblebrox <zaphod@berentweb.com>
---
Could you test this patch?
configure.ac | 29 +++++++++++++++++++++++++++--
grub-core/Makefile.am | 2 +-
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index 8619a67..be558de 100644
--- a/configure.ac
+++ b/configure.ac
@@ -654,6 +654,30 @@ if test x"$efiemu_excuse" = x ; then
efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib"
fi
fi
+if test x"$efiemu_excuse" = x ; then
+ AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [
+ grub_cv_target_cc_efiemu64_link_format=unknown
+ for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -mx86_64pe -arch,x86_64; do
+ CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone"
+ LDFLAGS="-m64 -Wl,$format -nostdlib"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+ asm (".globl start; start:");
+ asm (".globl _start; _start:");
+ asm (".globl __start; __start:");
+ void __main (void);
+ void __main (void) {}
+ ]], [[]])], [flag=1], [flag=0])
+ if test x"$flag" = x1; then
+ grub_cv_target_cc_efiemu64_link_format="$format"
+ break;
+ fi
+ done])
+ if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then
+ efiemu_excuse="no suitable link format for efiemu64 found"
+ else
+ EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format"
+ fi
+fi
if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then
AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled])
fi
@@ -663,11 +687,12 @@ else
enable_efiemu=no
fi
AC_SUBST([enable_efiemu])
+AC_SUBST([EFIEMU64_LINK_FORMAT])
CFLAGS="$TARGET_CFLAGS"
if test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
- AC_CACHE_CHECK([for linking format], [grub_cv_target_cc_link_format], [
+ AC_CACHE_CHECK([for target linking format], [grub_cv_target_cc_link_format], [
grub_cv_target_cc_link_format=unknown
for format in -melf_${target_cpu} -melf_${target_cpu}_fbsd -melf_${target_cpu}_obsd -melf_${target_cpu}_haiku -m${target_cpu}pe -arch,${target_cpu}; do
if test x${target_cpu} != xi386 && test x$format = x${target_cpu}pe; then
@@ -681,7 +706,7 @@ if test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then
asm (".globl __start; __start:");
void __main (void);
void __main (void) {}
- ]], [[]])], [flag=1], [])
+ ]], [[]])], [flag=1], [flag=0])
if test x"$flag" = x1; then
grub_cv_target_cc_link_format="$format"
break;
diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am
index e2da083..e6862b7 100644
--- a/grub-core/Makefile.am
+++ b/grub-core/Makefile.am
@@ -421,7 +421,7 @@ efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF)
$(TARGET_OBJCONV) -felf64 -nu -nd $@.bin $@ || exit 1; \
rm -f $@.bin; \
else \
- $(TARGET_CC) -m64 -Wl,-melf_x86_64 -nostdlib -Wl,-r -o $@ $^ || exit 1; \
+ $(TARGET_CC) -m64 $(EFIEMU64_LINK_FORMAT) -nostdlib -Wl,-r -o $@ $^ || exit 1; \
if test ! -z "$(TARGET_OBJ2ELF)"; then $(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi; \
fi
--
1.8.1.4
next prev parent reply other threads:[~2013-11-24 17:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-24 9:14 grub2 boot root-on-zfs errors Beeblebrox
2013-11-24 15:08 ` Andrey Borzenkov
2013-11-25 11:08 ` Beeblebrox
2013-11-25 11:14 ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-11-25 17:29 ` Andrey Borzenkov
2013-11-25 22:12 ` Vladimir 'phcoder' Serbinenko
2013-11-24 17:21 ` Andrey Borzenkov [this message]
2013-11-25 3:59 ` [PATCH] Explicitly check for linking format to use for efiemu64 module Vladimir 'φ-coder/phcoder' Serbinenko
2013-11-25 4:22 ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-11-25 17:42 ` Andrey Borzenkov
2013-11-25 17:51 ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-11-25 18:13 ` [PATCH v2] " Andrey Borzenkov
2013-11-25 18:19 ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-11-25 18:34 ` Andrey Borzenkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1385313664-5982-1-git-send-email-arvidjaar@gmail.com \
--to=arvidjaar@gmail.com \
--cc=grub-devel@gnu.org \
--cc=zaphod@berentweb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).