heimdal icon indicating copy to clipboard operation
heimdal copied to clipboard

Cross compilation fails

Open tp2750 opened this issue 2 years ago • 1 comments

Describe the bug

I'm not able to cross compile Heimdal I've tried latest release: 7.7.0 and current master: https://github.com/heimdal/heimdal/commit/56b60a1a40022b651091933200dbefd087e32805

To Reproduce

  1. Clone the repo
  2. Run sh autogen.sh
  3. Run ./configure --prefix=/tmp/test_heimdal --build=x86_64-linux-gnu --host=aarch64-linux-gnu
  4. Run make
  5. Build fails with:
  CCLD     asn1_compile
asn1_compile --one-code-file --template --option-file=./rfc2459.opt ./rfc2459.asn1 rfc2459_asn1 || (rm -f rfc2459_asn1_files ; exit 1)
/bin/bash: asn1_compile: command not found
Makefile:2372: recipe for target 'rfc2459_asn1_files' failed
make[2]: *** [rfc2459_asn1_files] Error 1
make[2]: Leaving directory '/tmp/heimdal/heimdal/lib/asn1'
Makefile:589: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/tmp/heimdal/heimdal/lib'
Makefile:632: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1

Expected behavior

I need this to be able to build Heimdal for the Julia BinaryBuilder: https://docs.binarybuilder.org

Desktop

  • OS: Ubuntu 18.04.6 LTS

Additional context

It looks like there is something wrong with the makefiles, when doing cross compilation:

This fails:

./configure --prefix=/tmp/test_heimdal --build=x86_64-linux-gnu --host=aarch64-linux-gnu && make

Here we have:

$ grep ASN1_COMPILE lib/asn1/Makefile | head -1
ASN1_COMPILE = asn1_compile

This works:

./configure --prefix=/tmp/test_heimdal && make

Here we have:

$ grep ASN1_COMPILE lib/asn1/Makefile | head -1
ASN1_COMPILE = $(top_builddir)/lib/asn1/asn1_compile$(EXEEXT)

This looks more correct.

tp2750 avatar Apr 12 '22 08:04 tp2750

Cross-compiling Heimdal does not work. Its unclear when it worked last. The challenge is that Heimdal builds and executes many in-tree binaries which depend on in-tree libraries in order to generate the final output. The in-tree binaries and libraries are also the output. For cross-compilation to succeed the build system will need to build some targets multiple times at different stages of the build and execute the correct version locally. The build system clearly does not handle this case today.

jaltman avatar Sep 17 '22 13:09 jaltman

Besides that, for lib/asn1 in particular we need make absolutely sure that we use the correct sizeof() and offsetof() expressions if we're cross-compiling, and we almost certainly do not, especially in the "template" backend of the compiler!

To make cross-compilation work we'd have to:

  • build executables we need for both, the build and the release, twice: once for the local build and once for the release
  • fix lib/asn1/gen_template.c
  • produce something that one can run make check with on the target system
  • maybe other things.

nicowilliams avatar Dec 31 '22 06:12 nicowilliams

I'm going to close this, though it'd be really nice to have cross-compilation working.

nicowilliams avatar Dec 31 '22 07:12 nicowilliams