efivar: fix build with old gcc versions
PATCH 1/1 efivar: fix build with old gcc versions
The efivar build process starts by building one tool for the host, which is needed for the rest of the build. This tool currently fails to build with old gcc versions because the gcc.specs used by efivar specifies -std=gnu11. To address this, this patch:
- passes 'gcc_flags=' to the host build, so that the custom gcc specs are not passed. They are in practice not needed for the build of the simple makeguids host utility.
- passes -std=gnu99 instead of -std=c99 in the build of host makeguids, because the source code uses anonymous structs and unions, which requires std=gnu99 and not just std=c99
In addition, the build by default assumes that the target toolchain is LTO capable, and that therefore you can call gcc-ar, gcc-nm and gcc-ranlib. This fails short when the target toolchain is for example gcc 4.7. To address this, we explicitly specify AR, NM and RANLIB to be used, but pass them as make options instead of in the environment, in order to override the values specified in the package Makefile.
Fixes:
http://autobuild.buildroot.net/results/fe40c1d139ba8ddeef3dafd5c1818a946f014d7c/
--- package/efivar/efivar.mk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
package/efivar/efivar.mk +3 -2
@@ -31,10 +31,11 @@ define EFIVAR_BUILD_CMDS # makeguids is an internal host tool and must be built separately with # $(HOST_CC), otherwise it gets cross-built. $(HOST_MAKE_ENV) $(HOST_CONFIGURE_OPTS) \ - CFLAGS="$(HOST_CFLAGS) -std=c99" \ - $(MAKE) -C $(@D)/src makeguids + CFLAGS="$(HOST_CFLAGS) -std=gnu99" \ + $(MAKE) -C $(@D)/src gcc_cflags= makeguids $(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE1) -C $(@D) \ + AR=$(TARGET_AR) NM=$(TARGET_NM) RANLIB=$(TARGET_RANLIB) \ $(EFIVAR_MAKE_OPTS) \ all endef
Signature · 1 line
2.7.4
PATCH 1/1 efivar: fix build with old gcc versions
Hello, Thomas.
Thank you for further investigating this.
package/efivar/efivar.mk define EFIVAR_BUILD_CMDS · line 35
Quoted 12 lines · Thomas Petazzoni
package/efivar/efivar.mk +2
-2@@ -31,10 +31,11 @@ define EFIVAR_BUILD_CMDS # makeguids is an internal host tool and must be built separately with # $(HOST_CC), otherwise it gets cross-built. $(HOST_MAKE_ENV) $(HOST_CONFIGURE_OPTS) \ - CFLAGS="$(HOST_CFLAGS) -std=c99" \ - $(MAKE) -C $(@D)/src makeguids + CFLAGS="$(HOST_CFLAGS) -std=gnu99" \ + $(MAKE) -C $(@D)/src gcc_cflags= makeguids
I have tested the patch and it fixes the build break even in an environment with host gcc 4.6.
I had prepared a patch adding depends on BR2_HOST_GCC_AT_LEAST_4_7 to the efivar Config.in file as an alternative solution, but I think that it would be needed to add BR2_TOOLCHAIN_GCC_AT_LEAST_4_7 as well. Didn't finish testing that as I didn't have any target gcc 4.6 toolchain at hand.
The flags -std=gnu11 , -Wmaybe-uninitialized , -flto are only present in gcc 4.7 and up and are also used by the target build. Buildroot doesn't support building its own toolchains with target gcc 4.6 anymore but it's still possible to select it when using an external toolchain. It would probably still break for that case.
If that is a problem that we don't care much now, then I can add my Tested-by on this patch. To cover all cases, the patch to add the 'depends on' on both host and target gcc 4.7 would probably also fix it.
Erico
PATCH 1/1 efivar: fix build with old gcc versions
Hello,
Quoted 17 lines · Erico Nunes
package/efivar/efivar.mk define EFIVAR_BUILD_CMDS · line 35
Quoted 12 lines · Thomas Petazzoni
package/efivar/efivar.mk +2
-2@@ -31,10 +31,11 @@ define EFIVAR_BUILD_CMDS # makeguids is an internal host tool and must be built separately with # $(HOST_CC), otherwise it gets cross-built. $(HOST_MAKE_ENV) $(HOST_CONFIGURE_OPTS) \ - CFLAGS="$(HOST_CFLAGS) -std=c99" \ - $(MAKE) -C $(@D)/src makeguids + CFLAGS="$(HOST_CFLAGS) -std=gnu99" \ + $(MAKE) -C $(@D)/src gcc_cflags= makeguidsI have tested the patch and it fixes the build break even in an environment with host gcc 4.6.
Thanks for testing. I did test it successfully on my build server that uses gcc 4.4 as the host gcc, so it's working with a host gcc even older than 4.6.
Quoted 6 lines
I had prepared a patch adding depends on
BR2_HOST_GCC_AT_LEAST_4_7to the efivar Config.in file as an alternative solution, but I think that it would be needed to addBR2_TOOLCHAIN_GCC_AT_LEAST_4_7as well. Didn't finish testing that as I didn't have any target gcc 4.6 toolchain at hand.
The flags -std=gnu11 , -Wmaybe-uninitialized , -flto are only present
Quoted 8 lines
in gcc 4.7 and up and are also used by the target build. Buildroot doesn't support building its own toolchains with target gcc 4.6 anymore but it's still possible to select it when using an external toolchain. It would probably still break for that case. If that is a problem that we don't care much now, then I can add my Tested-by on this patch. To cover all cases, the patch to add the 'depends on' on both host and target gcc 4.7 would probably also fix it.
I agree that a dependency on >= 4.7 for the target gcc should also be added. Can be done as a separate patch. Can you send such a patch?
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 1/1 efivar: fix build with old gcc versions
In reply to Thomas PetazzoniHello,
Quoted 22 lines · Thomas Petazzoni
The efivar build process starts by building one tool for the host, which is needed for the rest of the build. This tool currently fails to build with old gcc versions because the gcc.specs used by efivar specifies -std=gnu11. To address this, this patch:
- passes 'gcc_flags=' to the host build, so that the custom gcc specs are not passed. They are in practice not needed for the build of the simple makeguids host utility.
- passes -std=gnu99 instead of -std=c99 in the build of host makeguids, because the source code uses anonymous structs and unions, which requires std=gnu99 and not just std=c99
In addition, the build by default assumes that the target toolchain is LTO capable, and that therefore you can call gcc-ar, gcc-nm and gcc-ranlib. This fails short when the target toolchain is for example gcc 4.7. To address this, we explicitly specify AR, NM and RANLIB to be used, but pass them as make options instead of in the environment, in order to override the values specified in the package
Makefile.Fixes:
Quoted 7 lines
http://autobuild.buildroot.net/results/fe40c1d139ba8ddeef3dafd5c1818a946f014d7c/Cc Erico Nunes <[email protected]>Signed-off-by Thomas Petazzoni <[email protected]>--- package/efivar/efivar.mk | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
I've applied this patch, to avoid the numerous autobuilder failures. Additional fixes can be made on top of it if needed.
Thanks,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com