| Summary: | I use the i686-linux-gcc-4.6.1 compiled grub-0.97 does not work | ||
|---|---|---|---|
| Product: | buildroot | Reporter: | 万新明 <xiaxiaojin> |
| Component: | Other | Assignee: | unassigned |
| Status: | RESOLVED INVALID | ||
| Severity: | minor | CC: | buildroot, net147 |
| Priority: | P5 | ||
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Host: | Target: | ||
| Build: | |||
We have a grub package in Buildroot. Please use it to build grub. Same problem over here when using buildroot-2011.11, selecting gcc-4.6.x and 'using' buildroot compiled grub. The generated file stage2 seems corrupt (it is not recognized as being a grub component by 'file' which works fine on other systems with grub 0.97)... No problem with grub when using gcc 4.5.x (file stage2 recognises grub component...). Could you test the patch applied on the Ubuntu package, as discussed at https://bugs.launchpad.net/ubuntu/+source/grub/+bug/837815 ? Something like: --- grub-0.97.orig/debian/patches/no-reorder-functions.diff +++ grub-0.97/debian/patches/no-reorder-functions.diff @@ -0,0 +1,27 @@ +Index: b/configure.ac +=================================================================== +--- a/configure.ac ++++ b/configure.ac +@@ -113,6 +113,22 @@ + if test "x$no_stack_protector_flag" = xyes; then + STAGE2_CFLAGS="$STAGE2_CFLAGS -fno-stack-protector" + fi ++ # GCC >= 3.3 supports -fno-reorder-functions; this defends us against ++ # unlikely-to-be-executed functions being linked before _start with GCC ++ # >= 4.6. ++ AC_CACHE_CHECK([whether gcc has -fno-reorder-functions], ++ no_reorder_functions_flag, [ ++ saved_CFLAGS=$CFLAGS ++ CFLAGS="-fno-reorder-functions" ++ AC_TRY_COMPILE(, ++ , ++ no_reorder_functions_flag=yes, ++ no_reorder_functions_flag=no) ++ CFLAGS=$saved_CFLAGS ++ ]) ++ if test "x$no_reorder_functions_flag" = xyes; then ++ STAGE2_CFLAGS="$STAGE2_CFLAGS -fno-reorder-functions" ++ fi + fi + fi + (In reply to comment #4) > Could you test the patch applied on the Ubuntu package, as discussed at > https://bugs.launchpad.net/ubuntu/+source/grub/+bug/837815 ? > > Something like: > > --- grub-0.97.orig/debian/patches/no-reorder-functions.diff > +++ grub-0.97/debian/patches/no-reorder-functions.diff > @@ -0,0 +1,27 @@ > +Index: b/configure.ac > +=================================================================== > +--- a/configure.ac > ++++ b/configure.ac > +@@ -113,6 +113,22 @@ > + if test "x$no_stack_protector_flag" = xyes; then > + STAGE2_CFLAGS="$STAGE2_CFLAGS -fno-stack-protector" > + fi > ++ # GCC >= 3.3 supports -fno-reorder-functions; this defends us against > ++ # unlikely-to-be-executed functions being linked before _start with GCC > ++ # >= 4.6. > ++ AC_CACHE_CHECK([whether gcc has -fno-reorder-functions], > ++ no_reorder_functions_flag, [ > ++ saved_CFLAGS=$CFLAGS > ++ CFLAGS="-fno-reorder-functions" > ++ AC_TRY_COMPILE(, > ++ , > ++ no_reorder_functions_flag=yes, > ++ no_reorder_functions_flag=no) > ++ CFLAGS=$saved_CFLAGS > ++ ]) > ++ if test "x$no_reorder_functions_flag" = xyes; then > ++ STAGE2_CFLAGS="$STAGE2_CFLAGS -fno-reorder-functions" > ++ fi > + fi > + fi > + The patch does not work for me. Even after configure is regenerated, STAGE2_CFLAGS is empty. However, the patch from https://dev.openwrt.org/browser/trunk/package/grub/patches/030-add-stage2-ldscripts.patch works for me. (In reply to comment #4) > Could you test the patch applied on the Ubuntu package, as discussed at > https://bugs.launchpad.net/ubuntu/+source/grub/+bug/837815 ? Ubuntu package approach works at my side but not in the way given in Comment 4. Seems that configuration logic doesn't work or it is overriden with debian patch. Now, I'm aware that my way is hardcoding and not final solution to problem but at least it can be used until more systematic solution is added. Patch given here is executed after debian patch is applied. Logic to determine gcc version is missing in my approach. Also patch after debian patch is not in Buildroot spirit. 1) patch file: boot/grub/grub.500-gcc4_6_3.patch.after_debian_patch diff -Naur a/configure b/configure --- a/configure 2013-04-06 00:10:40.998698398 +0200 +++ b/configure 2013-04-06 00:26:40.610662350 +0200 @@ -3532,7 +3532,7 @@ fi fi fi - +STAGE2_CFLAGS="$STAGE2_CFLAGS -fno-reorder-functions" 2) update of boot/grub/grub.mk @@ -46,6 +46,7 @@ (cd $(@D) ; for f in `cat debian/patches/00list | grep -v ^#` ; do \ cat debian/patches/$$f | patch -g0 -p1 ; \ done) + patch -d $(@D) -p1 < boot/grub/grub.500-gcc4_6_3.patch.after_debian_patch endef GRUB_POST_PATCH_HOOKS += GRUB_DEBIAN_PATCHES I've recently posted a set of patches against grub, and it was working for me on x86. Can you test the patches at http://lists.busybox.net/pipermail/buildroot/2013-November/082351.html and report if they fix the problem for you? Sorry, my toolchain is gone. So close this bug. Thank you very much. |
grub-0.97 did not play any patch. gcc 版本 4.6.1 (Buildroot 2011.11-git) root [ grub-0.97 ]# ./configure --host=i686 CC=i686-linux-gcc --disable-ffs --prefix=/usr make make check make install GNU GRUB version 0.97 (640K lower / 3072K upper memory) [ Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename. ] grub> root (hd1,0) Filesystem type is reiserfs, partition type 0x83 grub> setup (hd1) Checking if "/boot/grub/stage1" exists... no Checking if "/grub/stage1" exists... yes Checking if "/grub/stage2" exists... yes Checking if "/grub/reiserfs_stage1_5" exists... yes Running "embed /grub/reiserfs_stage1_5 (hd1)"... 23 sectors are embedded. succeeded Running "install /grub/stage1 (hd1) (hd1)1+23 p (hd1,0)/grub/stage2 /grub/menu.lst"... failed Error 6: Mismatched or corrupt version of stage1/stage2 grub> root [ grub-0.94 ]# i686-linux-gcc -v 使用内建 specs。 COLLECT_GCC=i686-linux-gcc COLLECT_LTO_WRAPPER=/mnt/lfs/toolchain/i-uClibc-0.9.32-x86/usr/libexec/gcc/i686-unknown-linux-uclibc/4.6.1/lto-wrapper 目标:i686-unknown-linux-uclibc 配置为:/mnt/lfs/buildroot-2011.11-git/output/toolchain/gcc-4.6.1/configure --prefix=/mnt/lfs/toolchain/i-uClibc-0.9.32-x86/usr --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=i686-unknown-linux-uclibc --enable-languages=c,c++ --with-sysroot=/mnt/lfs/toolchain/i-uClibc-0.9.32-x86/usr/i686-unknown-linux-uclibc/sysroot --with-build-time-tools=/mnt/lfs/toolchain/i-uClibc-0.9.32-x86/usr/i686-unknown-linux-uclibc/bin --disable-__cxa_atexit --enable-target-optspace --enable-libgomp --with-gnu-ld --disable-libssp --disable-multilib --enable-tls --enable-shared --with-gmp=/mnt/lfs/toolchain/i-uClibc-0.9.32-x86/usr --with-mpfr=/mnt/lfs/toolchain/i-uClibc-0.9.32-x86/usr --with-mpc=/mnt/lfs/toolchain/i-uClibc-0.9.32-x86/usr --enable-threads --disable-decimal-float --with-arch=i686 --with-tune=i686 --with-pkgversion='Buildroot 2011.11-git' --with-bugurl=http://bugs.buildroot.net/ 线程模型:posix gcc 版本 4.6.1 (Buildroot 2011.11-git) flooder62 [ /mnt ]# fdisk -l Disk /dev/hda: 125 MB, 125829120 bytes 255 heads, 63 sectors/track, 15 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/hda1 1 15 120456 83 Linux Disk /dev/sda: 8011 MB, 8011120640 bytes 247 heads, 62 sectors/track, 1021 cylinders Units = cylinders of 15314 * 512 = 7840768 bytes Device Boot Start End Blocks Id System /dev/sda1 1 1021 7817766 83 Linux flooder62 [ /mnt ]# dmesg|grep -i sda sd 2:0:0:0: [sda] 15646720 512-byte logical blocks: (8.01 GB/7.46 GiB) sd 2:0:0:0: [sda] Write Protect is off sd 2:0:0:0: [sda] Mode Sense: 23 00 00 00 sd 2:0:0:0: [sda] Assuming drive cache: write through sd 2:0:0:0: [sda] Assuming drive cache: write through sda: sda1 sd 2:0:0:0: [sda] Assuming drive cache: write through sd 2:0:0:0: [sda] Attached SCSI removable disk REISERFS (device sda1): found reiserfs format "3.6" with standard journal REISERFS (device sda1): using ordered data mode REISERFS (device sda1): journal params: device sda1, size 8192, journal first block 18, max trans len 1024, max batch 900, max commit age 30, max trans age 30 REISERFS (device sda1): checking transaction log (sda1) REISERFS (device sda1): Using r5 hash to sort names REISERFS (device sda1): Created .reiserfs_priv - reserved for xattr storage. flooder62 [ /mnt ]# uname -sa Linux flooder62 2.6.32-flz62 #45 SMP Tue Jul 12 09:40:59 GMT 2011 i686 GNU/Linux flooder62 [ /mnt ]# ls /lib/lib* /lib/libc.so /lib/libgcc_s.so /lib/libpthread.so /lib/libuClibc-0.9.32.so /lib/libc.so.0 /lib/libgcc_s.so.1 /lib/libpthread.so.0 /lib/libutil-0.9.32.so /lib/libc.so.6 /lib/libm-0.9.32.so /lib/libresolv-0.9.32.so /lib/libutil.so.0 /lib/libcrypt-0.9.32.so /lib/libm.so /lib/libresolv.so /lib/libz.so /lib/libcrypt.so /lib/libm.so.0 /lib/libresolv.so.0 /lib/libz.so.1 /lib/libcrypt.so.0 /lib/libnsl-0.9.32.so /lib/librt-0.9.32.so /lib/libz.so.1.2.5 /lib/libdl-0.9.32.so /lib/libnsl.so /lib/librt.so /lib/libdl.so /lib/libnsl.so.0 /lib/librt.so.0 /lib/libdl.so.0 /lib/libpthread-0.9.32.so /lib/librt.so.1