Error when trying to build u-boot for Raspberry Pi on Ubuntu 20.04 (scarthgap)

I get the following error message when trying to build u-boot on scarthgap:

| gcc: error: unrecognized command line option ‘-fcanon-prefix-map’; did you mean ‘-fmacro-prefix-map=’?
| make: *** [Makefile:1817: include/generated/env.in] Error 1

This is because the host compiler version on this Ubuntu version is 9.4 where this option isn’t supported.

The error stems from the following code in the Makefile in the root of the u-boot source directory:

quiet_cmd_gen_envp = ENVP $@
cmd_gen_envp =
if [ -s “$(ENV_FILE)” ]; then
$(CPP) -P $(CFLAGS) -x assembler-with-cpp -D__ASSEMBLY__
-D__UBOOT_CONFIG__
-I . -I include -I $(srctree)/include
-include linux/kconfig.h -include include/config.h
-I$(srctree)/arch/$(ARCH)/include
$< -o $@;
else
rm -f $@;
touch $@ ;
fi
include/generated/env.in: include/generated/env.txt
$(call cmd,gen_envp)

A workaround would be to add the following line to u-boot-mender.inc in line 332:

    CFLAGS="${BUILD_CFLAGS}" \
    BUILDCC="${BUILD_CC}" \
    CROSS_COMPILE="${TARGET_PREFIX}" \

But I’m not sure if this this is correct. Honestly I don’t understand which steps need the host compiler toolchain and which steps should be using the cross compiler toolchain. Perhaps this is something which should be cleaned up in u-boot?

1 Like

HI @StMartin81,

That’s definitely strange, especially as building u-boot in a Yocto context should not rely on the host toolchain. Is this an otherwise unmodified poky+meta-raspberrypi+meta-mender build like the kas files we provide (meta-mender-community/kas at scarthgap · mendersoftware/meta-mender-community · GitHub) do set up, or are there additional modifications which might affect the decoupling from the host?

Greets,
Josef

Hi Josef.

The issue is in uboot_auto_configure.sh which uses the host toolchain.

poky/meta/conf/bitbake.conf includes the offending option in DEBUG_PREFIX_MAP
poky/meta/recipes-bsp/u-boot/u-boot.inc includes DEBUG_PREFIX_MAP in EXTRA_OEMAKE.

I resolved the issue by defining an empty DEBUG_PREFIX_MAP in my u-boot recipe. poky/meta/conf/bitbake.conf only sets that variable if it isn’t already set.

Steve
2 Likes