to use latest GCC(4.8.1) on older Linux Svrs (Redh

2019-07-01 11:03发布

问题:

We do coding & building in one Linux machine, & deploy to our cluster with hundreds of cores. For now both type of machines are Redhat EL 5.7, with the default GCC 4.1.2 installed.

Recently we realized the latest GCCs (e.g. 4.8.1) got extensive optimizations for arithmetic calculations, including the usage of MPFR/MPC etc. Because our programs are very floating point calculation intensive, we hope to rebuild our programs in latest GCCs to achieve the boost.

Here are the current linking details for a typical program built by us:

    linux-gate.so.1 =>  (0x007e0000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x009bb000)
    libc.so.6 => /lib/libc.so.6 (0x00581000)
    /lib/ld-linux.so.2 (0x0034c000)    

Because it's unlikely for us to upgrade OS, or install new stuffs in cluster. (tightly controlled). So questions are:

1, for developing, possible for us to install the latest GCC on existing machine? (We tried and found lot's of dependencies needed). And possible to link to the older libs?

2, for deployment, possible to deploy to our cluster without installing new softwares? For these MPFR etc, can we just deploy the so files instead of installing RPMs in the target cluster nodes?

Thanks a lot for any help.

回答1:

You need to install the required dependencies (and their required versions) to build GCC 4.8; notice that MPFR, CLOOG etc are only needed to the compiler (so are needed at compilation time, not at run time of your compiled program), so you don't need to install them to deploy your compiled program. Don't link the compiler to older versions of required dependencies.

The gcc-4.8 source tarball has a contrib/download_prerequisites script which could be helpful.

If building GCC 4.8 from source tarball, don't forget to build outside of the source tree, and to follow the install instruction.

You may want to link your program with the -static-libgcc option, or even to ..../configure the compiler with --disable-shared and --program-suffix=-4.8 configure options

(with that program-suffix option, you'll run your new GCC as gcc-4.8 and it will get installed, unless you configure some --prefix, in /usr/local/bin/ by default; this won't interfere with the system gcc; if you don't have [root] write access to /usr/local you should configure your own --prefix).

BTW, you might consider perhaps customizing your GCC 4.8, e.g. thru plugins or better yet using MELT.