Build gcc 4.1.2 from src RPM on a CentOS 5.10

Grigory asked:

I need an advice on how to compile gcc 4.1.2 on a CentOS 5.10.

The long story:

I’ve a got a Citrix XenServer Creedence beta 1 up and running OK. It has actually CentOS 5.10 as the dom0. This can be figured out like this:

[admin@xenserver ~]$ rpm -q centos-release
centos-release-5-10.el5.centos 

I need to recompile dom0’s kernel to include some options. It does not have gcc installed. There is an an ISO with all the sources and there I can find the gcc’s and the kernel’s src RPMs.

IMO I have to first compile the gcc and then build a custom kernel. I’m totally not a RedHat and CentOS guy but I want to do everything right. The things that confuse me are those source RPMs.

The gcc RPM has a lot of files including patches:

[admin@xenserver 1]$ l
total 39M
drwxrwxr-x 2 admin admin  12K Sep 13 22:09 ./
drwxrwxr-x 3 admin admin 4.0K Sep 13 22:08 ../
-rwxr-xr-x 1 admin admin 1.7K May 31  2012 dummylib.sh*
-rw-rw-r-- 1 admin admin  37M Sep 17  2008 gcc-4.1.2-20080825.tar.bz2
-rw-r--r-- 1 admin admin  346 May 31  2012 gcc41-ada-pr18302.patch
-rw-r--r-- 1 admin admin 2.5K May 31  2012 gcc41-ada-tweaks.patch
-rw-r--r-- 1 admin admin 149K May 31  2012 gcc41-artificial-attrib.patch
-rw-r--r-- 1 admin admin 3.6K May 31  2012 gcc41-c++-builtin-redecl.patch
-rw-r--r-- 1 admin admin 2.1K May 31  2012 gcc41-c++-gnu-inline-redecl.patch
-rw-r--r-- 1 admin admin  47K May 31  2012 gcc41-CVE-2008-5659.patch
-rw-r--r-- 1 admin admin 6.8K May 31  2012 gcc41-CVE-2009-3736.patch
-rw-r--r-- 1 admin admin 3.0K May 31  2012 gcc41-CVE-2010-0831.patch
-rw-r--r-- 1 admin admin 1.3K May 31  2012 gcc41-debug-fortran-array.patch
-rw-r--r-- 1 admin admin  745 May 31  2012 gcc41-dsohandle.patch
-rw-r--r-- 1 admin admin  16K May 31  2012 gcc41-eh-backport.patch
-rw-r--r-- 1 admin admin  12K May 31  2012 gcc41-error-attrib.patch
-rw-r--r-- 1 admin admin  491 May 31  2012 gcc41-fastjar-filename0.patch
-rw-r--r-- 1 admin admin 1.5K May 31  2012 gcc41-gnuc-rh-release.patch
-rw-r--r-- 1 admin admin 5.4K May 31  2012 gcc41-hash-style-gnu.patch
-rw-r--r-- 1 admin admin  878 May 31  2012 gcc41-i386-libgomp.patch
-rw-r--r-- 1 admin admin  17K May 31  2012 gcc41-ia64-libunwind.patch
-rw-r--r-- 1 admin admin 8.1K May 31  2012 gcc41-ice-hack.patch
-rw-r--r-- 1 admin admin 2.5K May 31  2012 gcc41-java-libdotdotlib.patch
-rw-r--r-- 1 admin admin  641 May 31  2012 gcc41-java-nomulti.patch
-rw-r--r-- 1 admin admin  521 May 31  2012 gcc41-java-slow_pthread_self.patch
-rw-r--r-- 1 admin admin  91K May 31  2012 gcc41-libgomp-speedup.patch
-rw-r--r-- 1 admin admin  16K May 31  2012 gcc41-libjava-anonverscript.patch
-rw-r--r-- 1 admin admin 3.6K May 31  2012 gcc41-omp-outer-ctx.patch
-rw-r--r-- 1 admin admin 1.9K May 31  2012 gcc41-ppc32-retaddr.patch
-rw-r--r-- 1 admin admin 3.0K May 31  2012 gcc41-ppc64-ia64-GNU-stack.patch
-rw-r--r-- 1 admin admin 1014 May 31  2012 gcc41-ppc64-libffi-unwind.patch
-rw-r--r-- 1 admin admin 1.1K May 31  2012 gcc41-ppc64-m32-m64-multilib-only.patch
-rw-r--r-- 1 admin admin 2.1K May 31  2012 gcc41-pr20297-test.patch
-rw-r--r-- 1 admin admin 1.5K May 31  2012 gcc41-pr20880.patch
-rw-r--r-- 1 admin admin 6.5K May 31  2012 gcc41-pr23848.patch
-rw-r--r-- 1 admin admin 1.7K May 31  2012 gcc41-pr25507.patch
-rw-r--r-- 1 admin admin  11K May 31  2012 gcc41-pr27144.patch
-rw-r--r-- 1 admin admin 1.7K May 31  2012 gcc41-pr33844.patch
-rw-r--r-- 1 admin admin 2.2K May 31  2012 gcc41-pr33890.patch
-rw-r--r-- 1 admin admin 1.1K May 31  2012 gcc41-pr33962.patch
-rw-r--r-- 1 admin admin 2.0K May 31  2012 gcc41-pr34070.patch
-rw-r--r-- 1 admin admin 1.3K May 31  2012 gcc41-pr34089.patch
-rw-r--r-- 1 admin admin 3.2K May 31  2012 gcc41-pr34146.patch
-rw-r--r-- 1 admin admin 3.2K May 31  2012 gcc41-pr34178.patch
-rw-r--r-- 1 admin admin 1.9K May 31  2012 gcc41-pr34213.patch
-rw-r--r-- 1 admin admin  935 May 31  2012 gcc41-pr34275.patch
-rw-r--r-- 1 admin admin 1.1K May 31  2012 gcc41-pr34364.patch
-rw-r--r-- 1 admin admin  980 May 31  2012 gcc41-pr34369.patch
-rw-r--r-- 1 admin admin  651 May 31  2012 gcc41-pr34394.patch
-rw-r--r-- 1 admin admin 3.1K May 31  2012 gcc41-pr34506.patch
-rw-r--r-- 1 admin admin 1.8K May 31  2012 gcc41-pr34513.patch
-rw-r--r-- 1 admin admin 2.9K May 31  2012 gcc41-pr36189.patch
-rw-r--r-- 1 admin admin 1.5K May 31  2012 gcc41-pr36237.patch
-rw-r--r-- 1 admin admin 2.6K May 31  2012 gcc41-pr36449.patch
-rw-r--r-- 1 admin admin 2.4K May 31  2012 gcc41-pr37014.patch
-rw-r--r-- 1 admin admin 1.4K May 31  2012 gcc41-pr37731.patch
-rw-r--r-- 1 admin admin 4.3K May 31  2012 gcc41-pr39431.patch
-rw-r--r-- 1 admin admin 1.3K May 31  2012 gcc41-pr39563.patch
-rw-r--r-- 1 admin admin  18K May 31  2012 gcc41-pr39865.patch
-rw-r--r-- 1 admin admin 2.4K May 31  2012 gcc41-pr40057.patch
-rw-r--r-- 1 admin admin 1.3K May 31  2012 gcc41-pr40088.patch
-rw-r--r-- 1 admin admin  954 May 31  2012 gcc41-pr40473.patch
-rw-r--r-- 1 admin admin 1.3K May 31  2012 gcc41-pr41063.patch
-rw-r--r-- 1 admin admin 1.7K May 31  2012 gcc41-pr41646.patch
-rw-r--r-- 1 admin admin 1.2K May 31  2012 gcc41-pr44367.patch
-rw-r--r-- 1 admin admin 2.0K May 31  2012 gcc41-pr46815.patch
-rw-r--r-- 1 admin admin 2.2K May 31  2012 gcc41-pr48481-1.patch
-rw-r--r-- 1 admin admin 1.9K May 31  2012 gcc41-pr48481-2.patch
-rw-r--r-- 1 admin admin 3.5K May 31  2012 gcc41-pr48481-3.patch
-rw-r--r-- 1 admin admin 1.3K May 31  2012 gcc41-pr50055.patch
-rw-r--r-- 1 admin admin 5.3K May 31  2012 gcc41-pr519519.patch
-rw-r--r-- 1 admin admin 8.7K May 31  2012 gcc41-pr7081.patch
-rw-r--r-- 1 admin admin  674 May 31  2012 gcc41-rh184446.patch
-rw-r--r-- 1 admin admin 3.2K May 31  2012 gcc41-rh235008.patch
-rw-r--r-- 1 admin admin 1.2K May 31  2012 gcc41-rh247256.patch
-rw-r--r-- 1 admin admin 2.7K May 31  2012 gcc41-rh251682.patch
-rw-r--r-- 1 admin admin 8.4K May 31  2012 gcc41-rh317051.patch
-rw-r--r-- 1 admin admin  24K May 31  2012 gcc41-rh364001.patch
-rw-r--r-- 1 admin admin 2.1K May 31  2012 gcc41-rh369541-1.patch
-rw-r--r-- 1 admin admin 2.0K May 31  2012 gcc41-rh369541-2.patch
-rw-r--r-- 1 admin admin 5.7K May 31  2012 gcc41-rh407281.patch
-rw-r--r-- 1 admin admin  17K May 31  2012 gcc41-rh426846.patch
-rw-r--r-- 1 admin admin 2.0K May 31  2012 gcc41-rh462397.patch
-rw-r--r-- 1 admin admin 3.4K May 31  2012 gcc41-rh578382.patch
-rw-r--r-- 1 admin admin 1.5K May 31  2012 gcc41-rh605803.patch
-rw-r--r-- 1 admin admin  594 May 31  2012 gcc41-rh630893.patch
-rw-r--r-- 1 admin admin 7.3K May 31  2012 gcc41-rh735304.patch
-rw-r--r-- 1 admin admin 1.5K May 31  2012 gcc41-rh746405.patch
-rw-r--r-- 1 admin admin  803 May 31  2012 gcc41-rh750545.patch
-rw-r--r-- 1 admin admin 2.1K May 31  2012 gcc41-rh797938.patch
-rw-r--r-- 1 admin admin 132K May 31  2012 gcc41.spec
-rw-r--r-- 1 admin admin 259K May 31  2012 gcc41-sse5.patch
-rw-r--r-- 1 admin admin 5.1K May 31  2012 gcc41-sse5-pperm.patch
-rw-r--r-- 1 admin admin 1.3K May 31  2012 gcc41-unwind-cmp.patch
-rw-r--r-- 1 admin admin 2.4K May 31  2012 gcc41-unwind-restore-state.patch
-rw-r--r-- 1 admin admin  574 May 31  2012 gcc41-unwind-swap.patch
-rw-r--r-- 1 admin admin  30K May 31  2012 gcc41-virtual-inline-backtrace.patch
-rw-r--r-- 1 admin admin  16K May 31  2012 libgcc_post_upgrade.c
-rw-r--r-- 1 admin admin  12K May 31  2012 protoize.1
-rw-r--r-- 1 admin admin 2.4K May 31  2012 README.libgcjwebplugin.so

So I am asking why all these patches are here? How and in what order should they be applied?

And what totally confuses me is that there is no any gcc installed here.

Can anyone give me a piece of advice on how to compile gcc having this src RPM?

Thank you.

UPDATE Another question about rpmbuild
I’ll say something about rpmbuild. In Citrix XenServer all the standard yum repos are disabled. And one have to enable a repo to install a package. So, when I try to install the rpm-build package I get the output that I don’t quite understand:

[admin@xenserver 1]$ sudo yum --enablerepo=base --disablerepo=citrix install rpm-build                                                                                                                          
[sudo] password for admin: 
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.majorhost.net
base                                                                                                                                                                                     | 1.1 kB     00:00     
Excluding Packages from CentOS-5 - Base
Finished
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package rpm-build.x86_64 0:4.4.2.3-34.el5 set to be updated
--> Processing Dependency: elfutils for package: rpm-build
--> Running transaction check
---> Package elfutils.x86_64 0:0.137-3.el5 set to be updated
--> Processing Dependency: elfutils-libs-x86_64 = 0.137-3.el5 for package: elfutils
--> Processing Dependency: elfutils-libelf-x86_64 = 0.137-3.el5 for package: elfutils
--> Processing Dependency: libdw.so.1(ELFUTILS_0.130)(64bit) for package: elfutils
--> Processing Dependency: libdw.so.1(ELFUTILS_0.126)(64bit) for package: elfutils
--> Processing Dependency: libdw.so.1(ELFUTILS_0.127)(64bit) for package: elfutils
--> Processing Dependency: libasm.so.1(ELFUTILS_1.0)(64bit) for package: elfutils
--> Processing Dependency: libdw.so.1(ELFUTILS_0.122)(64bit) for package: elfutils
--> Processing Dependency: libdw.so.1()(64bit) for package: elfutils
--> Processing Dependency: libasm.so.1()(64bit) for package: elfutils
--> Running transaction check
---> Package elfutils.x86_64 0:0.137-3.el5 set to be updated
--> Processing Dependency: elfutils-libelf-x86_64 = 0.137-3.el5 for package: elfutils
---> Package elfutils-libs.x86_64 0:0.137-3.el5 set to be updated
--> Processing Dependency: elfutils-libelf-x86_64 = 0.137-3.el5 for package: elfutils-libs
--> Finished Dependency Resolution
elfutils-libs-0.137-3.el5.x86_64 from base has depsolving problems
  --> Missing Dependency: elfutils-libelf-x86_64 = 0.137-3.el5 is needed by package elfutils-libs-0.137-3.el5.x86_64 (base)
elfutils-0.137-3.el5.x86_64 from base has depsolving problems
  --> Missing Dependency: elfutils-libelf-x86_64 = 0.137-3.el5 is needed by package elfutils-0.137-3.el5.x86_64 (base)
Error: Missing Dependency: elfutils-libelf-x86_64 = 0.137-3.el5 is needed by package elfutils-0.137-3.el5.x86_64 (base)
Error: Missing Dependency: elfutils-libelf-x86_64 = 0.137-3.el5 is needed by package elfutils-libs-0.137-3.el5.x86_64 (base)
 You could try using --skip-broken to work around the problem
 You could try running: package-cleanup --problems
                        package-cleanup --dupes
                        rpm -Va --nofiles --nodigest
The program package-cleanup is found in the yum-utils package.

Does yum tell me that it is actually impossible to install the rpm-build package?

My answer:


It’s best to build the source RPM with rpmbuild, or better yet with mock as this tool will keep the build environment clean and separate from the system it’s running on, by performing everything in a chroot.

This does not need to be done on the actual system which the final RPMs are intended for; you can always spin up a virtual machine running the same target operating system and perform the build on that.

And if you can’t, there is always the new COPR service from the Fedora Project. This build service lets you submit source RPMs for EL 5, 6, 7, and current versions of Fedora, builds them on Fedora servers, and creates yum repositories which you can then use directly. It’s very similar in functionality to the PPA service from Ubuntu.

Of course, since this is a package which came with the OS distribution, you could simply install the existing binary packages which you can find on any CentOS mirror.


Ultimately, though, the problem here is that your yum configuration has some package exclusions which are probably inappropriate. Inspect the /etc/yum.conf and files in /etc/yum.repos.d to determine where these exclusions are, and then remove them. Oh, and you probably also need to re-enable the updates repo.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.