Files
xen/tools/firmware/Rules.mk
T
Roger Pau Monné 73b13705af firmware: provide a stand alone set of headers
The current build of the firmware relies on having 32bit compatible
headers installed in order to build some of the 32bit firmware.
Usually this can be solved by using the -ffreestanding compiler option
which drops the usage of the system headers in favor of a private set
of freestanding headers provided by the compiler itself that are not
tied to libc.

However such option is broken at least in the gcc compiler provided in
Alpine Linux, as the system include path (ie: /usr/include) takes
precedence over the gcc private include path:

#include <...> search starts here:
 /usr/include
 /usr/lib/gcc/x86_64-alpine-linux-musl/10.2.1/include

And the headers in /usr/include are exclusively 64bit.

Since -ffreestanding is currently broken on at least that distro, and
for resilience against future compilers also having the option broken
provide a set of stand alone 32bit headers required for the firmware
build.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-Acked-by: Ian Jackson <iwj@xenproject.org>
2021-03-04 16:49:00 +01:00

33 lines
1.1 KiB
Makefile

# Firmware is a 32-bit target
override XEN_TARGET_ARCH = x86_32
# User-supplied CFLAGS are not useful here.
CFLAGS =
EXTRA_CFLAGS_XEN_TOOLS =
include $(XEN_ROOT)/tools/Rules.mk
ifneq ($(debug),y)
CFLAGS += -DNDEBUG
endif
CFLAGS += -Werror
$(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
# Extra CFLAGS suitable for an embedded type of environment.
CFLAGS += -ffreestanding -msoft-float
# Use our own set of stand alone headers to build firmware.
#
# Ideally using -ffreestanding should be enough, but that relies on the
# compiler having the right order for include paths (ie: compiler private
# headers before system ones) or the libc headers having proper arch-agnostic
# freestanding support. This is not the case in Alpine at least which searches
# system headers before compiler ones and has arch-specific libc headers. This
# has been reported upstream:
# https://gitlab.alpinelinux.org/alpine/aports/-/issues/12477
# In the meantime (and for resilience against broken systems) use our own set
# of headers that provide what's needed for the firmware build.
CFLAGS += -nostdinc -I$(XEN_ROOT)/tools/firmware/include