1

I'm trying to build gcc compiler to producing executables that are supposed to run on x86-64 machines. I'm actually using existing 64bit gcc compiler on my computer. It is redundant but I'm doing it for learning purposes.

The problems is, I don't know how do I specify --target option. What should I type there? Would simply typing "x86-64" work?

What if I wanted the cross compiler to be producing executables for x86 machines and is supposed to be running on another x86-64 bit machine in order to compile the source code?, what keyword should I use for setting target and host?

I would like to know if there is any gcc manual specifying supported architectures for host and target machines and the right commands to specify them.

1 Answer 1

3

To get an idea of the supported target architectures, you should look at configure and config.sub in whatever GCC sources you’re trying to build. You’ll also need matching binutils and a C library; the GCC installation manual provides details of the steps involved in configuring and building the compiler.

Beyond the architecture, you also need to decide which operating system and library to target; thus for Linux with the GNU C library on x86_64, you’d configure with --target=x86_64-linux-gnu. Shorter aliases exist, you can run config.sub to determine what they correspond to:

$ src/config.sub x86_64-linux
x86_64-pc-linux-gnu

So ./configure --target=x86_64-linux would be equivalent to x86_64-linux-gnu, which is equivalent to x86_64-pc-linux-gnu.

Once configured and built, you’ll get a compiler which builds programs which can run on the configured target; the compiler itself will run on the configured host. Generally speaking you should only specify the target; it is possible to cross-build a cross-compiler (this is known as a Canadian cross), but if you’re just getting into cross-compilation you should leave that aside for now.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .