pcc/ cross-compiler

General cross-compiler

A complete cross-compiler can be set up easily. For example:

$ cd binutils-2.18
$ ./configure --target=mips-netbsdelf
$ make && make install
$ cd ../pcc
$ ./configure --target=mips-netbsdelf
$ make && make install

The compiler from the above example is called /usr/local/bin/mips-netbsdelf-pcc.

Copying the header files from the target machine into /usr/local/mips-netbsdelf/include and the libraries into /usr/local/mips-netbsdelf/lib is sufficient to build binaries.

It's possible for multiple cross-compilers to exist on the host system at the same time (which was the motivation for doing this!).

Cross-compiler to Microsoft Windows

Building a cross-compiler for Windows follows a similar process to the above; however be aware that using pcc to generate '.exe' executables is best described as a 'work in progress' at the present time. Specifically, pcc is unable to compile the support libraries for either itself or the Windows runtime, so the gcc cross-compiler needs to be installed and used for this. Also, pcc cannot currently parse the #pragma's included by "windows.h", which means that you're pretty much limited to compiling console programs.

It is hoped that these issues can be resolved and these build instructions are provided to outline the steps needed in creating a cross-compiler, and to assist as a test case for anticipated compiler fixes. You will need header files and libraries for Windows; these files are maintained by the MinGW project. You can find pcc-supported source and binary tarballs of these libraries on the pcc website and in addition you will need binutils. These instructions will create a cross-compiler called '/usr/local/bin/i386-pe-pcc' with all includes and libraries in '/usr/local/i386-pe'. (Root password is required for the installation steps; if you are a 'sudo' user replace su -c 'make install' with sudo make install in the examples.)

And that's it! You should now be able to run 'i386-pe-pcc' to compile simple (console) programs, which will invoke only 'i386-pe-as' and 'i386-pe-ld' (you may wish to open a new shell because of your altered $PATH):

    i386-pe-pcc -o /tmp/helloworld.exe /tmp/hellow.c

Be sure to check status of pragma support in pcc on the bug tracking system and changes to the MinGW release files before submitting bugs for this build.