Last change: 2006-12-25
1 Background |
1.1 Introduction |
|
1.2 What formats is this PGCC FAQ available in? |
The PGCC FAQ is generated from text using m4, and is available only in html format, although conversions into other formats might not be too difficult. |
1.3 What operating systems does this FAQ cover? |
Currently, many questions are based on the GNU/Linux operating system. Most of these are applicable to other Unices (like FreeBSD) and even to DOS (DJGPP) and OS/2 (EMX). |
1.4 Where can I get the PGCC FAQ? |
PGCC FAQ is available from / |
1.5 What is PGCC? |
PGCC stands for Pentium GCC. The PGCC is a version of the GNU C compiler (gcc), which provides special optimizations for the Pentium processor. |
1.6 Why have a Pentium-optimized gcc? |
The basic aim is to have a compiler which generates faster code.
The standard gcc does not take advantage of the capabilities of the Pentium processor to any great extent, while PGCC does. |
1.7 What is/was EGCS? |
EGCS stands for Experimental/Enhanced GNU Compiler System. It was a
decendant of GCC which used a more open development process. This meant
that it included more optimizations and language features than the
standard GCC. This experiment was very successful, and version 2.95 of GCC adopted the EGCS code. Since then GCC has been developed using the same methods as were used for EGCS. For more information and the official announcement (now historical) see this page and the GCC homepage. |
1.8 How do GCC and PGCC relate? |
PGCC is maintained and distributed as patches to EGCS. This allows PGCC
to benefit from the generally applicable enhancements of EGCS and
ensures that incompatible changes are not made in the two compilers.
Development is done on both, but PGCC gets the benefit of both sets of
improvements :-) .
Improvements from PGCC are also being folded into the main EGCS distribution. Since EGCS is aimed at more than just the Pentium, the optimizations often need to be implemented more generally before they can be included there. There are also some problems with the copyright of the Intel-written portions. |
1.9 How do I read the version name? |
"pgcc" versions usually have the same version number as the GCC versions they are based on, i.e. gcc-2.90.20 -> pgcc-2.90.20. There are rare exceptions, though. |
1.10 How much does it cost? |
It is free. |
1.11 Where can I get it? |
Have a look at our main site at www.goof.com/pcg. |
1.12 Where are FTP mirrors? |
Currently, the diffs and binaries are available at:
ftp.pmi.saitama-med.ac.jp (Japan) NOTE: a much longer and more uptodate list can be found either on this web server or on our main site |
1.13 Where are the web mirrors for PGCC? |
www.pmi.saitama-med.ac.jp/pcg Japan linux.cis.nctu.edu.tw/pcg Taiwan www.nightflight.com/~pcg USA NOTE: a much longer and more uptodate list can be found either on this web server or on our main site |
1.14 Are there mailing lists available? |
pgcc@delorie.com, a mailing list
for all people interested in pgcc. To subscribe send mail to
listserv@delorie.com with
add pgcc in the body. There is an archive available.
Before reporting bugs to the list, pleas see the question describing how to report bugs. |
1.15 What is the status of the project? |
These are the main people involved at the moment (if I forgot somebody just tell me!):
|
1.16 What platform does PGCC run on? |
PGCC should run on almost any platform the original gcc runs on (even non-Intel machines). See Compatibility for more details. |
1.17 Are there any operating systems using PGCC? |
Both the Stampede and Enoch GNU/Linux distributions use PGCC as their main compiler, shipping it and using it to build the distribution. |
1.18 Where did PGCC come from? |
When Intel
released the Pentium some of their team produced a version of gcc with
enhancements which gave 30% speed improvements on some benchmarks.
Having demonstrated the improvements possible, they stopped development
and released the code.
PGCC came from this work and further enhancements of the Intel code that had been produced. It aims to improve the stability of the compiler and to carry on improving the quality of the generated code. |
1.19 How much speed improvement can I expect? |
The 30% achieved by the Intel engineers is rare in the real world. Typically, the improvement will be about 5% using an intermediate optimization level like -O3 and no fine-tuning. Sometimes the 30% can be achieved - gzip-1.24 unzips about 20%-35% faster - but don't bank on it. |
1.20 How can you help? |
WE NEED HACKERS.. AND TIME! Please contact Marc Lehmann <pcg@goof.com>! |
1.21 Can I set up a mirror for PGCC? |
Sure, if you want to... There are two basic options.
|
1.22 Whom can I contact? |
If you have ANY questions concerning PGCC or the Pentium Compiler Group,
don't hesitate to mail Marc Lehmann <pcg@goof.com>!
If you have source code patches (e.g. if you are a hacker), you can always document (or explain) them and send them directly to Marc Lehmann <pcg@goof.com>, but you should ask him before going to hack around in pgcc (just to ensure that no unnecessary work is done)! If you have more suggestions for the FAQ, you can always mail Marc Lehmann <pcg@goof.com> or Mark Brown <broonie@tardis.ed.ac.uk>. See also the section on Reporting Bugs. |
2 Compatibility issues |
2.1 What platforms does PGCC run on? |
PGCC should support all configurations supported by EGCS, although in
practise it may not build on non-Intel machines. No guarentees
can be made about the quality of the generated code (particularly not
for non-Intel processors) but the aim is that it should be faster.
Please check the EGCS FAQ for the most up to date information on what's supported and required. |
2.2 What libraries do I need? |
PGCC requires whatever libraries EGCS requires on the same platform - normally just the standard C library under Unix. If you are using glibc 2 you should use version 2.0.7 or later if you wish to use the FPU stack alignment features. Some binary releases will also require 2.0.7, but others will not. |
2.3 Can I compile the Linux kernel with PGCC? |
Perhaps. :-)
Older Linux kernels had many problems with illegal assembly constructs which prevented them from being compiled with egcs or pgcc (see the next question for details). Work has been done to correct these problems, and 2.2 kernels are much improved. However, there are still a number of problems which can cause kernels built using PGCC to fail to work correctly and neither the PGCC maintainers nor the kernel maintainers officially support this. While many people are successfuly using PGCC built kernels you may experience problems, and if you do the PGCC maintainers are only really interested in bug reports which also identify the source of the problem. |
2.4 What about PGCC and Linux 2.0.x? |
Linux 2.0.x uses many illegal constructs that happened to work fine
under gcc-2.7.2 and earlier versions. PGCC happily optimizes away crucial
code, so Linux 2.0.x will not, in general, work when compiled with PGCC.
The egcs and linux 2.0 page has some patches for the most important problems, and many users have no problems with such a patched kernel, but I wouldn't trust the kernel even with these patches applied. |
2.5 Does PGCC support Pentium-compatible CPUs? |
Yes. PGCC's generic Pentium optimised code will run on the Pentium
clones as well as Intel chips. There is a specially tuned
optimization mode for AMD K6 chips.
Code which contains Pentium Pro instructions (ie, has been compiled with
|
2.6 Does PGCC support MMX or 3Dnow! instructions? |
PGCC does support MMX and 3Dnow! - recent snapshots can generate MMX instructions, and you can include them both in inline assembly. Using inline assembler will almost certainly produce the best results. To use these instructions, you need to be using GNU binutils-2.9.1 or later. For full details, see the optimization section. |
3 Installation/Configuration |
3.1 Can I install PGCC 1.1.2? |
There are problems with PGCC 1.1.2 which prevent it from building on most platforms - please use PGCC 1.1.3 instead. |
3.2 How do I install the precompiled binary? |
If you have a tar file containing a binary distribution saying
mv /usr/bin/gcc /usr/bin/oldgcc
will install the binary compiler as the default compiler (it will overwrite
/usr/bin/gcc but not the real compiler). If you saved your
old |
3.3 Are there Debian packages of PGCC? |
No. While some people have expressed an interest in them, nobody has actually done the work yet. If you are interested the people to speak to are probably the Debian gcc maintainers. |
3.4 How do I uninstall a binary release? |
The basic idea is just to delete all the installed files.
PGCC binary releases install in
It is much easier to uninstall if you use a system like GNU stow to
help manage your |
3.5 How do I invoke my old GCC version? |
Even when not saving your /usr/bin/gcc , your previous gcc
(which will probably be gcc-2.7.2) is not lost.
Generally, you can install as many version of gcc for as many architectures
you want. To choose between them, gcc has two switches:
|
-V | the version of gcc you want to invoke. Used like -V2.7.2 or -V2.7.2p |
-b | the target machine/architecture gcc should _compile code for. Typical uses include -bi486-linux and -bi586-pc-linux-gnu. |
PGCC's architecture (under GNU/Linux) generally is
i586-pc-linux-gnu. Your old compiler will likely use architecture
i486-linux or i586-linux (ancient distributions use
i386-linux) and version 2.7.2, so the you will probably get your
old compile when using:
-V2.7.2 -bi486-linux . It's much easier to save your old compiler
binary, though. |
3.6 How do I build PGCC from source? |
The standard method is that documented in the INSTALL tree in
the root of the source distribution (in snapshots, this is replaced by
a pointer to a web based version of the instructions). The quickest
(although not always best) method is this:
which (all being well) should install PGCC in
It is better to use one of the bootstrapping options |
3.7 Do I need to install pentium library in order to install snapshot? |
PGCC should work with whatever libraries you have installed (see this question for Linux requirements). A Pentium optimised version would probably run faster. |
3.8 What else do I need to compile pgcc? |
gperf , the gnu-perfect-hash generator, autoconf , bison and
flex . All of these are available from any GNU mirror.
The newest versions
(which might be required for the snapshots) of most programs can be found
at ftp://egcs.cygnus.com/pub/egcs/infrastructure/. Autoconf can be found
at
http://sourceware.cygnus.com/autoconf/. |
3.9 I can't find the version of libc5 you recommended, where can I get it from? |
You can get libc-5.4.43 (and other versions) from ftp://ftp.yggdrasil.com/private/hjl/. |
4 Optimization |
4.1 Which compiler switches should I use for optimum performance? |
As with all optimization questions, the final answer is to benchmark your code and see what works best. The hints in the next few questions should give you some good starting points, but it pays to test. |
4.2 How do I tell the compiler which CPU I'm using? |
The options controlling processor type come in two forms. You can
enable scheduling for a given processor using -mcpu. This will
produce binaries which will run on any Intel CPU, but which should
perform best for the CPU type. For those CPUs where PGCC knows about
additional instructions, you can use -march=cpu. Binaries
compiled with -march may not run on other kinds of CPU.
Currently, cpu can be chosen from 486, pentium, pentiumpro and either amdk6 (in released versions) or k6 (in snapshots). There is no specific Pentium II or III support, but they are very much like a Pentium Pro and so Pentium Pro options tend to work best. Please note when when using -march that the resulting binaries will only run on CPUs which support the same instruction set as the architecture selected. See the compatbility section for some details. |
4.3 Why has PGCC changed from saying amdk6 to k6 in
options? |
That's what EGCS called it when support for the K6 was added to it. The rationale is that none of the other processor selection options use the manufacturer's name, so it's more consistent. |
4.4 Can PGCC use the MMX features of my CPU? |
Recent snapshots support MMX so long as you are using binutils-2.9.1
or later. You can include MMX instructions in inline assemlber, or
enable the compiler optimizations by using the -mmx option (use
-mmx-only if your code never uses the FPU). These
optimizations are unlikely produce much improvement without special
fine-tuning of the code to take advantage of them.
This probably won't result in any improvement on Pentiums - their MMX unit is not particularly fast, so the code must be specially structured to take advantage of the MMX. The implementation of MMX in the Pentium II is somewhat better, so more improvements may be seen there. |
4.5 Is there 3Dnow! support? |
Currently, the only support for 3Dnow! is the ability to use it in inline assembly. As with MMX, you need binutils-2.9.1 or later to do this. |
4.6 Which compiler switches should I use for smallest code size? |
The combination -O -Os will usually generate the smallest
binaries. If you don't use exceptions you can add -fno-exceptions
to reduce code size further, although newer binutils can compact the
execution table and reduce the benefits.
In C++ programs you might additionally try -fno-rtti in programs not using runtime type information. |
4.7 Why are the programs produced by PGCC larger than those produced by gcc? |
x86 CPUs have many special purpose instructions. On older CPUs they
executed at roughly the same speed as the more general ones, and so gcc
used them. The current trend in processor design is towards a smaller
instruction set, and Intel have followed this to a certain extent. The
old instructions are supported, but won't work nearly as quickly as
others. While it may take more of the general instructions to do
something, they run faster.
Sometimes this doesn't work out - the code can end up using the cache ineffectively and actually run slower. If this happens, optimizing for size re-enables the old instructions and should help. |
4.8 How stable are the PGCC-specific optimizations? |
Everything that is enabled by -O6 should be stable. If that doesn't work, -O2 should be even more stable. You can also pick and choose which optimizations to use - see the listing of optimizations for details. Those optimizations which are known to be buggy are never enabled by a -Ox option and must always be enabled individually. |
4.9 Exactly what optimizations does PGCC do? |
Table Headers |
SWITCH | the compiler switch used to activate/deactive the optimization. if reduce-all-givs is the switch, then -freduce-all-givs will activate, while -fno-reduce-all-givs will deactivate it. |
O | The standard optimization level that will enable the switch by default. For example, 3 means that -O3, -O4 and higher include this optimization, while -O2 will not. - means that no -O level will activate this optimization so you must specify it manually. |
S | The "stableness" of this optimization. One of:
|
DESCRIPTION | gives a short description of the optimization. Tell me if you want to add something or have questions... |
SWITCH | O | S | DESCRIPTION |
---|---|---|---|
move-all-movables | - | S | it is taken from g77, and rarely improves C or C++ codes although Fortran codes might be improved |
reduce-all-givs | - | S | it is taken from g77, and rarely improves C or C++ codes although Fortran codes might be improved |
rerun-loop-opt | - | S | it is taken from g77, and rarely improves C or C++ codes although Fortran codes might be improved |
opt-reg-use | 1 | S | optimizes usage of registers for memory addresses |
reduce-index-givs | 1 | S | try to treat index terms of addresses as a reducible mem givs |
inline-functions | 3 | S | see gcc's documentation |
jump-back | 3 | S | in optimization of loops treats jumps backwards as not nullifying optimization opportunities |
copy-prop | 3 | S | loop copy propagation |
compare-elim | 3 | S | compare elimination |
software-pipe | 3 | S | mini software pipelining on stack registers |
reg-reg-copy-opt | 3 | S | after reload if a register is marked dead at a copy into another register - see if the other register can be used in the first place thereby eliminating the copy |
opt-reg-stack | 3 | D | optimize usage of stack registers from the stack |
loop-after-global | 3 | D | after reload try to optimize usage of spill slots in loops |
peep-spills | 3 | U | after reload try to replace spill slots with equivalent registers |
replace-stack-mem | 3 | S | try to replace memory operands with equivalent stack registers in first pass of loop optimize |
opt-jumps-out | 3 | S | try aggressive changing of jumps taken to jumps not taken |
replace-mem | 3 | S | try to replace memory operands with equivalent registers in first pass of loop optimize |
correct-cse-mistakes | 3 | S | cse is sometimes detrimental |
push-load-into-loop | 3 | S | try to push loads back into loops if the loaded register has been spilled |
replace-reload-regs | 3 | S | try to use available registers so that a memory operand that is reloaded will be reloaded into the same register. This helps loop-after-global |
sign-extensions-elim | 3 | S | sign-extension elimination |
lift-stores | 3 | S | try to lift memory clarity, memory operands that are stored to in a loop into a register for the duration of the loop |
combine-222 | 4 | D | combining two instructions to two instructions sometimes can be a gain |
schedule-insns2 | 4 | S | see gcc's documentation |
swap-for-agi | 4 | S | allow scheduler to try to swap two instructions when the first increments a register by a constant and the second uses that register as a base |
risc | 4 | S | after reload use available registers to load memory operands into them and use the register instead of the memory operand |
risc-const | 4 | S | after reload use available registers to load CONST_INTs into them and then store the register instead of the CONST_INT |
recombine | 4 | R | if the riscified instruction has not changed it's place in scheduling then recombine it into a cisc instruction |
interlave-stack-non-stack | 4 | S | use the first pass of the scheduler to rearrange between insns that reference stack registers and those that don't but not amongst themselves |
schedule-stack-reg-insns | 4 | S | use the first pass of the scheduler to rearrange between insns that reference stack register |
runtime-lift-stores | 5 | S | as lift-stores but improve clarity at runtime, i.e. there will be two copies of the loop, one clear one not, and the decision of which one to run will be made at runtime |
omit-frame-pointer | 5 | U | see gcc's documentation |
schedule-insns | 5 | R | see gcc's documentation |
all-mem-givs | 6 | S | reduce all the mem address givs |
do-offload | 6 | S | move stack registers that will be compared for equality off, the stack before the comparison |
risc-mem-dest | 6 | S | a destination that was riscified should stay that way |
4.10 Any specific suggestions for FPU intensive code? |
Yes. Newer CPUs (Pentium and above) are very sensitive
to the memory alignment of double variables. Unfortunately,
the x86 ABI (Application Binary Interface) specifies an alignment
of 4 bytes, whereas 8 bytes would be optimal. As a result, execution
speed may be poor and can vary dramatically between runs.
There are several switches which can be used to improve the situation, sometimes at the expense of compatibility with other code:
-malign-double
-mstack-align-double
-marg-align-double
-funroll-all-loops
-Os
You may also find some useful suggestions in the GNU Fortran manual (supplied in the distribution in Texinfo format - it will be installed in info format by the default install target in the Makefile). |
5 Troubleshooting |
5.1 How do I report a bug in PGCC? |
Before you report a bug for the C++ compiler, please check the list
of well-known bugs in egcs. If you
want to report a bug with pgcc-1.0.x, we recommend upgrading to the
current release first. It might also be worthwhile to check out a current
snapshot, preferably from CVS, to see wether the bug has already been
fixed.
In short, if pgcc says
Typically the CPP output will be large, so please compress the resulting
file with one of the popular compression programs such as The mailing lists have message size limits (50 kbytes) and bug reports over those limits will annoy people. If you bug reports are larger and if you cannot reduce the bug report below the limit, please make it available for ftp or http and post the URL. In general you can do us a great favour if you can track down the error as much as possible. Stripping down the size of the file that exhibits a problem as much as possible is also an invaluable aid: a single, small file is easier to debug than some dubious error in one of the 23 source files. Please check the list archives to see if the problem has already been reported you submit your report. This is particularly likely to be the case if some common piece of software fails to build when a new version of it or PGCC is released. If the problem has already been reported, please only report additional information (eg, exactly which optimization causes the failure or even a fix). |
5.2 Why am I having trouble compiling PGCC 1.1.2? |
There are problems building PGCC 1.1.2 on many platforms. Please use PGCC 1.1.3 instead. |
5.3 Why do I get hundreds of silly errors on a perfectly fine program? |
If you get excessive errors like pgcc-2.90.21/include/stdarg.h:41: parse error pgcc-2.90.21/include/stdarg.h:0: numeric constant with no digits pgcc-2.90.21/include/stdarg.h:0: warning: unrecognized text at end pgcc-2.90.21/include/stdarg.h:69: parse error at null characterthen you have an old version of libc5 installed on your system. You need at least libc-5.4.22 (5.4.43 or higher recommended). If you use glibc, then you have probably installed the libc5 version of pgcc (which won't work with glibc anyway). |
5.4 My linux kernel 2.0.x doesn't run properly when compiled with pgcc. |
See this question for an answer. |
5.5 Why do I keep getting SIGSEV (signal 11)? |
If you get spurious SIGSEGV (signal 11) signals when compiling
something with the pgcc, which go away when you restart the compilation,
that is not a pgcc problem, but
rather a problem with the hardware (i.e. overclocking, slow dram etc..).
See the sig11 faq at
http://www.bitwizard.nl/sig11/
If you get SIGSEGV (signal 11) with the same file everytime you compile it, i.e. PGCC fails consistently, then you've hit a bug in pgcc. Please report it. |
5.6 Why am I getting asm() errors when I don't use any assembly in
my code? |
The offending statements have probably been introduced by inline code in
header files. Most likely the header files contain incorrect
asm() statements which worked with older (and less strict) gcc
versions.
Under Linux, some versions of libc and glibc have these problems - you might try upgrading. glibc 2.1 should work, as should some 2.0 versions. |
5.7 How can I build XFree86 using PGCC? |
There is a problem compiling libfont.a with PGCC 1.1.3 and high
optimisations. Compiling this library with EGCS has been reported to
work, as has using the link kit see
the mailing list archives for further details. |
Did you know that your Browser is buggy: it can't parse comments correctly. -->