rhboot / efivar

Tools and libraries to work with EFI variables
GNU Lesser General Public License v2.1
241 stars 104 forks source link

Cross compile build for `armv7l` fails due to incompatible type(s) #270

Open ppenguin opened 2 months ago

ppenguin commented 2 months ago

Error log:

armv7l-unknown-linux-gnueabihf-gcc -Og  -g3 -Wall -Wextra  -Werror  -std=gnu11 -funsigned-char -fvisibility=hidden -specs=/build/source/src/include/gcc.specs -fno-merge-constants  -fPIC  -DLIBEFIVAR_VERSION=39 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -I/build/source/src/include/ -c -o esl-iter.o esl-iter.c
esl-iter.c: In function 'esl_list_iter_next_with_size_correction':
esl-iter.c:338:80: error: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'off_t' {aka 'long long int'} [-Werror=format=]
  338 |                                 warnx("correcting ESL size from %d to %jd at %lx",
      |                                                                              ~~^
      |                                                                                |
      |                                                                                long unsigned int
      |                                                                              %llx
  339 |                                       iter->esl->signature_list_size,
  340 |                                       (intmax_t)(iter->len - iter->offset), iter->offset);
      |                                                                             ~~~~~~~~~~~~
      |                                                                                 |
      |                                                                                 off_t {aka long long int}
esl-iter.c:363:82: error: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'off_t' {aka 'long long int'} [-Werror=format=]
  363 |                                 warnx("correcting ESL size from %d to %jd at 0x%lx",
      |                                                                                ~~^
      |                                                                                  |
      |                                                                                  long unsigned int
      |                                                                                %llx
  364 |                                       iter->esl->signature_list_size,
  365 |                                       (intmax_t)(iter->len - iter->offset), iter->offset);
      |                                                                             ~~~~~~~~~~~~
      |                                                                                 |
      |                                                                                 off_t {aka long long int}
esl-iter.c:396:29: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
  396 |                 iter->esl = (efi_signature_list_t *)((intptr_t)iter->buf
      |                             ^
esl-iter.c:414:74: error: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'off_t' {aka 'long long int'} [-Werror=format=]
  414 |                         warnx("correcting ESL size from %d to %jd at 0x%lx",
      |                                                                        ~~^
      |                                                                          |
      |                                                                          long unsigned int
      |                                                                        %llx
  415 |                               iter->esl->signature_list_size,
  416 |                               (intmax_t)(iter->len - iter->offset), iter->offset);
      |                                                                     ~~~~~~~~~~~~
      |                                                                         |
      |                                                                         off_t {aka long long int}
cc1: all warnings being treated as errors
make[1]: *** [/build/source/src/include/rules.mk:53: esl-iter.o] Error 1
make[1]: Leaving directory '/build/source/src'
make: *** [Makefile:17: all] Error 2
sternenseemann commented 2 months ago

This affects 32 bit systems in general, including e.g. native compilation on i686-linux.

ppenguin commented 2 months ago

This affects 32 bit systems in general, including e.g. native compilation on i686-linux.

I made a naive fix here (sorry for the auto-reformat, don't know what the original formatter was), it built fine but I didn't get to test it, because in the end it was not the last problem...

gcoremans commented 6 days ago

I'm also affected by this issue, cross-compiling an armv7l boot image on x64 using nix.

puffnfresh commented 6 days ago

@gcoremans I also hit this just two days ago, doing the same. Since your armv7l image probably won't be using EFI, you can probably safely remove it:

nixpkgs.overlays = [
  (self: super: {
    efivar = pkgs.runCommand "empty-efivar" { } "touch $out";
    efibootmgr = pkgs.runCommand "empty-efibootmgr" { } "touch $out";
  })
];

But then you'll hit many other issues, like I did.