[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Please drop autoconf-2.13-compatible cross-compile detection

From: Niels Möller
Subject: Please drop autoconf-2.13-compatible cross-compile detection
Date: Fri, 20 Apr 2018 23:08:30 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (berkeley-unix)

According to the autoconf manual,

  That's the short documentation. To ease the transition between 2.13 and
  its successors, a more complicated scheme is implemented. Do not rely on
  the following, as it will be removed in the near future.

  If you specify --host, but not --build, when configure performs the
  first compiler test it tries to run an executable produced by the
  compiler. If the execution fails, it enters cross-compilation mode. This
  is fragile.

My development machine is an x86_64 box running Debian GNU/Linux, with
autoconf version 2.69. I also have a couple of cross compilers
installed, e.g., mips-linux-gnu-gcc from the gcc-mips-linux-gnu debian
package. I can cross compile for this system using, e.g.,

  $ ~/hack/nettle/configure --host=mips-linux-gnu

and this initially worked as expected. Then I wanted to be able to run
the testsuite, so I installed the qemu-user package, and I can then run,

  $ file testsuite/aes-test
  testsuite/aes-test: ELF 32-bit MSB shared object, [...]
  $ LD_LIBRARY_PATH=.lib qemu-mips ./testsuite/aes-test

and this works fine. Now, the qemu-user package hooks up to the kernel's
binfmt mechanism, so that mips binaries can also be executed directly,
without invoking qemu explicitly:

  $ LD_LIBRARY_PATH=.lib ./testsuite/aes-test

All very nice, and makes it possible to run plain make check without any
Makefile hacks to invoke qemu at the right place.

However, this breaks autoconf's arcane cross compilation detection.
After I installed qemu, .../configure --host=mips-linux-gnu thinks I'm
doing a native build. Since the kernel is happy to execute binaries
produced by mips-linux-gnu-gcc.

In nettle, I build a programs "eccdata" used to generate lookup tables.
When cross compiling, I build this program as a native program using the
native compiler for the build architecture, and my configure script
selects the compiler to use based in part on the value of
$cross_compiling (using the macro GMP_PROG_CC_FOR_BUILD, borrowed from
GNU GMP). So one side effect of $cross_compiling incorrectly being "no"
here is that the eccdata program is compiled using the mips cross
compiler, and then running that program will go through the qemu
emulation. Which makes the total build time considerably longer. And
also means that

  $ ./configure --host=mips-linux-gnu && make
behaves very differently depending on whether or not the qemu packages
are installed, which is unintuitive.

Now, autoconf-2.13 is from a past millenium, and autoconf-2.50
(where the saner cross compile detection was introduced, as well as the
above documentation) was released 2001, promising removal of the
transition hack "in the near future".

I would say that 17 years later, the near future is here. Can we please
delete the fragile transitioning rules now?

Best regards,

PS. I am aware of the documented work-around, which is to also specify
    --build explicitly.

Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]