diff mbox

Unable to compile uboot v2012.10 on Buildroot 2016.05

Message ID 1249010753.7483898.1467378648497.JavaMail.zimbra@datacom.ind.br
State Not Applicable
Headers show

Commit Message

Carlos Santos July 1, 2016, 1:10 p.m. UTC
Hello,

My company is developing a board based on a vendor reference design which depends on a custom U-Boot, based on v2012.10. We were able to build the custom U-Boot using Buildroot before this commit:

commit 0dca644e443c8f28bfe5aa1c98201dc3b49e1165
Author: Julien Boibessot <julien.boibessot@armadeus.com>
Date:   Fri May 20 06:57:24 2016 +0200

    boot/uboot: fix missing host-openssl for i.MX28 target
    
    Building an U-Boot image for the i.MX23 or i.MX28 target requires to run the
    bootloaders 'mxsimage' tool on the host. As mxsimage needs unconditionally
    OpenSSL, building U-Boot for those targets fails if it is not available on
    the host:
    
    tools/mxsimage.c:18:25: fatal error: openssl/evp.h: No such file or directory
      #include <openssl/evp.h>
    
    Add the required dependency 'host-openssl' to all the different U-Boot image
    types used to build a bootloader image for an i.MX23/i.MX28 target.
    
    Also pass HOST_CFLAGS and HOST_LDFLAGS to the U-Boot build process so the right
    -I/-L options will be used to find OpenSSL.
    
    Ported from the Armadeus project:
    https://sourceforge.net/p/armadeus/mailman/message/33595402/
    
    Signed-off-by: Julien Boibessot <julien.boibessot@armadeus.com>
    [Jörg: port to recent Buildroot version]
    Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
    Signed-off-by: Peter Korsgaard <peter@korsgaard.com>

The problem is easily reproducible using the following defconfig, based on "beaglebone", in which BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE was set to "2012.10":

BR2_arm=y
BR2_cortex_a8=y
BR2_DL_DIR="/store/Mirror/CT-NG-Buildroot"
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_3_12=y
BR2_TARGET_GENERIC_HOSTNAME="beaglebone"
BR2_TARGET_GENERIC_GETTY_PORT="ttyO0"
# BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW is not set
BR2_ROOTFS_POST_IMAGE_SCRIPT="board/beaglebone/post-image.sh"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_GIT=y
BR2_LINUX_KERNEL_CUSTOM_REPO_URL="git://git.ti.com/ti-linux-kernel/ti-linux-kernel.git"
BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="7f280334068b7c875ade51f8f3921ab311f0c824"
BR2_LINUX_KERNEL_PATCH="board/beaglebone/patches/linux"
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/beaglebone/linux-3.12.config"
BR2_LINUX_KERNEL_DTS_SUPPORT=y
BR2_LINUX_KERNEL_INTREE_DTS_NAME="am335x-bone am335x-boneblack"
BR2_PACKAGE_AM33X_CM3=y
BR2_TARGET_ROOTFS_EXT2=y
BR2_TARGET_ROOTFS_EXT2_4=y
# BR2_TARGET_ROOTFS_TAR is not set
BR2_TARGET_UBOOT=y
BR2_TARGET_UBOOT_BOARDNAME="am335x_evm"
BR2_TARGET_UBOOT_CUSTOM_VERSION=y
BR2_TARGET_UBOOT_CUSTOM_VERSION_VALUE="2012.10"
BR2_TARGET_UBOOT_FORMAT_IMG=y
BR2_TARGET_UBOOT_SPL=y
BR2_TARGET_UBOOT_SPL_NAME="MLO"
BR2_PACKAGE_HOST_DOSFSTOOLS=y
BR2_PACKAGE_HOST_GENIMAGE=y
BR2_PACKAGE_HOST_MTOOLS=y

$ make uboot BR2_JLEVEL=1
umask 0022 && make -C /work/Buildroot O=/work/bcm95615x/. uboot
>>> uboot 2012.10 Building
PATH="/work/bcm95615x/host/bin:/work/bcm95615x/host/sbin:/work/bcm95615x/host/usr/bin:/work/bcm95615x/host/usr/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin" AR="/work/bcm95615x/host/usr/bin/arm-buildroot-linux-uclibcgnueabihf-ar" AS="/work/bcm95615x/host/usr/bin/arm-buildroot-linux-uclibcgnueabihf-as" LD="/work/bcm95615x/host/usr/bin/arm-buildroot-linux-uclibcgnueabihf-ld" NM="/work/bcm95615x/host/usr/bin/arm-buildroot-linux-uclibcgnueabihf-nm" CC="/work/bcm95615x/host/usr/bin/arm-buildroot-linux-uclibcgnueabihf-gcc" GCC="/work/bcm95615x/host/usr/bin/arm-buildroot-linux-uclibcgnueabihf-gcc" CPP="/work/bcm95615x/host/usr/bin/arm-buildroot-linux-uclibcgnueabihf-cpp" CXX="/work/bcm95615x/host/usr/bin/arm-buildroot-linux-uclibcgnueabihf-g++" FC="/work/bcm95615x/host/usr/bin/arm-buildroot-linux-uclibcgnueabihf-gfortran" RANLIB="/work/bcm95615x/host/usr/bin/arm-buildroot-linux-uclibcgnueabihf-ranlib" READELF="/work/bcm95615x/host/usr/bin/arm-buildroot-linux-uclibcgnueabihf-readelf" STRIP="/work/bcm95615x/host/usr/bin/arm-buildroot-linux-uclibcgnueabihf-strip" OBJCOPY="/work/bcm95615x/host/usr/bin/arm-buildroot-linux-uclibcgnueabihf-objcopy" OBJDUMP="/work/bcm95615x/host/usr/bin/arm-buildroot-linux-uclibcgnueabihf-objdump" AR_FOR_BUILD="/usr/bin/ar" AS_FOR_BUILD="/usr/bin/as" CC_FOR_BUILD="/usr/bin/gcc" GCC_FOR_BUILD="/usr/bin/gcc" CXX_FOR_BUILD="/usr/bin/g++" LD_FOR_BUILD="/usr/bin/ld" CPPFLAGS_FOR_BUILD="-I/work/bcm95615x/host/usr/include" CFLAGS_FOR_BUILD="-O2 -I/work/bcm95615x/host/usr/include" CXXFLAGS_FOR_BUILD="-O2 -I/work/bcm95615x/host/usr/include" LDFLAGS_FOR_BUILD="-L/work/bcm95615x/host/lib -L/work/bcm95615x/host/usr/lib -Wl,-rpath,/work/bcm95615x/host/usr/lib" FCFLAGS_FOR_BUILD="" DEFAULT_ASSEMBLER="/work/bcm95615x/host/usr/bin/arm-buildroot-linux-uclibcgnueabihf-as" DEFAULT_LINKER="/work/bcm95615x/host/usr/bin/arm-buildroot-linux-uclibcgnueabihf-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  -Os " CXXFLAGS="-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64  -Os " LDFLAGS="" FCFLAGS="" PKG_CONFIG="/work/bcm95615x/host/usr/bin/pkg-config" STAGING_DIR="/work/bcm95615x/host/usr/arm-buildroot-linux-uclibcgnueabihf/sysroot" INTLTOOL_PERL=/usr/bin/perl CXX=false /usr/bin/make -j1 -C /work/bcm95615x/build/uboot-2012.10 CROSS_COMPILE="/work/bcm95615x/host/usr/bin/arm-buildroot-linux-uclibcgnueabihf-" ARCH=arm HOSTCFLAGS="-O2 -I/work/bcm95615x/host/usr/include" HOSTLDFLAGS="-L/work/bcm95615x/host/lib -L/work/bcm95615x/host/usr/lib -Wl,-rpath,/work/bcm95615x/host/usr/lib" 
for dir in tools examples/standalone examples/api arch/arm/cpu/armv7  ; do \
		/usr/bin/make -C $dir _depend ; done
make[3]: Nothing to be done for '_depend'.
make[3]: Nothing to be done for '_depend'.
make[3]: Nothing to be done for '_depend'.
make[3]: Nothing to be done for '_depend'.
/usr/bin/make -C tools all
gcc -O2 -I/work/bcm95615x/host/usr/include   -o img2srec.o img2srec.c -c
In file included from img2srec.c:55:0:
os_support.h:22:22: fatal error: compiler.h: No such file or directory
compilation terminated.
/work/bcm95615x/build/uboot-2012.10/rules.mk:64: recipe for target 'img2srec.o' failed
make[3]: *** [img2srec.o] Error 1
Makefile:544: recipe for target 'tools' failed
make[2]: *** [tools] Error 2
package/pkg-generic.mk:201: recipe for target '/work/bcm95615x/build/uboot-2012.10/.stamp_built' failed
make[1]: *** [/work/bcm95615x/build/uboot-2012.10/.stamp_built] Error 2
Makefile:16: recipe for target '_all' failed
make: *** [_all] Error 2

The build succeeds if I apply the following patch, which partially reverts the aforementioned commit:


Do you agree?

Carlos Santos (Casantos) - DATACOM, P&D
Rua América, 1000 - Eldorado do Sul, RS, Brasil - 92990-000
casantos@datacom.ind.br          +55 51 3933.3000 ext. 3627
http://www.datacom.ind.br

Comments

Thomas Petazzoni July 1, 2016, 1:18 p.m. UTC | #1
Hello,

On Fri, 1 Jul 2016 10:10:48 -0300 (BRT), Carlos Santos wrote:

> /usr/bin/make -C tools all
> gcc -O2 -I/work/bcm95615x/host/usr/include   -o img2srec.o img2srec.c -c
> In file included from img2srec.c:55:0:
> os_support.h:22:22: fatal error: compiler.h: No such file or directory

What is your host gcc version ? This failure smells like building an
old U-Boot, with gcc 5.x as the host gcc version.

> diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk
> index a2274ee..5d171dd 100644
> --- a/boot/uboot/uboot.mk
> +++ b/boot/uboot/uboot.mk
> @@ -92,9 +92,7 @@ endif
>  
>  UBOOT_MAKE_OPTS += \
>  	CROSS_COMPILE="$(TARGET_CROSS)" \
> -	ARCH=$(UBOOT_ARCH) \
> -	HOSTCFLAGS="$(HOST_CFLAGS)" \
> -	HOSTLDFLAGS="$(HOST_LDFLAGS)"

I'm not sure to see why this would fix the problem you're reporting.

Thomas
Carlos Santos July 1, 2016, 2 p.m. UTC | #2
> From: "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>
> To: "Carlos Santos" <casantos@datacom.ind.br>
> Cc: "buildroot" <buildroot@buildroot.org>, "Julien Boibessot" <julien.boibessot@armadeus.com>
> Sent: Friday, July 1, 2016 10:18:04 AM
> Subject: Re: [Buildroot] Unable to compile uboot v2012.10 on Buildroot 2016.05

> Hello,
> 
> On Fri, 1 Jul 2016 10:10:48 -0300 (BRT), Carlos Santos wrote:
> 
>> /usr/bin/make -C tools all
>> gcc -O2 -I/work/bcm95615x/host/usr/include   -o img2srec.o img2srec.c -c
>> In file included from img2srec.c:55:0:
>> os_support.h:22:22: fatal error: compiler.h: No such file or directory
> 
> What is your host gcc version ? This failure smells like building an
> old U-Boot, with gcc 5.x as the host gcc version.

The problem happens on CentOS 7 (GCC 4.8.3) and Ubuntu 16.04 (GCC 5.3.1).

>> diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk
>> index a2274ee..5d171dd 100644
>> --- a/boot/uboot/uboot.mk
>> +++ b/boot/uboot/uboot.mk
>> @@ -92,9 +92,7 @@ endif
>>  
>>  UBOOT_MAKE_OPTS += \
>>  	CROSS_COMPILE="$(TARGET_CROSS)" \
>> -	ARCH=$(UBOOT_ARCH) \
>> -	HOSTCFLAGS="$(HOST_CFLAGS)" \
>> -	HOSTLDFLAGS="$(HOST_LDFLAGS)"
> 
> I'm not sure to see why this would fix the problem you're reporting.

It prevents overriding HOSTCFLAGS and HOSTLDFLAGS on targets that don't need OpenSSL, so older versions of U-Boot will compile successfully.

Carlos Santos (Casantos)
DATACOM, P&D
Thomas Petazzoni July 1, 2016, 2:15 p.m. UTC | #3
Hello,

On Fri, 1 Jul 2016 11:00:57 -0300 (BRT), Carlos Santos wrote:

> > What is your host gcc version ? This failure smells like building an
> > old U-Boot, with gcc 5.x as the host gcc version.  
> 
> The problem happens on CentOS 7 (GCC 4.8.3) and Ubuntu 16.04 (GCC 5.3.1).

I think the failure with GCC 5.3.x is normal, but I don't understand
why it would fail with gcc 4.8.

> >>  UBOOT_MAKE_OPTS += \
> >>  	CROSS_COMPILE="$(TARGET_CROSS)" \
> >> -	ARCH=$(UBOOT_ARCH) \
> >> -	HOSTCFLAGS="$(HOST_CFLAGS)" \
> >> -	HOSTLDFLAGS="$(HOST_LDFLAGS)"  
> > 
> > I'm not sure to see why this would fix the problem you're reporting.  
> 
> It prevents overriding HOSTCFLAGS and HOSTLDFLAGS on targets that don't need OpenSSL, so older versions of U-Boot will compile successfully.

Yes, but I don't understand why not setting HOSTCFLAGS/HOSTLDFLAGS
fixes the build issue you mentioned.

Thomas
Carlos Santos July 1, 2016, 3:28 p.m. UTC | #4
> From: "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>
> To: "Carlos Santos" <casantos@datacom.ind.br>
> Cc: "buildroot" <buildroot@buildroot.org>, "Julien Boibessot" <julien.boibessot@armadeus.com>
> Sent: Friday, July 1, 2016 11:15:56 AM
> Subject: Re: [Buildroot] Unable to compile uboot v2012.10 on Buildroot 2016.05

> Hello,
> 
> On Fri, 1 Jul 2016 11:00:57 -0300 (BRT), Carlos Santos wrote:
> 
>> > What is your host gcc version ? This failure smells like building an
>> > old U-Boot, with gcc 5.x as the host gcc version.
>> 
>> The problem happens on CentOS 7 (GCC 4.8.3) and Ubuntu 16.04 (GCC 5.3.1).
> 
> I think the failure with GCC 5.3.x is normal, but I don't understand
> why it would fail with gcc 4.8.
> 
>> >>  UBOOT_MAKE_OPTS += \
>> >>  	CROSS_COMPILE="$(TARGET_CROSS)" \
>> >> -	ARCH=$(UBOOT_ARCH) \
>> >> -	HOSTCFLAGS="$(HOST_CFLAGS)" \
>> >> -	HOSTLDFLAGS="$(HOST_LDFLAGS)"
>> > 
>> > I'm not sure to see why this would fix the problem you're reporting.
>> 
>> It prevents overriding HOSTCFLAGS and HOSTLDFLAGS on targets that don't need
>> OpenSSL, so older versions of U-Boot will compile successfully.
> 
> Yes, but I don't understand why not setting HOSTCFLAGS/HOSTLDFLAGS
> fixes the build issue you mentioned.
> 

Without setting HOSTCFLAGS/HOSTLDFLAGS the command line is this

gcc -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -idirafter /work/bcm95615x/build/uboot-2012.10/include -idirafter /work/bcm95615x/build/uboot-2012.10/include2 -idirafter /work/bcm95615x/build/uboot-2012.10/include -I /work/bcm95615x/build/uboot-2012.10/lib/libfdt -I /work/bcm95615x/build/uboot-2012.10/tools -DCONFIG_SYS_TEXT_BASE=0x80800000 -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES -pedantic   -o img2srec.o img2srec.c -c

Setting HOSTCFLAGS/HOSTLDFLAGS the command line becomes

gcc -O2 -I/work/bcm95615x/host/usr/include   -o img2srec.o img2srec.c -c

Because the value of HOSTCFLAGS set in U-Boot's config.mk is overwritten. 

Carlos Santos (Casantos)
DATACOM, P&D
Stephen Agate July 1, 2016, 4:22 p.m. UTC | #5
Carlos,

You are probably missing "include/linux/compiler-gcc5.h".

This one may work for you:

https://github.com/altera-opensource/u-boot-socfpga
/commit/d3c9a256d6445129d01d1ea779d2587523190427

S.
Arnout Vandecappelle July 2, 2016, 10:47 a.m. UTC | #6
On 01-07-16 17:28, Carlos Santos wrote:
>> From: "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>
>> To: "Carlos Santos" <casantos@datacom.ind.br>
>> Cc: "buildroot" <buildroot@buildroot.org>, "Julien Boibessot" <julien.boibessot@armadeus.com>
>> Sent: Friday, July 1, 2016 11:15:56 AM
>> Subject: Re: [Buildroot] Unable to compile uboot v2012.10 on Buildroot 2016.05
> 
>> Hello,
>>
>> On Fri, 1 Jul 2016 11:00:57 -0300 (BRT), Carlos Santos wrote:
>>
>>>> What is your host gcc version ? This failure smells like building an
>>>> old U-Boot, with gcc 5.x as the host gcc version.
>>>
>>> The problem happens on CentOS 7 (GCC 4.8.3) and Ubuntu 16.04 (GCC 5.3.1).
>>
>> I think the failure with GCC 5.3.x is normal, but I don't understand
>> why it would fail with gcc 4.8.
>>
>>>>>  UBOOT_MAKE_OPTS += \
>>>>>  	CROSS_COMPILE="$(TARGET_CROSS)" \
>>>>> -	ARCH=$(UBOOT_ARCH) \
>>>>> -	HOSTCFLAGS="$(HOST_CFLAGS)" \
>>>>> -	HOSTLDFLAGS="$(HOST_LDFLAGS)"
>>>>
>>>> I'm not sure to see why this would fix the problem you're reporting.
>>>
>>> It prevents overriding HOSTCFLAGS and HOSTLDFLAGS on targets that don't need
>>> OpenSSL, so older versions of U-Boot will compile successfully.
>>
>> Yes, but I don't understand why not setting HOSTCFLAGS/HOSTLDFLAGS
>> fixes the build issue you mentioned.
>>
> 
> Without setting HOSTCFLAGS/HOSTLDFLAGS the command line is this
> 
> gcc -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -idirafter /work/bcm95615x/build/uboot-2012.10/include -idirafter /work/bcm95615x/build/uboot-2012.10/include2 -idirafter /work/bcm95615x/build/uboot-2012.10/include -I /work/bcm95615x/build/uboot-2012.10/lib/libfdt -I /work/bcm95615x/build/uboot-2012.10/tools -DCONFIG_SYS_TEXT_BASE=0x80800000 -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES -pedantic   -o img2srec.o img2srec.c -c
> 
> Setting HOSTCFLAGS/HOSTLDFLAGS the command line becomes
> 
> gcc -O2 -I/work/bcm95615x/host/usr/include   -o img2srec.o img2srec.c -c
> 
> Because the value of HOSTCFLAGS set in U-Boot's config.mk is overwritten. 

 How about leaving HOSTCFLAGS alone, and instead setting
HOSTCC="$(HOSTCC) $(HOST_CFLAGS)". HOSTLDFLAGS can probably be overridden.

 Regards,
 Arnout
Thomas Petazzoni July 2, 2016, 10:56 a.m. UTC | #7
Hello,

On Sat, 2 Jul 2016 12:47:14 +0200, Arnout Vandecappelle wrote:

> > Because the value of HOSTCFLAGS set in U-Boot's config.mk is overwritten.   
> 
>  How about leaving HOSTCFLAGS alone, and instead setting
> HOSTCC="$(HOSTCC) $(HOST_CFLAGS)". HOSTLDFLAGS can probably be overridden.

Good point, that's possibly an alternate solution. I sent a patch
implementing a different solution, but Carlos, if you can try Arnout's
suggestion, it would be good.

Thanks,

Thomas
Carlos Santos July 3, 2016, 4:15 p.m. UTC | #8
> From: "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>
> To: "Arnout Vandecappelle" <arnout@mind.be>
> Cc: "Carlos Santos" <casantos@datacom.ind.br>, "Julien Boibessot" <julien.boibessot@armadeus.com>, "buildroot"
> <buildroot@buildroot.org>
> Sent: Saturday, July 2, 2016 7:56:25 AM
> Subject: Re: [Buildroot] Unable to compile uboot v2012.10 on Buildroot 2016.05

> Hello,
> 
> On Sat, 2 Jul 2016 12:47:14 +0200, Arnout Vandecappelle wrote:
> 
>> > Because the value of HOSTCFLAGS set in U-Boot's config.mk is overwritten.
>> 
>>  How about leaving HOSTCFLAGS alone, and instead setting
>> HOSTCC="$(HOSTCC) $(HOST_CFLAGS)". HOSTLDFLAGS can probably be overridden.
> 
> Good point, that's possibly an alternate solution. I sent a patch
> implementing a different solution, but Carlos, if you can try Arnout's
> suggestion, it would be good.

Yes, it works, but this reminds me that HOSTCC is not passed when building buildroot, so the command line for version 2015.01 becomes

cc -Wp,-MD,tools/.img2srec.d -O2 -I/work/freescale_imx28evk/host/usr/include   -include ./include/libfdt_env.h -idirafterinclude -idirafter./arch/arm/include -I./lib/libfdt -I./tools -DCONFIG_SYS_TEXT_BASE=0x40002000 -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES -D_GNU_SOURCE -pedantic -o tools/img2srec tools/img2srec.c

This may not be a problem now but I believe that HOSTCC should always be provided.

Carlos Santos (Casantos)
DATACOM, P&D
Arnout Vandecappelle July 4, 2016, 9:26 a.m. UTC | #9
Hi Carlos,

On 03-07-16 18:15, Carlos Santos wrote:
>> From: "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>
>> To: "Arnout Vandecappelle" <arnout@mind.be>
>> Cc: "Carlos Santos" <casantos@datacom.ind.br>, "Julien Boibessot" <julien.boibessot@armadeus.com>, "buildroot"
>> <buildroot@buildroot.org>
>> Sent: Saturday, July 2, 2016 7:56:25 AM
>> Subject: Re: [Buildroot] Unable to compile uboot v2012.10 on Buildroot 2016.05
> 
>> Hello,
>>
>> On Sat, 2 Jul 2016 12:47:14 +0200, Arnout Vandecappelle wrote:
>>
>>>> Because the value of HOSTCFLAGS set in U-Boot's config.mk is overwritten.
>>>
>>>  How about leaving HOSTCFLAGS alone, and instead setting
>>> HOSTCC="$(HOSTCC) $(HOST_CFLAGS)". HOSTLDFLAGS can probably be overridden.
>>
>> Good point, that's possibly an alternate solution. I sent a patch
>> implementing a different solution, but Carlos, if you can try Arnout's
>> suggestion, it would be good.
> 
> Yes, it works, but this reminds me that HOSTCC is not passed when building buildroot, so the command line for version 2015.01 becomes
> 
> cc -Wp,-MD,tools/.img2srec.d -O2 -I/work/freescale_imx28evk/host/usr/include   -include ./include/libfdt_env.h -idirafterinclude -idirafter./arch/arm/include -I./lib/libfdt -I./tools -DCONFIG_SYS_TEXT_BASE=0x40002000 -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES -D_GNU_SOURCE -pedantic -o tools/img2srec tools/img2srec.c
> 
> This may not be a problem now but I believe that HOSTCC should always be provided.

 Care to prepare a patch then that replaces HOSTCFLAGS by HOSTCC?

 Regards,
 Arnout
Carlos Santos July 4, 2016, 11:15 a.m. UTC | #10
> From: "Arnout Vandecappelle" <arnout@mind.be>
> To: "Carlos Santos" <casantos@datacom.ind.br>, "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>
> Cc: "Julien Boibessot" <julien.boibessot@armadeus.com>, "buildroot" <buildroot@buildroot.org>
> Sent: Monday, July 4, 2016 6:26:09 AM
> Subject: Re: [Buildroot] Unable to compile uboot v2012.10 on Buildroot 2016.05

> Hi Carlos,
> 
> On 03-07-16 18:15, Carlos Santos wrote:
>>> From: "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>
>>> To: "Arnout Vandecappelle" <arnout@mind.be>
>>> Cc: "Carlos Santos" <casantos@datacom.ind.br>, "Julien Boibessot"
>>> <julien.boibessot@armadeus.com>, "buildroot"
>>> <buildroot@buildroot.org>
>>> Sent: Saturday, July 2, 2016 7:56:25 AM
>>> Subject: Re: [Buildroot] Unable to compile uboot v2012.10 on Buildroot 2016.05
>> 
>>> Hello,
>>>
>>> On Sat, 2 Jul 2016 12:47:14 +0200, Arnout Vandecappelle wrote:
>>>
>>>>> Because the value of HOSTCFLAGS set in U-Boot's config.mk is overwritten.
>>>>
>>>>  How about leaving HOSTCFLAGS alone, and instead setting
>>>> HOSTCC="$(HOSTCC) $(HOST_CFLAGS)". HOSTLDFLAGS can probably be overridden.
>>>
>>> Good point, that's possibly an alternate solution. I sent a patch
>>> implementing a different solution, but Carlos, if you can try Arnout's
>>> suggestion, it would be good.
>> 
>> Yes, it works, but this reminds me that HOSTCC is not passed when building
>> buildroot, so the command line for version 2015.01 becomes
>> 
>> cc -Wp,-MD,tools/.img2srec.d -O2 -I/work/freescale_imx28evk/host/usr/include
>> -include ./include/libfdt_env.h -idirafterinclude
>> -idirafter./arch/arm/include -I./lib/libfdt -I./tools
>> -DCONFIG_SYS_TEXT_BASE=0x40002000 -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES
>> -D_GNU_SOURCE -pedantic -o tools/img2srec tools/img2srec.c
>> 
>> This may not be a problem now but I believe that HOSTCC should always be
>> provided.
> 
> Care to prepare a patch then that replaces HOSTCFLAGS by HOSTCC?
> 

Thomas already submitted a patch: http://patchwork.ozlabs.org/patch/643426/

Carlos Santos (Casantos)
DATACOM, P&D
Arnout Vandecappelle July 5, 2016, 9:10 a.m. UTC | #11
On 04-07-16 13:15, Carlos Santos wrote:
>> From: "Arnout Vandecappelle" <arnout@mind.be>
>> To: "Carlos Santos" <casantos@datacom.ind.br>, "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>
>> Cc: "Julien Boibessot" <julien.boibessot@armadeus.com>, "buildroot" <buildroot@buildroot.org>
>> Sent: Monday, July 4, 2016 6:26:09 AM
>> Subject: Re: [Buildroot] Unable to compile uboot v2012.10 on Buildroot 2016.05
> 
>> Hi Carlos,
>>
>> On 03-07-16 18:15, Carlos Santos wrote:
>>>> From: "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com>
>>>> To: "Arnout Vandecappelle" <arnout@mind.be>
>>>> Cc: "Carlos Santos" <casantos@datacom.ind.br>, "Julien Boibessot"
>>>> <julien.boibessot@armadeus.com>, "buildroot"
>>>> <buildroot@buildroot.org>
>>>> Sent: Saturday, July 2, 2016 7:56:25 AM
>>>> Subject: Re: [Buildroot] Unable to compile uboot v2012.10 on Buildroot 2016.05
>>>
>>>> Hello,
>>>>
>>>> On Sat, 2 Jul 2016 12:47:14 +0200, Arnout Vandecappelle wrote:
>>>>
>>>>>> Because the value of HOSTCFLAGS set in U-Boot's config.mk is overwritten.
>>>>>
>>>>>  How about leaving HOSTCFLAGS alone, and instead setting
>>>>> HOSTCC="$(HOSTCC) $(HOST_CFLAGS)". HOSTLDFLAGS can probably be overridden.
>>>>
>>>> Good point, that's possibly an alternate solution. I sent a patch
>>>> implementing a different solution, but Carlos, if you can try Arnout's
>>>> suggestion, it would be good.
>>>
>>> Yes, it works, but this reminds me that HOSTCC is not passed when building
>>> buildroot, so the command line for version 2015.01 becomes
>>>
>>> cc -Wp,-MD,tools/.img2srec.d -O2 -I/work/freescale_imx28evk/host/usr/include
>>> -include ./include/libfdt_env.h -idirafterinclude
>>> -idirafter./arch/arm/include -I./lib/libfdt -I./tools
>>> -DCONFIG_SYS_TEXT_BASE=0x40002000 -DUSE_HOSTCC -D__KERNEL_STRICT_NAMES
>>> -D_GNU_SOURCE -pedantic -o tools/img2srec tools/img2srec.c
>>>
>>> This may not be a problem now but I believe that HOSTCC should always be
>>> provided.
>>
>> Care to prepare a patch then that replaces HOSTCFLAGS by HOSTCC?
>>
> 
> Thomas already submitted a patch: http://patchwork.ozlabs.org/patch/643426/

 Yes, but Thomas's patch still sets HOSTCFLAGS. My question was: do you care to
submit an alternative (better) patch that sets HOSTCC (unconditionally) rather
than changing HOSTCFLAGS?

 Regards,
 Arnout
diff mbox

Patch

diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk
index a2274ee..5d171dd 100644
--- a/boot/uboot/uboot.mk
+++ b/boot/uboot/uboot.mk
@@ -92,9 +92,7 @@  endif
 
 UBOOT_MAKE_OPTS += \
 	CROSS_COMPILE="$(TARGET_CROSS)" \
-	ARCH=$(UBOOT_ARCH) \
-	HOSTCFLAGS="$(HOST_CFLAGS)" \
-	HOSTLDFLAGS="$(HOST_LDFLAGS)"
+	ARCH=$(UBOOT_ARCH)
 
 ifeq ($(BR2_TARGET_UBOOT_NEEDS_DTC),y)
 UBOOT_DEPENDENCIES += host-dtc

But this breaks the build fir the i.MX2[38] targets (freescale_imx28evk). A better workaround would be something like this:

diff --git a/boot/uboot/uboot.mk b/boot/uboot/uboot.mk
index a2274ee..5b7663d 100644
--- a/boot/uboot/uboot.mk
+++ b/boot/uboot/uboot.mk
@@ -92,9 +92,15 @@  endif
 
 UBOOT_MAKE_OPTS += \
 	CROSS_COMPILE="$(TARGET_CROSS)" \
-	ARCH=$(UBOOT_ARCH) \
+	ARCH=$(UBOOT_ARCH)
+
+ifeq ($(or $(BR2_TARGET_UBOOT_FORMAT_SB),$(BR2_TARGET_UBOOT_FORMAT_SD),$(BR2_TARGET_UBOOT_FORMAT_NAND)),y)
+# Pass HOST_CFLAGS and HOST_LDFLAGS to the U-Boot build process so the right
+# -I/-L options will be used to find OpenSSL.
+UBOOT_MAKE_OPTS += \
 	HOSTCFLAGS="$(HOST_CFLAGS)" \
 	HOSTLDFLAGS="$(HOST_LDFLAGS)"
+endif
 
 ifeq ($(BR2_TARGET_UBOOT_NEEDS_DTC),y)
 UBOOT_DEPENDENCIES += host-dtc