From Fedora Project Wiki

Line 118: Line 118:


<code>
<code>
 
* Info ./gold-rebuild started
* Warning Mock will be run as root, this is not recomended
* Info Fedora release: 12 | target: x86_64
* Info We will build latest binutils tarball and create repo from build RPMs
* Info Download latest Fedora (rawhide) binutils SRPM which we use as base for new RPMs
warning: user mockbuild does not exist - using root
[SPAM]
warning: group mockbuild does not exist - using root
* Info Download latest binutils tarball (18 MB)
2010-03-08 10:35:44 URL: ftp://ftp-stud.fht-esslingen.de/pub/Mirrors/sourceware.org/binutils/snapshots/binutils.tar.bz2 [18746729] -> "/home/newman/rpmbuild/SOURCES/binutils.tar.bz2" [1]
* Info Repository will be now: disabled
* Info Creating binutils RPMs
* Info Copy binutils RPMs to new repository
* Info Creating repository out of new RPMs
* Info Repository will be now: enabled
* Info PASS: binutils-2.20.51-0.20100308.17.fc12 built
* Info Download SRPM packages: hardlink
* Info Looking for duplicate packages, like two kernel SRPMs
* Info [ PACKAGES hardlink REBUILD ]
* Info ld: CVS snapshot from date: 20100308
* Info gcc: gcc-4.4.3-4.fc12 (likely, just a guess)
* Info kernel: Linux assam 2.6.32.9-67.fc12.x86_64 #1 SMP Sat Feb 27 09:26:40 UTC 2010  x86_64 x86_64 x86_64 GNU/Linux (from this machine)
* Info [1/1]
* Info Package:  hardlink-1.0-9.fc12
* Info Time:      3:08.32
* Info Size:      28K
* Info Status:    PASS
==============================================
* Info TOTAL: 1 PASS: 1 FAIL: 0
* Info Compressing /tmp/gold/reports/gold-2010-03-08-trunk-20100308-x86_64 to tar.xz to save some space and moving to /tmp/gold/reports/archive
tar: Removing leading `/' from member names
* Info Repository will be now: disabled
* Info ./gold-rebuild finishing with exit code: 0
</code>
</code>

Revision as of 09:50, 8 March 2010

Introducing GNU gold

Gold is a linker for ELF files. It was added to binutils March, 2008 and first released in binutils version 2.19. Gold is developed by Ian Lance Taylor and a small team at Google with participation of general GNU community. The motivation for writing gold was to make a linker that is faster than the GNU linker, especially for large applications coded in C++. Gold is known to work on x86 and x86-64, PowerPC (partially) and ARM. Gold is intended to link faster but may not support that much architectures as original GNU ld does however distributions, like Fedora, which primary supports GNU gold supported architectures may make it default linker in the future.

gold`s state in Fedora

GNU gold is in Fedora since binutils 2.19 release but was not built until recently. In binutils-2.20.51.0.2-7 (F-13/rawhide that time) we build gold as alternative linker to ld. Via /usr/sbin/alternatives we have /usr/bin/ld which is symbolic link to either /usr/bin/ld.bfd (original ld), or /usr/bin/ld.gold. By default /usr/bin/ld links to BFD ld but altering spec file is easily possible.

Before Fedora may uses gold as primary linker, several things have to be assured

  • gold is stable and feature full, so linked apps generally work,
  • gold is supported and available for Fedora-supported architectures,
  • gold gives speed benefits, and
  • Fedora application stack is capable of being linked by gold

gold-rebuild script

Basics

gold-rebuild is a Bash script which utilizes Mock, rpm-build, createrepo, yum and gold itself to rebuild, hence the name, Fedora packages or even whole comps groups and link resulted object files with gold instead of ld. For this purpose builds daily binutils CVS snapshot from trunk as part of Rawhide binutils SRPM and installs resulted new binutils packages to repository reachable by Mock. If rebuild of particular package fails it`s logged and failure is guess-classified to state what might be the problem.

General Capabilities

Usage: gold-rebuild [OPTION]...
Link programs with gold linker.

  -c, --color              Output in colors.
  -r, --rebuild            Rebuild current binutils snapshot,
                           create Yum for Mock repository and use it.
                           Without --rebuild we use distribution binutils.
  -g, --group <GROUP>      Select Fedora comps GROUP to rebuild.
  -p, --package <P1,...>   Comma separated list of packages to
                           rebuild. Mutual exclusive with '-g'.
  -t, --target <ARCH>      Target arch (e.g. i686 at x86_64 box).
  -o, --os-release <OS>    Fedora release from which to take
                           packages (e.g. 12, 13, ...).
  -h, --help               Display this help and exit.
  -v, --version            Output version information and exit.
  -q, --quiet              Be as quiet much as possible.
  -d, --debug              Be as verbose as possible.
Examples:
  gold-rebuild -c -r          Run with colors enabled as well as with
                              rebuild on.
  gold-rebuild                Run with defaults (colors=off, etc).

Report gold-rebuild bugs to mnowak@redhat.com
gold-rebuild home page: <http://mnowak.fedorapeople.org/gold-rebuild/>

Linear description of how-it-works

Code should be well commented so you shouldnt have much problems reading and understanding it

  1. First we parse options and set several variables determining whether we are "quiet" or "verbose", building whole comps group or just several packages, etc.
  2. If script is asked for rebuild of binutils from CVS, it
    1. Downloads latest binutils package from Koji and installs it on localhost
    2. Gets binutils.tar.bz2 and places it to RPM SOURCES/ directory
    3. Several necessary edits to Rawhides specfile is necessary - Version and Release fields are bumped to include snapshot date, recent upstream incorporated patches are turned off (one has to specify them in sources now...)
    4. SRPM package is built and we hand it to mock for rebuild
    5. binutils packages are built and placed into shiny new repository, createrepo is ran on it
    6. repository is added (if necessary) and enabled to be on for other packages when are being rebuilt
  3. Selected SRPM packages for rebuild and linage by gold are downloaded to cache, dupes are removed
  4. Logging facilities are being set
  5. Script now iterates for every SRPM package
    1. Mock is asked to rebuild package $PK1
    2. Log is archived for later investigation
    3. If rebuild passed - good for us! - size of produced packages and time spent are logged, otherwise script investigates roots of the problem
      1. Last lines from log are being removed known to be bogus lines (such as ^ *user or ^ *group or ^make[[0-9]*]: [LE].*), actually last 15 lines are being inspected.
      2. Error classification.
    4. When error type is guessed, error message is written out
  6. After all packages passed or failed to build'n'link statistics is produced (e.g. TOTAL: 99 PASS: 84 FAIL: 15)
  7. As last step, all logs are archived

Classification looks like this

 err_component
   PKG    - problem in package
   LD     - problem in linker
   GCC    - problem in GCC
   FEDORA - e.g. we build i386-only package on PPC
 err_type
   $various

How does it look like?

Quiet package rebuild

Failed rebuild
  • ./gold-rebuild --quiet --color --rebuild --package kernel

* Info		./gold-rebuild started
* Warning 	Mock will be run as root, this is not recomended
* Info		Fedora release: 12 | target: x86_64
* Info		We will build latest binutils tarball and create repo from build RPMs
* Info		Download latest Fedora (rawhide) binutils SRPM which we use as base for new RPMs
warning: user mockbuild does not exist - using root
[SPAM]
warning: group mockbuild does not exist - using root
* Info		Download latest binutils tarball (18 MB)
2010-03-05 15:04:40 URL: ftp://ftp-stud.fht-esslingen.de/pub/Mirrors/sourceware.org/binutils/snapshots/binutils.tar.bz2 [18738162] -> "/home/newman/rpmbuild/SOURCES/binutils.tar.bz2" [1]
* Info		Repository will be now: disabled
* Info		Creating binutils RPMs
ERROR: Exception(/home/newman/rpmbuild/SRPMS/binutils-2.20.51-0.20100305.17.fc12.src.rpm) Config(fedora-12-x86_64) 7 minutes 15 seconds
ERROR: Command failed. See logs for output.
 # ['bash', '--login', '-c', 'rpmbuild -bb --target x86_64 --nodeps builddir/build/SPECS/binutils.spec']
* Error 	Failed to build binutils snapshot from Fri Mar  5 15:12:06 CET 2010
* Info		Repository will be now: disabled
* Info		./gold-rebuild finishing with exit code: 1

Passed rebuild
  • ./gold-rebuild --quiet --color --rebuild --package hardlink

* Info		./gold-rebuild started
* Warning 	Mock will be run as root, this is not recomended
* Info		Fedora release: 12 | target: x86_64
* Info		We will build latest binutils tarball and create repo from build RPMs
* Info		Download latest Fedora (rawhide) binutils SRPM which we use as base for new RPMs
warning: user mockbuild does not exist - using root
[SPAM]
warning: group mockbuild does not exist - using root
* Info		Download latest binutils tarball (18 MB)
2010-03-08 10:35:44 URL: ftp://ftp-stud.fht-esslingen.de/pub/Mirrors/sourceware.org/binutils/snapshots/binutils.tar.bz2 [18746729] -> "/home/newman/rpmbuild/SOURCES/binutils.tar.bz2" [1]
* Info		Repository will be now: disabled
* Info		Creating binutils RPMs
* Info		Copy binutils RPMs to new repository
* Info		Creating repository out of new RPMs
* Info		Repository will be now: enabled
* Info		PASS: binutils-2.20.51-0.20100308.17.fc12 built
* Info		Download SRPM packages: hardlink
* Info		Looking for duplicate packages, like two kernel SRPMs
* Info		[ PACKAGES hardlink REBUILD ]
* Info		ld:	CVS snapshot from date: 20100308
* Info		gcc:	gcc-4.4.3-4.fc12 (likely, just a guess)
* Info		kernel: Linux assam 2.6.32.9-67.fc12.x86_64 #1 SMP Sat Feb 27 09:26:40 UTC 2010  x86_64 x86_64 x86_64 GNU/Linux (from this machine)
		
* Info		[1/1]
* Info		Package:   hardlink-1.0-9.fc12
* Info		Time:      3:08.32
* Info		Size:      28K
* Info		Status:    PASS
		
		==============================================
* Info		TOTAL: 1 PASS: 1 FAIL: 0
* Info		Compressing /tmp/gold/reports/gold-2010-03-08-trunk-20100308-x86_64 to tar.xz to save some space and moving to /tmp/gold/reports/archive
tar: Removing leading `/' from member names
* Info		Repository will be now: disabled
* Info		./gold-rebuild finishing with exit code: 0