grub2 boot root-on-zfs errors
* Is there a way to compile without docs? This does not work:
./configure --disable-werror --disable-nls --disable-docs
* I disabled the docs section manually in grub/Makefile. gmake completed but still with warning:/usr/bin/ld: unrecognised emulation mode: elf_x86_64
Supported emulations: elf_x86_64_fbsd elf_i386_fbsd
cc: error: linker command failed with exit code 1 (use -v to see invocation) gmake[3]: [efiemu64.o] Error 1 (ignored)
gmake[3]: Leaving directory `/asp/git/grub/grub-core'
* I proceeded with "gmake install" and previous error now causes a problem:
/usr/bin/install -c -m 644 all_video.mod gdb.mod testspeed.mod tr.mod
progress.mod gcry_arcfour.mod gcry_blowfish.mod gcry_camellia.mod gcry_cast5.mod gcry_crc.mod gcry_des.mod gcry_dsa.mod gcry_idea.mod gcry_md4.mod gcry_md5.mod gcry_rfc2268.mod gcry_rijndael.mod gcry_rmd160.mod gcry_rsa.mod gcry_seed.mod gcry_serpent.mod gcry_sha1.mod gcry_sha256.mod gcry_sha512.mod gcry_tiger.mod gcry_twofish.mod gcry_whirlpool.mod modinfo.sh efiemu32.o ./efiemu64.o '/usr/local/lib/grub/i386-pc'
install: ./efiemu64.o: No such file or directory
gmake[4]: *** [install-platformDATA] Error 71
gmake[4]: Leaving directory `/asp/git/grub/grub-core'
gmake[3]: *** [install-am] Error 2
gmake[3]: Leaving directory `/asp/git/grub/grub-core'
gmake[2]: *** [install] Error 2
В Sun, 24 Nov 2013 11:14:11 +0200
Beeblebrox <[email protected]> пишет:
Quoted 11 lines
* Is there a way to compile without docs? This does not work:
./configure --disable-werror --disable-nls --disable-docs* I disabled the docs section manually in grub/Makefile. gmake completed but still with warning:
/usr/bin/ld: unrecognised emulation mode:elf_x86_64
Supported emulations:elf_x86_64_fbsdelf_i386_fbsd
cc: error: linker command failed with exit code 1 (use -v to see invocation) gmake[3]: [efiemu64.o] Error 1 (ignored)
gmake[3]: Leaving directory `/asp/git/grub/grub-core'
Quoted 10 lines
* I proceeded with "gmake install" and previous error now causes a problem:
/usr/bin/install-c -m 644 all_video.mod gdb.mod testspeed.mod tr.mod
progress.mod gcry_arcfour.mod gcry_blowfish.mod gcry_camellia.mod gcry_cast5.mod gcry_crc.mod gcry_des.mod gcry_dsa.mod gcry_idea.mod gcry_md4.mod gcry_md5.mod gcry_rfc2268.mod gcry_rijndael.mod gcry_rmd160.mod gcry_rsa.mod gcry_seed.mod gcry_serpent.mod gcry_sha1.mod gcry_sha256.mod gcry_sha512.mod gcry_tiger.mod gcry_twofish.mod gcry_whirlpool.modmodinfo.shefiemu32.o ./efiemu64.o '/usr/local/lib/grub/i386-pc'
install: ./efiemu64.o: No such file or directory
As a workaround build with --disable-efiemu. You probably do not need it anyway unless booting OS X.
Quoted 10 lines
gmake[4]: *** [install-platformDATA] Error 71 gmake[4]: Leaving directory `/asp/git/grub/grub-core' gmake[3]: *** [install-am] Error 2
gmake[3]: Leaving directory `/asp/git/grub/grub-core' gmake[2]: *** [install] Error 2_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Hello.
I have built and installed Grub from trunk (lbeit without docs and efiemu, which I don't need). I have also installed the boot code and have booted from grub. Here are my results:
* grub-probe correctly identifies partitions as ZFS.
* grub-mkconfig correctly generates a config file and has the correct path, insmod code for zfs-booting.
* grub-mkconfig does not detect an ubuntu linux (btrfs) install on separate HDD.
* At boot time, grub menu comes up, and starts to boot normally into the ZFS pool. However boot stops at mounting root because "no such file system", and BTX (the FreeBSD loader) is very unresponsive. This is probably because I have newcons installed as patch in FreeBSD-current (11).
* Modified grub.cfg to include menu item having "kfreebsd //@/boot/loader" for chain-loading into BTX. Chain-load method successfully boots into zfs-based root and mounts all FS. Difference between direct-boot and chainload seems to be access to zpool.cache, which is actually different and maybe even a little buggy at this date in 11 (I had some problems with automatically bringing up non-root zpools and had to make some modifications in order to get it working)
Advise if any other info is required.
Thanks and Regards.
Quoted 3 lines · Beeblebrox
* At boot time, grub menu comes up, and starts to boot normally into the ZFS pool. However boot stops at mounting root because "no such file system", and BTX (the FreeBSD loader) is very unresponsive.
What do you mean by BTX? The standard GRUB entries for FReeBSD circumvent BTX altogether.
В Mon, 25 Nov 2013 13:08:45 +0200
Beeblebrox <[email protected]> пишет:
Quoted 1 line
* grub-mkconfig does not detect an ubuntu linux (btrfs) install on separate HDD.
Detection of other systems is implemented outside of grub2; it is done
by os-prober. grub-mkconfig will launch os-prober if it is found and
interpret its output, that's all. It is done as part of /etc/grub.d framework, so any custom code is possible instead of os-prober.
paste your grub.cfg to give context
Quoted 30 lines · Beeblebrox
Hello.
I have built and installed Grub from trunk (lbeit without docs and efiemu, which I don't need). I have also installed the boot code and have booted from grub. Here are my results:
* grub-probe correctly identifies partitions as ZFS.
* grub-mkconfig correctly generates a config file and has the correct path, insmod code for zfs-booting.
* grub-mkconfig does not detect an ubuntu linux (btrfs) install on separate HDD.
* At boot time, grub menu comes up, and starts to boot normally into the ZFS pool. However boot stops at mounting root because "no such file system", and BTX (the FreeBSD loader) is very unresponsive. This is probably because I have newcons installed as patch in FreeBSD-current (11).
* Modified grub.cfg to include menu item having "kfreebsd //@/boot/loader" for chain-loading into BTX. Chain-load method successfully boots into zfs-based root and mounts all FS. Difference between direct-boot and chainload seems to be access to zpool.cache, which is actually different and maybe even a little buggy at this date in 11 (I had some problems with automatically bringing up non-root zpools and had to make some modifications in order to get it working)Advise if any other info is required.
Thanks and Regards._______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 1/1 Explicitly check for linking format to use for efiemu64 module
In reply to BeeblebroxSimilar 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.
---
Could you test this patch?
configure.ac | 29 +++++++++++++++++++++++++++-- grub-core/Makefile.am | 2 +- 2 files changed, 28 insertions(+), 3 deletions(-)
configure.ac +27 -2
@@ -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;
grub-core/Makefile.am +1 -1
@@ -421,7 +421,7 @@ efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF) $(TARGET_OBJCONV) -felf64 -nu -nd [email protected] $@ || exit 1; \ rm -f [email protected]; \ 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
Signature · 1 line
1.8.1.4
Re: [PATCH] Explicitly check for linking format to use for efiemu64 module
Quoted 1 line · Andrey Borzenkov
+ for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -mx86_64pe -arch,x86_64; do
Remove x86_64pe. We skip it in first check as well since we have no converter for 64-bit windows binaries and the format is name i386pep, not x86_64pe
configure.ac if test x"$efiemu_excuse" = x ; then · line 662
Quoted 2 lines
configure.ac +2
-0+ CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" + LDFLAGS="-m64 -Wl,$format -nostdlib"
It should be -nostdlib -static. (see my other thread)
Re: [PATCH] Explicitly check for linking format to use for efiemu64 module
In reply to Andrey BorzenkovQuoted 23 lines · Andrey Borzenkov
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_FORMATthat contains detected link option and is used in efiemu64.o linking instead of hardcoded value.Reported-By Beeblebrox <[email protected]>---
Could you test this patch?
configure.ac | 29 +++++++++++++++++++++++++++-- grub-core/Makefile.am | 2 +- 2 files changed, 28 insertions(+), 3 deletions(-)configure.ac +0
-0
configure.ac if test x"$efiemu_excuse" = x ; then · line 660
Quoted 7 lines
configure.ac +4
-0@@ -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
As in other mail: remove -mx86_64pe
configure.ac if test x"$efiemu_excuse" = x ; then · line 662
Quoted 2 lines
configure.ac +2
-0+ CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" + LDFLAGS="-m64 -Wl,$format -nostdlib"
You need -static as otherwise on Apple systems it will try to pull in the dynamic linker which we don't want (scratch comment about other thread, I though of adding -static everywhere but it's no necessarry after all)
Quoted 49 lines
configure.ac +21
-2+ 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;grub-core/Makefile.am +0
-0
grub-core/Makefile.am efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF) · line 422
Quoted 2 lines
grub-core/Makefile.am +0
-0@@ -421,7 +421,7 @@ efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF) $(TARGET_OBJCONV) -felf64 -nu -nd [email protected] $@ || exit 1; \ rm -f [email protected]; \
Here the check for apple linker has to be adjusted as x$(EFIEMU64_LINK_FORMAT) = x-arch,x86_64
grub-core/Makefile.am efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF) · line 425
Quoted 4 lines
grub-core/Makefile.am +1
-1else \ - $(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; \
Remove TARGET_OBJ2ELF part as it's for 32-bit and we don't use PE here.
Quoted 3 lines
grub-core/Makefile.am +0
-0fi
Re: [PATCH] Explicitly check for linking format to use for efiemu64 module
В Mon, 25 Nov 2013 05:22:58 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:
Quoted 6 lines
configure.ac if test x"$efiemu_excuse" = x ; then · line 662
Quoted 2 lines
configure.ac +2
-0+ CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" + LDFLAGS="-m64 -Wl,$format -nostdlib"You need -static as otherwise on Apple systems it will try to pull in the dynamic linker which we don't want (scratch comment about other thread, I though of adding -static everywhere but it's no necessarry after all)
I used the same flags as in Makefile. If -static is needed here should not it be added to grub-core/Makefile.am as well?
Quoted 9 lines
grub-core/Makefile.am efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF) · line 422
Quoted 7 lines
grub-core/Makefile.am +0
-0@@ -421,7 +421,7 @@ efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF) $(TARGET_OBJCONV) -felf64 -nu -nd [email protected] $@ || exit 1; \ rm -f [email protected]; \Here the check for apple linker has to be adjusted as x$(EFIEMU64_LINK_FORMAT) = x-arch,x86_64
Mmm ... but I assume apple linker case *did* work before and it broke only for the case !TARGET_APPLE_LINKER. Should $(EFIEMU64_LINK_FORMAT) be added for apple linker case as well? I have no way to test it.
Re: [PATCH] Explicitly check for linking format to use for efiemu64 module
Quoted 23 lines · Andrey Borzenkov
В Mon, 25 Nov 2013 05:22:58 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:Quoted 6 lines
configure.ac if test x"$efiemu_excuse" = x ; then · line 662
Quoted 2 lines
configure.ac +2
-0+ CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" + LDFLAGS="-m64 -Wl,$format -nostdlib"You need -static as otherwise on Apple systems it will try to pull in the dynamic linker which we don't want (scratch comment about other thread, I though of adding -static everywhere but it's no necessarry after all)
I used the same flags as in
Makefile. If -static is needed here should not it be added to grub-core/Makefile.am as well?Quoted 9 lines
grub-core/Makefile.am efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF) · line 422
Quoted 7 lines
grub-core/Makefile.am +0
-0@@ -421,7 +421,7 @@ efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF) $(TARGET_OBJCONV) -felf64 -nu -nd [email protected] $@ || exit 1; \ rm -f [email protected]; \Here the check for apple linker has to be adjusted as x$(EFIEMU64_LINK_FORMAT) = x-arch,x86_64
Quoted 4 lines
Mmm ... but I assume apple linker case *did* work before and it broke only for the case !TARGET_APPLE_LINKER. Should $(EFIEMU64_LINK_FORMAT) be added for apple linker case as well? I have no way to test it.
What I mean is that TARGET_APPLE_LINKER is conditioned on link_format. And in this case we should check for efiemu64_link_format. As for the exact command, don't worry too much about it, I'll clean it up and unify the two cases after your patch is merged.
Quoted 7 lines
_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH v2 1/1 Explicitly check for linking format to use for efiemu64 module
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.
--- configure.ac | 29 +++++++++++++++++++++++++++-- grub-core/Makefile.am | 9 ++++----- 2 files changed, 31 insertions(+), 7 deletions(-)
configure.ac +27 -2
@@ -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 -arch,x86_64; do + CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" + LDFLAGS="-m64 -Wl,$format -nostdlib -static" + 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;
grub-core/Makefile.am +4 -5
@@ -399,7 +399,7 @@ efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF) fi efiemu64_c.o: efiemu/runtime/efiemu.c - if test "x$(TARGET_APPLE_LINKER)" = x1; then \ + if test "x$(EFIEMU64_LINK_FORMAT)" = x-arch,x86_64; then \ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -nostdlib -Wall -Werror -mno-red-zone -c -o $@ $< || exit 1; \ else \ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -nostdlib -Wall -Werror -O2 -mcmodel=large -mno-red-zone -c -o $@ $< || exit 1; \
@@ -407,7 +407,7 @@ efiemu64_c.o: efiemu/runtime/efiemu.c efiemu64_s.o: efiemu/runtime/efiemu.S -rm -f $@ - if test "x$(TARGET_APPLE_LINKER)" = x1; then \ + if test "x$(EFIEMU64_LINK_FORMAT)" = x-arch,x86_64; then \ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -Wall -Werror -nostdlib -O2 -mno-red-zone -c -o $@ $< || exit 1; \ else \ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -Wall -Werror -nostdlib -O2 -mcmodel=large -mno-red-zone -c -o $@ $< || exit 1; \
@@ -415,14 +415,13 @@ efiemu64_s.o: efiemu/runtime/efiemu.S efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF) -rm -f $@; \ - if test "x$(TARGET_APPLE_LINKER)" = x1; then \ + if test "x$(EFIEMU64_LINK_FORMAT)" = x-arch,x86_64; then \ rm -f [email protected]; \ $(TARGET_CC) -m64 -Wl,-r -nostdlib -o [email protected] $^ || exit 1; \ $(TARGET_OBJCONV) -felf64 -nu -nd [email protected] $@ || exit 1; \ rm -f [email protected]; \ else \ - $(TARGET_CC) -m64 -Wl,-melf_x86_64 -nostdlib -Wl,-r -o $@ $^ || exit 1; \ - if test ! -z "$(TARGET_OBJ2ELF)"; then $(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi; \ + $(TARGET_CC) -m64 $(EFIEMU64_LINK_FORMAT) -nostdlib -Wl,-r -o $@ $^ || exit 1; \ fi platform_DATA += efiemu32.o efiemu64.o
Signature · 1 line
1.8.1.4
Re: [PATCH v2] Explicitly check for linking format to use for efiemu64 module
Quoted 8 lines · Andrey Borzenkov
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_FORMATthat contains detected link option and is used in efiemu64.o linking instead of hardcoded value.
Go ahead
Quoted 105 lines
Reported-By Beeblebrox <[email protected]>--- configure.ac | 29 +++++++++++++++++++++++++++-- grub-core/Makefile.am | 9 ++++----- 2 files changed, 31 insertions(+), 7 deletions(-)configure.ac +27
-2@@ -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 -arch,x86_64; do + CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" + LDFLAGS="-m64 -Wl,$format -nostdlib -static" + 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;grub-core/Makefile.am +4
-5@@ -399,7 +399,7 @@ efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF) fi efiemu64_c.o: efiemu/runtime/efiemu.c - if test "x$(TARGET_APPLE_LINKER)" = x1; then \ + if test "x$(EFIEMU64_LINK_FORMAT)" = x-arch,x86_64; then \ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -nostdlib -Wall -Werror -mno-red-zone -c -o $@ $< || exit 1; \ else \ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -nostdlib -Wall -Werror -O2 -mcmodel=large -mno-red-zone -c -o $@ $< || exit 1; \@@ -407,7 +407,7 @@ efiemu64_c.o: efiemu/runtime/efiemu.c efiemu64_s.o: efiemu/runtime/efiemu.S -rm -f $@ - if test "x$(TARGET_APPLE_LINKER)" = x1; then \ + if test "x$(EFIEMU64_LINK_FORMAT)" = x-arch,x86_64; then \ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -Wall -Werror -nostdlib -O2 -mno-red-zone -c -o $@ $< || exit 1; \ else \ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -Wall -Werror -nostdlib -O2 -mcmodel=large -mno-red-zone -c -o $@ $< || exit 1; \@@ -415,14 +415,13 @@ efiemu64_s.o: efiemu/runtime/efiemu.S efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF) -rm -f $@; \ - if test "x$(TARGET_APPLE_LINKER)" = x1; then \ + if test "x$(EFIEMU64_LINK_FORMAT)" = x-arch,x86_64; then \ rm -f [email protected]; \ $(TARGET_CC) -m64 -Wl,-r -nostdlib -o [email protected] $^ || exit 1; \ $(TARGET_OBJCONV) -felf64 -nu -nd [email protected] $@ || exit 1; \ rm -f [email protected]; \ else \ - $(TARGET_CC) -m64 -Wl,-melf_x86_64 -nostdlib -Wl,-r -o $@ $^ || exit 1; \ - if test ! -z "$(TARGET_OBJ2ELF)"; then $(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi; \ + $(TARGET_CC) -m64 $(EFIEMU64_LINK_FORMAT) -nostdlib -Wl,-r -o $@ $^ || exit 1; \ fi platform_DATA += efiemu32.o efiemu64.o
Re: [PATCH v2] Explicitly check for linking format to use for efiemu64 module
В Mon, 25 Nov 2013 19:19:00 +0100
Vladimir 'φ-coder/phcoder' Serbinenko <[email protected]> пишет:
Quoted 10 lines · Andrey Borzenkov
Quoted 8 lines
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_FORMATthat contains detected link option and is used in efiemu64.o linking instead of hardcoded value.Go ahead
Committed with additional comment in grub-core/Makefile.am that -arch,x86_64 == Apple linker
Quoted 107 lines
Quoted 105 lines
Reported-By Beeblebrox <[email protected]>--- configure.ac | 29 +++++++++++++++++++++++++++-- grub-core/Makefile.am | 9 ++++----- 2 files changed, 31 insertions(+), 7 deletions(-)configure.ac +27
-2@@ -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 -arch,x86_64; do + CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" + LDFLAGS="-m64 -Wl,$format -nostdlib -static" + 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;grub-core/Makefile.am +4
-5@@ -399,7 +399,7 @@ efiemu32.o: efiemu/runtime/efiemu.c $(TARGET_OBJ2ELF) fi efiemu64_c.o: efiemu/runtime/efiemu.c - if test "x$(TARGET_APPLE_LINKER)" = x1; then \ + if test "x$(EFIEMU64_LINK_FORMAT)" = x-arch,x86_64; then \ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -nostdlib -Wall -Werror -mno-red-zone -c -o $@ $< || exit 1; \ else \ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -nostdlib -Wall -Werror -O2 -mcmodel=large -mno-red-zone -c -o $@ $< || exit 1; \@@ -407,7 +407,7 @@ efiemu64_c.o: efiemu/runtime/efiemu.c efiemu64_s.o: efiemu/runtime/efiemu.S -rm -f $@ - if test "x$(TARGET_APPLE_LINKER)" = x1; then \ + if test "x$(EFIEMU64_LINK_FORMAT)" = x-arch,x86_64; then \ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -Wall -Werror -nostdlib -O2 -mno-red-zone -c -o $@ $< || exit 1; \ else \ $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -m64 -Wall -Werror -nostdlib -O2 -mcmodel=large -mno-red-zone -c -o $@ $< || exit 1; \@@ -415,14 +415,13 @@ efiemu64_s.o: efiemu/runtime/efiemu.S efiemu64.o: efiemu64_c.o efiemu64_s.o $(TARGET_OBJ2ELEF) -rm -f $@; \ - if test "x$(TARGET_APPLE_LINKER)" = x1; then \ + if test "x$(EFIEMU64_LINK_FORMAT)" = x-arch,x86_64; then \ rm -f [email protected]; \ $(TARGET_CC) -m64 -Wl,-r -nostdlib -o [email protected] $^ || exit 1; \ $(TARGET_OBJCONV) -felf64 -nu -nd [email protected] $@ || exit 1; \ rm -f [email protected]; \ else \ - $(TARGET_CC) -m64 -Wl,-melf_x86_64 -nostdlib -Wl,-r -o $@ $^ || exit 1; \ - if test ! -z "$(TARGET_OBJ2ELF)"; then $(TARGET_OBJ2ELF) $@ || (rm -f $@; exit 1); fi; \ + $(TARGET_CC) -m64 $(EFIEMU64_LINK_FORMAT) -nostdlib -Wl,-r -o $@ $^ || exit 1; \ fi platform_DATA += efiemu32.o efiemu64.o