Bug 10261

Summary: Grub2 fails to build for x86_64
Product: buildroot Reporter: Dr I J Ormshaw <ian_ormshaw>
Component: OtherAssignee: Erico Nunes <nunes.erico>
Status: RESOLVED FIXED    
Severity: major CC: buildroot, ian_ormshaw
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:
Attachments: Config file

Description Dr I J Ormshaw 2017-08-29 07:49:51 UTC
Build system:

Fedora 25 x86_64

Target system AMD x86_64 system

Buildroot version 2017.08-rc3

Error messages:

checking for x86_64-gcc... /home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-gcc
checking for x86_64-objcopy... no
checking for objcopy... objcopy
configure: WARNING: using cross tools not prefixed with host triplet
checking for x86_64-strip... no
checking for strip... strip
checking for x86_64-nm... no
checking for nm... nm
checking for x86_64-ranlib... no
checking for ranlib... ranlib
checking which extra warnings work... 
checking if compiling with clang... no
checking for options to compile assembly... 
checking whether -freg-struct-return works... yes
checking for options to get soft-float... -msoft-float
checking whether -fno-dwarf2-cfi-asm works... yes
checking whether -mno-stack-arg-probe works... yes
checking whether -fno-asynchronous-unwind-tables works... yes
checking whether -fno-unwind-tables works... yes
checking for target linking format... unknown
configure: error: no suitable link format found
package/pkg-generic.mk:217: recipe for target '/home/ian/projects/dev/builds/x86_64-5006295/buildroot/build/grub2-2.02/.stamp_configured' failed
make[2]: *** [/home/ian/projects/dev/builds/x86_64-5006295/buildroot/build/grub2-2.02/.stamp_configured] Error 1
Makefile:16: recipe for target '_all' failed
make[1]: *** [_all] Error 2
make[1]: Leaving directory '/home/ian/projects/dev/builds/x86_64-5006295/buildroot'
Makefile:105: recipe for target 'buildroot' failed
make: *** [buildroot] Error 2
Comment 1 Dr I J Ormshaw 2017-08-29 07:58:58 UTC
Configuration detail:

>>> grub2 2.02 Configuring
(cd /home/ian/projects/dev/builds/x86_64-5006295/buildroot/build/grub2-2.02/ && rm -rf config.cache && PATH="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin:/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/sbin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/ian/.local/bin:/home/ian/bin" AR="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-ar" AS="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-as" LD="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-ld" NM="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-nm" CC="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-gcc" GCC="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-gcc" CPP="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-cpp" CXX="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-g++" FC="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-gfortran" F77="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-gfortran" RANLIB="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-ranlib" READELF="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-readelf" STRIP="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-strip" OBJCOPY="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-objcopy" OBJDUMP="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-objdump" AR_FOR_BUILD="/usr/bin/ar" AS_FOR_BUILD="/usr/bin/as" CC_FOR_BUILD="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/ccache /usr/lib64/ccache/gcc" GCC_FOR_BUILD="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/ccache /usr/lib64/ccache/gcc" CXX_FOR_BUILD="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/ccache /usr/lib64/ccache/g++" LD_FOR_BUILD="/usr/bin/ld" CPPFLAGS_FOR_BUILD="-I/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/include" CFLAGS_FOR_BUILD="-O2 -I/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/include" CXXFLAGS_FOR_BUILD="-O2 -I/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/include" LDFLAGS_FOR_BUILD="-L/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/lib -Wl,-rpath,/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/lib" FCFLAGS_FOR_BUILD="" DEFAULT_ASSEMBLER="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-as" DEFAULT_LINKER="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-ld" CPPFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" CFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -O2  -fstack-protector-all" CXXFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -O2  -fstack-protector-all -fstack-protector-all" LDFLAGS="" FCFLAGS=" -O2  -fstack-protector-all" FFLAGS=" -O2  -fstack-protector-all" PKG_CONFIG="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/pkg-config" STAGING_DIR="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/x86_64-buildroot-linux-gnu/sysroot" INTLTOOL_PERL=/usr/bin/perl ac_cv_lbl_unaligned_fail=no ac_cv_func_mmap_fixed_mapped=yes ac_cv_func_memcmp_working=yes ac_cv_have_decl_malloc=yes gl_cv_func_malloc_0_nonnull=yes ac_cv_func_malloc_0_nonnull=yes ac_cv_func_calloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes lt_cv_sys_lib_search_path_spec="" ac_cv_c_bigendian=no  PATH="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin:/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/sbin:/usr/lib64/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/ian/.local/bin:/home/ian/bin" PKG_CONFIG="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/pkg-config" PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG_LIBDIR="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/lib/pkgconfig:/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/share/pkgconfig" AR="/usr/bin/ar" AS="/usr/bin/as" LD="/usr/bin/ld" NM="/usr/bin/nm" CC="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/ccache /usr/lib64/ccache/gcc" GCC="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/ccache /usr/lib64/ccache/gcc" CXX="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/ccache /usr/lib64/ccache/g++" CPP="/usr/bin/cpp" OBJCOPY="/usr/bin/objcopy" RANLIB="/usr/bin/ranlib" CPPFLAGS="-I/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/include" CFLAGS="-O2 -I/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/include" CXXFLAGS="-O2 -I/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/include" LDFLAGS="-L/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/lib -Wl,-rpath,/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/lib" INTLTOOL_PERL=/usr/bin/perl CPP="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/ccache /usr/lib64/ccache/gcc -E" TARGET_CC="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-gcc" TARGET_CFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -O2  -fstack-protector-all" TARGET_CPPFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" TARGET_LDFLAGS="" NM="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-nm" OBJCOPY="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-objcopy" STRIP="/home/ian/projects/dev/builds/x86_64-5006295/buildroot/host/bin/x86_64-buildroot-linux-gnu-strip" CONFIG_SITE=/dev/null ./configure --target=x86_64-buildroot-linux-gnu --host=x86_64-buildroot-linux-gnu --build=x86_64-pc-linux-gnu --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --localstatedir=/var --program-prefix="" --disable-gtk-doc --disable-gtk-doc-html --disable-doc --disable-docs --disable-documentation --with-xmlto=no --with-fop=no --disable-dependency-tracking --enable-ipv6 --disable-nls --disable-static --enable-shared  --target=x86_64 --with-platform=efi --prefix=/ --exec-prefix=/ --disable-grub-mkfont --enable-efiemu=no ac_cv_lib_lzma_lzma_code=no --enable-device-mapper=no --enable-libzfs=no --disable-werror )
configure: WARNING: unrecognized options: --disable-gtk-doc, --disable-gtk-doc-html, --disable-doc, --disable-docs, --disable-documentation, --with-xmlto, --with-fop, --enable-ipv6, --disable-static, --enable-shared
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-buildroot-linux-gnu
checking target system type... x86_64-pc-none
Comment 2 Erico Nunes 2017-08-29 09:56:28 UTC
I have done a lot of grub2 builds for x86_64 on Fedora 25 and even recently tested the pc_x86_64_bios_defconfig and pc_x86_64_efi_defconfig configs on Fedora 26 as well and did not hit this issue.

Is this a clean build (make clean all)?
Can you please attach a .config file where you see the problem, for us to try to reproduce it?
Comment 3 Dr I J Ormshaw 2017-08-29 12:02:12 UTC
Created attachment 7216 [details]
Config file

Sorry I thought I had attached the config file, but it turns out it is too large to attach. So I've bzip2'ed it now
Comment 4 Dr I J Ormshaw 2017-08-29 13:34:04 UTC
It was a clean build.  I've but to check I've done a make clean all, and sill get the same error
Comment 5 Erico Nunes 2017-08-29 14:57:10 UTC
I am able to reproduce the issue with your config, running Fedora 26 if that matters. Had to remove some of your user specific settings such as ones pointing to your BR2_EXTERNAL, but nevertheless reproduced:

> checking whether -fno-asynchronous-unwind-tables works... yes
> checking whether -fno-unwind-tables works... yes
> checking for target linking format... unknown
> configure: error: no suitable link format found

I retested and am not able to reproduce a grub2 build failure with pc_x86_64_efi_defconfig, so it must be one of your changes.

So now we need to narrow down which of your changes caused this, might be the changes in the grub2 config or more likely some of your optimization settings.

Also we might consider retesting this with the v2 patchset on patchwork at [1] since it did some better separation between the host part and target part of grub2 which I wouldn't discard being a cause here (this would be one more reason to have something like that merged). I plan to respin that for 2017.11.


[1] https://patchwork.ozlabs.org/project/buildroot/list/?submitter=46481&q=grub2&archive=&delegate=&state=*
Comment 6 Erico Nunes 2017-08-30 01:50:09 UTC
It turns out that grub2 fails to build with BR2_SSP_ALL=y.
The following defconfig is enough to reproduce the issue:

BR2_x86_64=y
BR2_SSP_ALL=y
BR2_TOOLCHAIN_BUILDROOT_GLIBC=y
BR2_TARGET_GRUB2=y
BR2_TARGET_GRUB2_X86_64_EFI=y

We already had Bug 8946 in the past with a very similar issue and from which we can borrow a solution. So I sent the following patch as an attempt to address this issue before 2017.08 is cut out:
https://patchwork.ozlabs.org/patch/807377/
Comment 7 Thomas Petazzoni 2017-08-30 20:10:24 UTC
Fixed by https://git.buildroot.org/buildroot/commit/?id=2a27294e9ade6130a12ced9a1f152c51431a870e. Thanks Erico!