Discussion:
Compile error when building an Aarch32 program on Aarch64?
Jeffrey Walton
2016-07-30 02:04:24 UTC
Permalink
Hi Everyone,

I have a HiKey running Linaro. I'm trying to build out a test case
which tests Aarch32 on Aarch64.

When I attempt to build an Aarch32 binary I experience the compile
error below. The GCC folks helped me with the Aarch32 CFLAGS, so I
believe they are correct.

$ gcc -march=armv8-a+crc -mtune=cortex-a53
-mfpu=crypto-neon-fp-armv8 -mfloat-abi=hard test.cc -o test.exe
gcc: error: unrecognized command line option ‘-mfpu=crypto-neon-fp-armv8’
gcc: error: unrecognized command line option ‘-mfloat-abi=hard’

Trying an -m32:

$ gcc -march=armv8-a+crc -mtune=cortex-a53
-mfpu=crypto-neon-fp-armv8 -mfloat-abi=hard -m32 test.cc -o test.exe
gcc: error: unrecognized command line option ‘-mfpu=crypto-neon-fp-armv8’
gcc: error: unrecognized command line option ‘-mfloat-abi=hard’
gcc: error: unrecognized command line option ‘-m32’

And without the -mtune:

$ gcc -march=armv8-a+crc -mfpu=crypto-neon-fp-armv8
-mfloat-abi=hard test.cc -o test.exe
gcc: error: unrecognized command line option ‘-mfpu=crypto-neon-fp-armv8’
gcc: error: unrecognized command line option ‘-mfloat-abi=hard’

I'm obviously suffering a disconnect. I may have more problems after
the build when attempting to run the program, but I'll cross that
bridge when I encounter it.

How does one build an Aarch32 program on Aarch64?

Thanks in advance.
Jim Wilson
2016-07-30 04:04:43 UTC
Permalink
Post by Jeffrey Walton
How does one build an Aarch32 program on Aarch64?
The arm and aarch64 compilers are separate compiler ports. So you
need two different compilers, an arm compiler and an aarch64 compiler.
The arm compiler emits only 32-bit code. The aarch64 compiler emits
only 64-bit code. The native compiler is an aarch64 compiler. I
don't think that we ship arm cross compilers for that. You could try
to build one but this isn't the solution I would recommend. If you
have ubuntu, then there is a gcc-arm-linux-gnueabihf package you can
install. Note that aarch64 systems don't have mutlilib/multiarch
support yet like i686/x86_64 systems. At least not Ubuntu 14.04LTS
trusty and Debian Jessie. If you static link, you might get arm code
working in an aarch64 environment, but you won't be able to do much
with it.

This works much better if you install an arm userspace via
debootstrap, chroot into the arm userspace, and then compile code.
The arm userspace will have a native arm compiler. I have this setup
on a dragonboard (jessie) and an APM Mustang (trusty) and it works
fine. lxc/lxd also works on my trusty system, but I mostly use
schroot. A hikey doesn't have as much disk/flash space as my
dragonboard though, so this might not be as convenient.

Jim

Loading...