Building GCC 4.9 biarch (i686+x86_64) on Debian 6.0 i686
Andrew Haley
aph@redhat.com
Wed Mar 18 12:28:00 GMT 2015
On 03/18/2015 11:58 AM, Alex Blekhman wrote:
> Andrew Haley <aph <at> redhat.com> writes:
>> Cross-compiling from 32- to 64-bit hosts is notoriously tricky. People
>> almost always go in the opposite direction. I don't even know if it
>> can be done.
>
> I can live with 64-bit system, which has 64-bit GCC. What is essential for
> me is that I can build both 32-bit and 64-bit targets and then run 32-bit
> targets (during test phase of the build).
>
> How difficult (easy?) is it to have 64-bit Debian/Redhat machine running
> 32-bit executables?
Tivial. As long as you have the libraries installed it usually just works.
You don't need a special GCC.
Like so:
zebedee:~ $ cat hello.c
#include <stdio.h>
int main(void) {
puts("Hello, world!");
}
zebedee:~ $ gcc hello.c
zebedee:~ $ file a.out
a.out: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
zebedee:~ $ ./a.out
Hello, world!
zebedee:~ $ gcc -m32 hello.c
zebedee:~ $ file a.out
a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
zebedee:~ $ ./a.out
Hello, world!
Andrew.
More information about the Gcc-help
mailing list