Subject: bug#51664: kexec-tools fails to build on i686-linux, breaks GTK/GNOME

From: Maxim Cournoyer <[email-masked]>
Date: Sun, 07 Nov 2021 10:32:47 -0500

Hello Guix,

This has always been the case on Guix it seems (c.f.:
https://ci.guix.gnu.org/build/64481/details); yet the upstream CI builds
it fine there, and so does an Ubuntu 20.04 VM (with GCC 10.3.0).  I've
already tested it on core-updates and it fails there too, with the same
GCC:

--8<---------------cut here---------------start------------->8---
starting phase `build'
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/kexec.o kexec/kexec.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/ifdown.o kexec/ifdown.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/kexec-elf.o kexec/kexec-elf.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/kexec-elf-exec.o kexec/kexec-elf-exec.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/kexec-elf-core.o kexec/kexec-elf-core.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/kexec-elf-rel.o kexec/kexec-elf-rel.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/kexec-elf-boot.o kexec/kexec-elf-boot.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/kexec-iomem.o kexec/kexec-iomem.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/firmware_memmap.o kexec/firmware_memmap.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/crashdump.o kexec/crashdump.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/crashdump-xen.o kexec/crashdump-xen.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/phys_arch.o kexec/phys_arch.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/lzma.o kexec/lzma.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/zlib.o kexec/zlib.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/kexec-xen.o kexec/kexec-xen.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/symbols.o kexec/symbols.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/proc_iomem.o kexec/proc_iomem.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/virt_to_phys.o kexec/virt_to_phys.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/phys_to_virt.o kexec/phys_to_virt.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/add_segment.o kexec/add_segment.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/add_buffer.o kexec/add_buffer.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/arch_reuse_initrd.o kexec/arch_reuse_initrd.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/arch/i386/kexec-x86.o kexec/arch/i386/kexec-x86.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/arch/i386/kexec-x86-common.o kexec/arch/i386/kexec-x86-common.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/arch/i386/kexec-elf-x86.o kexec/arch/i386/kexec-elf-x86.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/arch/i386/kexec-elf-rel-x86.o kexec/arch/i386/kexec-elf-rel-x86.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/arch/i386/kexec-bzImage.o kexec/arch/i386/kexec-bzImage.c
kexec/arch/i386/kexec-x86-common.c: In function ‘efi_get_acpi_rsdp’:
kexec/arch/i386/kexec-x86-common.c:425:19: warning: format ‘%lx’ expects argument of type ‘long unsigned int *’, but argument 3 has type ‘uint64_t *’ {aka ‘long long unsigned int *’} [-Wformat=]
  425 |    sscanf(s, "0x%lx", &acpi_rsdp);
      |                 ~~^   ~~~~~~~~~~
      |                   |   |
      |                   |   uint64_t * {aka long long unsigned int *}
      |                   long unsigned int *
      |                 %llx
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/arch/i386/kexec-multiboot-x86.o kexec/arch/i386/kexec-multiboot-x86.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/arch/i386/kexec-mb2-x86.o kexec/arch/i386/kexec-mb2-x86.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/arch/i386/kexec-beoboot-x86.o kexec/arch/i386/kexec-beoboot-x86.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/arch/i386/kexec-nbi.o kexec/arch/i386/kexec-nbi.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/arch/i386/x86-linux-setup.o kexec/arch/i386/x86-linux-setup.c
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/  -I./kexec/arch/i386/include  -c -MD -o kexec/arch/i386/crashdump-x86.o kexec/arch/i386/crashdump-x86.c
kexec/arch/i386/x86-linux-setup.c: In function ‘setup_linux_bootloader_parameters_high’:
kexec/arch/i386/x86-linux-setup.c:100:46: warning: right shift count >= width of type [-Wshift-count-overflow]
  100 |   real_mode->ext_ramdisk_image = initrd_base >> 32;
      |                                              ^~
kexec/arch/i386/x86-linux-setup.c:104:45: warning: right shift count >= width of type [-Wshift-count-overflow]
  104 |   real_mode->ext_ramdisk_size = initrd_size >> 32;
      |                                             ^~
kexec/arch/i386/x86-linux-setup.c:118:47: warning: right shift count >= width of type [-Wshift-count-overflow]
  118 |    real_mode->ext_cmd_line_ptr = cmd_line_ptr >> 32;
      |                                               ^~
kexec/arch/i386/x86-linux-setup.c: In function ‘setup_linux_vesafb’:
kexec/arch/i386/x86-linux-setup.c:173:44: warning: right shift count >= width of type [-Wshift-count-overflow]
  173 |   real_mode->ext_lfb_base = fix.smem_start >> 32;
      |                                            ^~
In file included from kexec/arch/i386/x86-linux-setup.c:35:
kexec/arch/i386/x86-linux-setup.c: In function ‘add_e820_map_from_mr’:
kexec/arch/i386/x86-linux-setup.c:758:13: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
  758 |   dbgprintf("%016lx-%016lx (%d)\n",
      |             ^~~~~~~~~~~~~~~~~~~~~~
  759 |     e820[i].addr,
      |     ~~~~~~~~~~~~
      |            |
      |            uint64_t {aka long long unsigned int}
kexec/arch/i386/../../kexec.h:122:19: note: in definition of macro ‘dbgprintf’
  122 |   fprintf(stderr, __VA_ARGS__); \
      |                   ^~~~~~~~~~~
kexec/arch/i386/x86-linux-setup.c:758:19: note: format string is defined here
  758 |   dbgprintf("%016lx-%016lx (%d)\n",
      |              ~~~~~^
      |                   |
      |                   long unsigned int
      |              %016llx
In file included from kexec/arch/i386/x86-linux-setup.c:35:
kexec/arch/i386/x86-linux-setup.c:758:13: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
  758 |   dbgprintf("%016lx-%016lx (%d)\n",
      |             ^~~~~~~~~~~~~~~~~~~~~~
  759 |     e820[i].addr,
  760 |     e820[i].addr + e820[i].size - 1,
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                 |
      |                                 uint64_t {aka long long unsigned int}
kexec/arch/i386/../../kexec.h:122:19: note: in definition of macro ‘dbgprintf’
  122 |   fprintf(stderr, __VA_ARGS__); \
      |                   ^~~~~~~~~~~
kexec/arch/i386/x86-linux-setup.c:758:26: note: format string is defined here
  758 |   dbgprintf("%016lx-%016lx (%d)\n",
      |                     ~~~~~^
      |                          |
      |                          long unsigned int
      |                     %016llx
kexec/arch/i386/crashdump-x86.c: In function ‘cmdline_add_efi’:
kexec/arch/i386/crashdump-x86.c:806:41: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=]
  806 |  sprintf(acpi_rsdp_buf, " acpi_rsdp=0x%lx", acpi_rsdp);
      |                                       ~~^   ~~~~~~~~~
      |                                         |   |
      |                                         |   uint64_t {aka long long unsigned int}
      |                                         long unsigned int
      |                                       %llx
gcc -fno-zero-initialized-in-bss  -Os -fno-builtin -ffreestanding -fno-zero-initialized-in-bss -fno-PIC -fno-PIE -fno-stack-protector  -I./purgatory/include -I./purgatory/arch/i386/include -I./util_lib/include -I./include -Iinclude -I/gnu/store/4vafjcwi9vlks5y67naf9gdia9l42pfz-gcc-10.3.0-lib/lib/gcc/i686-unknown-linux-gnu/10.3.0/include  -c -MD -o purgatory/purgatory.o purgatory/purgatory.c
gcc -fno-zero-initialized-in-bss  -Os -fno-builtin -ffreestanding -fno-zero-initialized-in-bss -fno-PIC -fno-PIE -fno-stack-protector  -I./purgatory/include -I./purgatory/arch/i386/include -I./util_lib/include -I./include -Iinclude -I/gnu/store/4vafjcwi9vlks5y67naf9gdia9l42pfz-gcc-10.3.0-lib/lib/gcc/i686-unknown-linux-gnu/10.3.0/include  -c -MD -o purgatory/printf.o purgatory/printf.c
gcc -fno-zero-initialized-in-bss  -Os -fno-builtin -ffreestanding -fno-zero-initialized-in-bss -fno-PIC -fno-PIE -fno-stack-protector  -I./purgatory/include -I./purgatory/arch/i386/include -I./util_lib/include -I./include -Iinclude -I/gnu/store/4vafjcwi9vlks5y67naf9gdia9l42pfz-gcc-10.3.0-lib/lib/gcc/i686-unknown-linux-gnu/10.3.0/include  -c -MD -o purgatory/string.o purgatory/string.c
gcc   -I./purgatory/include -I./purgatory/arch/i386/include -I./util_lib/include -I./include -Iinclude -I/gnu/store/4vafjcwi9vlks5y67naf9gdia9l42pfz-gcc-10.3.0-lib/lib/gcc/i686-unknown-linux-gnu/10.3.0/include  -c -MD -o purgatory/arch/i386/entry32-16.o purgatory/arch/i386/entry32-16.S
gcc   -I./purgatory/include -I./purgatory/arch/i386/include -I./util_lib/include -I./include -Iinclude -I/gnu/store/4vafjcwi9vlks5y67naf9gdia9l42pfz-gcc-10.3.0-lib/lib/gcc/i686-unknown-linux-gnu/10.3.0/include  -c -MD -o purgatory/arch/i386/entry32-16-debug.o purgatory/arch/i386/entry32-16-debug.S
gcc   -I./purgatory/include -I./purgatory/arch/i386/include -I./util_lib/include -I./include -Iinclude -I/gnu/store/4vafjcwi9vlks5y67naf9gdia9l42pfz-gcc-10.3.0-lib/lib/gcc/i686-unknown-linux-gnu/10.3.0/include  -c -MD -o purgatory/arch/i386/entry32.o purgatory/arch/i386/entry32.S
gcc   -I./purgatory/include -I./purgatory/arch/i386/include -I./util_lib/include -I./include -Iinclude -I/gnu/store/4vafjcwi9vlks5y67naf9gdia9l42pfz-gcc-10.3.0-lib/lib/gcc/i686-unknown-linux-gnu/10.3.0/include  -c -MD -o purgatory/arch/i386/setup-x86.o purgatory/arch/i386/setup-x86.S
gcc   -I./purgatory/include -I./purgatory/arch/i386/include -I./util_lib/include -I./include -Iinclude -I/gnu/store/4vafjcwi9vlks5y67naf9gdia9l42pfz-gcc-10.3.0-lib/lib/gcc/i686-unknown-linux-gnu/10.3.0/include  -c -MD -o purgatory/arch/i386/stack.o purgatory/arch/i386/stack.S
gcc   -I./purgatory/include -I./purgatory/arch/i386/include -I./util_lib/include -I./include -Iinclude -I/gnu/store/4vafjcwi9vlks5y67naf9gdia9l42pfz-gcc-10.3.0-lib/lib/gcc/i686-unknown-linux-gnu/10.3.0/include  -c -MD -o purgatory/arch/i386/compat_x86_64.o purgatory/arch/i386/compat_x86_64.S
purgatory/arch/i386/compat_x86_64.S: Assembler messages:
purgatory/arch/i386/compat_x86_64.S:27: Error: unknown pseudo-op: `.code64'
purgatory/arch/i386/compat_x86_64.S:34: Error: bad register name `%rip)'
purgatory/arch/i386/compat_x86_64.S:37: Error: bad register name `%rip)'
make: *** [Makefile:127: purgatory/arch/i386/compat_x86_64.o] Error 1
make: *** Waiting for unfinished jobs....
gcc -fno-zero-initialized-in-bss  -Os -fno-builtin -ffreestanding -fno-zero-initialized-in-bss -fno-PIC -fno-PIE -fno-stack-protector  -I./purgatory/include -I./purgatory/arch/i386/include -I./util_lib/include -I./include -Iinclude -I/gnu/store/4vafjcwi9vlks5y67naf9gdia9l42pfz-gcc-10.3.0-lib/lib/gcc/i686-unknown-linux-gnu/10.3.0/include  -c -MD -o purgatory/arch/i386/purgatory-x86.o purgatory/arch/i386/purgatory-x86.c
error: in phase 'build': uncaught exception:
%exception #<&invoke-error program: "make" arguments: ("-j" "4") exit-status: 2 term-signal: #f stop-signal: #f> 
phase `build' failed after 2.4 seconds
command "make" "-j" "4" failed with status 2
--8<---------------cut here---------------end--------------->8---

In the Ubuntu VM, the following include directive is passed to gcc:

  -I/usr/lib/gcc/x86_64-linux-gnu/10/include

while on Guix it uses:

  -I/gnu/store/4vafjcwi9vlks5y67naf9gdia9l42pfz-gcc-10.3.0-lib/lib/gcc/i686-unknown-linux-gnu/10.3.0/include;

i.e. it selects the i686 include directory of GCC instead of the x86_64
one.  That probably explains the missing .code64 and other
x86_64-related symbols in the compilation errors.

kexec-tools is a required input of elogind since at least 246.10, which
means GTK/GNOME is broken by this problem on i686
(core-updates-frozen-batched-changes).

Thanks,

Maxim