Build firmware as freestanding
cover Build firmware as freestanding
This fixes a bug we've had for ages, which even ended up being documented as an inappropriate build dependency.
For 4.15. I'm tempted to suggest that it wants backporting to the stable branches as well.
Andrew Cooper (3):
tools/hvmloader: Drop machelf include as well tools/firmware: Build firmware as -ffreestanding
automation: Annotate that a 32bit libc is no longer a dependency
.travis.yml | 1 - README | 3 --- automation/build/archlinux/current.dockerfile | 1 + automation/build/centos/7.2.dockerfile | 1 + automation/build/centos/7.dockerfile | 1 + automation/build/debian/jessie.dockerfile | 1 + automation/build/debian/stretch.dockerfile | 1 + automation/build/debian/unstable.dockerfile | 1 + automation/build/fedora/29.dockerfile | 1 + automation/build/suse/opensuse-leap.dockerfile | 1 + automation/build/suse/opensuse-tumbleweed.dockerfile | 1 + automation/build/ubuntu/bionic.dockerfile | 1 + automation/build/ubuntu/focal.dockerfile | 1 + automation/build/ubuntu/trusty.dockerfile | 1 + automation/build/ubuntu/xenial.dockerfile | 1 + tools/firmware/Rules.mk | 2 +- tools/firmware/hvmloader/32bitbios_support.c | 5 +---- 17 files changed, 15 insertions(+), 9 deletions(-)
Signature · 1 line
2.11.0
PATCH 1/3 tools/hvmloader: Drop machelf include as well
The logic behind switching to elfstructs applies to sun builds as well.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Ian Jackson <[email protected]>
--- tools/firmware/hvmloader/32bitbios_support.c | 3 --- 1 file changed, 3 deletions(-)
tools/firmware/hvmloader/32bitbios_support.c +0 -3
@@ -22,9 +22,6 @@#include <inttypes.h> #include <xen/libelf/elfstructs.h> -#ifdef __sun__ -#include <sys/machelf.h> -#endif #include "util.h" #include "config.h"
Signature · 1 line
2.11.0
Re: [PATCH 1/3] tools/hvmloader: Drop machelf include as well
Quoted 4 lines · Andrew Cooper
The logic behind switching to elfstructs applies to sun builds as well.
Fixes 81b2b328a2 ("hvmloader: use Xen private header for elf structs")Signed-off-by Andrew Cooper <[email protected]>
Re: [PATCH 1/3] tools/hvmloader: Drop machelf include as well
In reply to Andrew CooperAndrew Cooper writes ("[PATCH 1/3] tools/hvmloader: Drop machelf include as well"):
Quoted 4 lines
The logic behind switching to elfstructs applies to sun builds as well.
Fixes 81b2b328a2 ("hvmloader: use Xen private header for elf structs")Signed-off-by Andrew Cooper <[email protected]>
I would have preferred this patch to come after the one that is actually justified for 4.15, so that it could be held off to after 4.15. After all I see no substantive reason why this should get a freeze exception.
However, it looks fine based on code review and I don't want to add risk by asking you to transpose the two patches, so:
Ian.
Re: [PATCH 1/3] tools/hvmloader: Drop machelf include as well
Quoted 9 lines · Ian Jackson
Andrew Cooper writes ("[PATCH 1/3]
tools/hvmloader: Drop machelf include as well"):Quoted 4 lines
The logic behind switching to elfstructs applies to sun builds as well.
Fixes 81b2b328a2 ("hvmloader: use Xen private header for elf structs")Signed-off-by Andrew Cooper <[email protected]>I would have preferred this patch to come after the one that is actually justified for 4.15, so that it could be held off to after 4.15. After all I see no substantive reason why this should get a freeze exception.
It is a bugfix to a very recent patch which already already got a release ack.
If this doesn't get an ack, then 81b2b328a2 should be reverted. (Except obviously that would be a bad move.)
Quoted 5 lines
However, it looks fine based on code review and I don't want to add risk by asking you to transpose the two patches, so:
Release-Acked-by Ian Jackson <[email protected]>
Thanks.
~Andrew
PATCH 2/3 tools/firmware: Build firmware as -ffreestanding
In reply to Andrew Cooperfirmware should always have been -ffreestanding, as it doesn't execute in the host environment.
inttypes.h isn't a freestanding header, but the 32bitbios_support.c only wants the stdint.h types so switch to the more appropriate include.
This removes the build time dependency on a 32bit libc just to compile the hvmloader and friends.
Update README and the TravisCI configuration.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Ian Jackson <[email protected]>
For 4.15. Build tested in Travis (Ubuntu) and XenServer (CentOS) - no change in the compiled HVMLoader binary. I'm currently rebuilding the containers locally to check Arch, Debian and OpenSUSE, but don't anticipate any problems.
This does not resolve the build issue on Alpine. Exactly what to do there is still TBC, but Roger has opened a bug with Apline concerning their GCC packaging.
--- .travis.yml | 1 - README | 3 --- tools/firmware/Rules.mk | 2 +- tools/firmware/hvmloader/32bitbios_support.c | 2 +- 4 files changed, 2 insertions(+), 6 deletions(-)
.travis.yml +0 -1
@@ -58,7 +58,6 @@ addons: - acpica-tools - bin86 - bcc - - libc6-dev-i386 - libnl-3-dev - ocaml-nox - libfindlib-ocaml-dev
README +0 -3
@@ -62,9 +62,6 @@ provided by your OS distributor: * GNU bison and GNU flex * GNU gettext * ACPI ASL compiler (iasl) - * Libc multiarch package (e.g. libc6-dev-i386 / glibc-devel.i686). - Required when building on a 64-bit platform to build - 32-bit components which are enabled on a default build. In addition to the above there are a number of optional build prerequisites. Omitting these will cause the related features to be
tools/firmware/Rules.mk +1 -1
@@ -16,4 +16,4 @@ CFLAGS += -Werror $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS)) # Extra CFLAGS suitable for an embedded type of environment. -CFLAGS += -fno-builtin -msoft-float +CFLAGS += -fno-builtin -msoft-float -ffreestanding
tools/firmware/hvmloader/32bitbios_support.c +1 -1
@@ -20,7 +20,7 @@* this program; If not, see <http://www.gnu.org/licenses/>. */ -#include <inttypes.h> +#include <stdint.h> #include <xen/libelf/elfstructs.h> #include "util.h"
Signature · 1 line
2.11.0
Re: [PATCH 2/3] tools/firmware: Build firmware as -ffreestanding
Quoted 6 lines · Andrew Cooper
firmware should always have been -ffreestanding, as it doesn't execute in the host environment.
inttypes.hisn't a freestanding header, but the32bitbios_support.conly wants thestdint.htypes so switch to the more appropriate include.
Quoted 6 lines
This removes the build time dependency on a 32bit libc just to compile the hvmloader and friends.
Update README and the TravisCI configuration.
Signed-off-by Andrew Cooper <[email protected]>
preferably with one further adjustment:
tools/firmware/Rules.mk CFLAGS += -Werror · line 19
Quoted 8 lines
tools/firmware/Rules.mk +1
-1@@ -16,4 +16,4 @@ CFLAGS += -Werror $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS)) # Extra CFLAGS suitable for an embedded type of environment. -CFLAGS += -fno-builtin -msoft-float +CFLAGS += -fno-builtin -msoft-float -ffreestanding
As per gcc doc -ffreestanding implies -fno-builtin, so I think you want to replace that one instead of adding the new option on top.
Jan
Re: [PATCH 2/3] tools/firmware: Build firmware as -ffreestanding
Quoted 21 lines · Jan Beulich
Quoted 6 lines · Andrew Cooper
firmware should always have been -ffreestanding, as it doesn't execute in the host environment.
inttypes.hisn't a freestanding header, but the32bitbios_support.conly wants thestdint.htypes so switch to the more appropriate include.Quoted 6 lines
This removes the build time dependency on a 32bit libc just to compile the hvmloader and friends.
Update README and the TravisCI configuration.
Signed-off-by Andrew Cooper <[email protected]>Reviewed-by Jan Beulich <[email protected]>preferably with one further adjustment:
Quoted 5 lines
tools/firmware/Rules.mk +0
-0@@ -16,4 +16,4 @@ CFLAGS += -Werror $(call cc-options-add,CFLAGS,CC,$(EMBEDDED_EXTRA_CFLAGS))
Quoted 5 lines
tools/firmware/Rules.mk CFLAGS += -Werror · line 19
Quoted 3 lines
tools/firmware/Rules.mk +1
-1# Extra CFLAGS suitable for an embedded type of environment. -CFLAGS += -fno-builtin -msoft-float +CFLAGS += -fno-builtin -msoft-float -ffreestandingAs per gcc doc -ffreestanding implies -fno-builtin, so I think you want to replace that one instead of adding the new option on top.
Oops yes - fixed.
Thanks.
~Andrew
PATCH 2/3 tools/firmware: Build firmware as -ffreestanding
In reply to Andrew CooperAndrew Cooper writes ("[PATCH 2/3] tools/firmware: Build firmware as -ffreestanding"):
Quoted 6 lines
firmware should always have been -ffreestanding, as it doesn't execute in the host environment.
inttypes.hisn't a freestanding header, but the32bitbios_support.conly wants thestdint.htypes so switch to the more appropriate include.
Quoted 8 lines
This removes the build time dependency on a 32bit libc just to compile the hvmloader and friends.
Update README and the TravisCI configuration.
For 4.15. Build tested in Travis (Ubuntu) and XenServer (CentOS) - no change in the compiled HVMLoader binary. I'm currently rebuilding the containers locally to check Arch, Debian and OpenSUSE, but don't anticipate any problems.
PATCH 3/3 automation: Annotate that a 32bit libc is no longer a dependency
In reply to Andrew CooperWe can't drop the 32bit libc from the existing containers, because they are used on older Xen branches as well.
However, we can avoid the dependency being propagated into newer conainers derived from our dockerfiles.
No functional change.
---
CC: Doug Goldstein <[email protected]>
CC: Wei Liu <[email protected]>
CC: Ian Jackson <[email protected]>
For 4.15. Documentation changes only
--- automation/build/archlinux/current.dockerfile | 1 + automation/build/centos/7.2.dockerfile | 1 + automation/build/centos/7.dockerfile | 1 + automation/build/debian/jessie.dockerfile | 1 + automation/build/debian/stretch.dockerfile | 1 + automation/build/debian/unstable.dockerfile | 1 + automation/build/fedora/29.dockerfile | 1 + automation/build/suse/opensuse-leap.dockerfile | 1 + automation/build/suse/opensuse-tumbleweed.dockerfile | 1 + automation/build/ubuntu/bionic.dockerfile | 1 + automation/build/ubuntu/focal.dockerfile | 1 + automation/build/ubuntu/trusty.dockerfile | 1 + automation/build/ubuntu/xenial.dockerfile | 1 + 13 files changed, 13 insertions(+)
automation/build/archlinux/current.dockerfile +1 -0
@@ -20,6 +20,7 @@ RUN pacman -S --refresh --sysupgrade --noconfirm --noprogressbar --needed \ iasl \ inetutils \ iproute \ + # lib32-glibc for Xen < 4.15 lib32-glibc \ libaio \ libcacard \
automation/build/centos/7.2.dockerfile +1 -0
@@ -34,6 +34,7 @@ RUN rpm --rebuilddb && \ yajl-devel \ pixman-devel \ glibc-devel \ + # glibc-devel.i686 for Xen < 4.15 glibc-devel.i686 \ make \ binutils \
automation/build/centos/7.dockerfile +1 -0
@@ -32,6 +32,7 @@ RUN yum -y install \ yajl-devel \ pixman-devel \ glibc-devel \ + # glibc-devel.i686 for Xen < 4.15 glibc-devel.i686 \ make \ binutils \
automation/build/debian/jessie.dockerfile +1 -0
@@ -31,6 +31,7 @@ RUN apt-get update && \ bin86 \ bcc \ liblzma-dev \ + # libc6-dev-i386 for Xen < 4.15 libc6-dev-i386 \ libnl-3-dev \ ocaml-nox \
automation/build/debian/stretch.dockerfile +1 -0
@@ -32,6 +32,7 @@ RUN apt-get update && \ bin86 \ bcc \ liblzma-dev \ + # libc6-dev-i386 for Xen < 4.15 libc6-dev-i386 \ libnl-3-dev \ ocaml-nox \
automation/build/debian/unstable.dockerfile +1 -0
@@ -32,6 +32,7 @@ RUN apt-get update && \ bin86 \ bcc \ liblzma-dev \ + # libc6-dev-i386 for Xen < 4.15 libc6-dev-i386 \ libnl-3-dev \ ocaml-nox \
automation/build/fedora/29.dockerfile +1 -0
@@ -25,6 +25,7 @@ RUN dnf -y install \ yajl-devel \ pixman-devel \ glibc-devel \ + # glibc-devel.i686 for Xen < 4.15 glibc-devel.i686 \ make \ binutils \
automation/build/suse/opensuse-leap.dockerfile +1 -0
@@ -26,6 +26,7 @@ RUN zypper install -y --no-recommends \ git \ glib2-devel \ glibc-devel \ + # glibc-devel-32bit for Xen < 4.15 glibc-devel-32bit \ gzip \ hostname \
automation/build/suse/opensuse-tumbleweed.dockerfile +1 -0
@@ -26,6 +26,7 @@ RUN zypper install -y --no-recommends \ git \ glib2-devel \ glibc-devel \ + # glibc-devel-32bit for Xen < 4.15 glibc-devel-32bit \ gzip \ hostname \
automation/build/ubuntu/bionic.dockerfile +1 -0
@@ -32,6 +32,7 @@ RUN apt-get update && \ bin86 \ bcc \ liblzma-dev \ + # libc6-dev-i386 for Xen < 4.15 libc6-dev-i386 \ libnl-3-dev \ ocaml-nox \
automation/build/ubuntu/focal.dockerfile +1 -0
@@ -31,6 +31,7 @@ RUN apt-get update && \ bin86 \ bcc \ liblzma-dev \ + # libc6-dev-i386 for Xen < 4.15 libc6-dev-i386 \ libnl-3-dev \ ocaml-nox \
automation/build/ubuntu/trusty.dockerfile +1 -0
@@ -32,6 +32,7 @@ RUN apt-get update && \ bin86 \ bcc \ liblzma-dev \ + # libc6-dev-i386 for Xen < 4.15 libc6-dev-i386 \ libnl-3-dev \ ocaml-nox \
automation/build/ubuntu/xenial.dockerfile +1 -0
@@ -32,6 +32,7 @@ RUN apt-get update && \ bin86 \ bcc \ liblzma-dev \ + # libc6-dev-i386 for Xen < 4.15 libc6-dev-i386 \ libnl-3-dev \ ocaml-nox \
Signature · 1 line
2.11.0
Re: [PATCH 3/3] automation: Annotate that a 32bit libc is no longer a dependency
Andrew Cooper writes ("[PATCH 3/3] automation: Annotate that a 32bit libc is no longer a dependency"):
Quoted 8 lines
We can't drop the 32bit libc from the existing containers, because they are used on older Xen branches as well.
However, we can avoid the dependency being propagated into newer conainers derived from our dockerfiles.
No functional change.
Quoted 7 lines
Signed-off-by Andrew Cooper <[email protected]>---
CC: Doug Goldstein <[email protected]>
CC: Wei Liu <[email protected]>
CC: Ian Jackson <[email protected]>For 4.15. Documentation changes only