Cross compiling gcc 7.2 from x86_64 to aarch64

3.3k views Asked by At

I have successfully compiled gcc 7.2 from source on an x86_64. Native to native, so the resulting compiler is an x86_64 binary which works fine.

I would also like to have a working compiler for aarch64 (so, not a cross compiler. An aarch64 compiler binary producing aarch64 results.) This is where I'm stuck.

There's two options, a native-to-native compilation of gcc on the aarch64 host. This causes problems, and on top, is slow as mollasses, or a cross compilation of gcc on x86_64, resulting in an aarch64 compiler binary able to produce other aarch64 binaries.

I downloaded and unpacked gcc 7.2, and did the download_prerequisites step. Then I used the following configure:

../gcc-7.2.0/configure -v --build=x86_64-linux-gnu --host=x86_64-linux-gnu \
--target=x86_64-linux-gnu --prefix=/usr/local/gcc-7.2 \
--enable-checking=release --enable-languages=c,c++ --disable-multilib \
--program-suffix=-7.2

I suspect the --build, --host and --target are overkill in the native case, though. My question is now, what should I set these three to if I want to end up with the aarch64 compiler?

Down the line, I would also like an armv7l version. What would be the options for this?

0

There are 0 answers