# Ports that fail with gcc45's link-time optimizer



## interfasys (Aug 14, 2010)

I just wanted to see what wasn't working with the "new" link-time optimizer and here are my findings. The goal is just to have a rough list so that people can just quickly check here in case some of their ports fail.

Should always be excluded
lang/gcc45
devel/libtool
devel/binutils

Doesn't work (default binutils)
multimedia/mp4v2
databases/mysql51-client
databases/mysql51-server
lang/python26
devel/pcre
graphics/ImageMagick
databases/db42
security/clamav
audio/opencore-amr
math/gmp
devel/icu
graphics/tiff
textproc/aspell
security/gnutls
www/apache22
lang/php52
www/rubygem-passenger
graphics/png
archivers/arj
security/libgcrypt
multimedia/schroedinger
devel/orc
security/lockdown

Changes when using *gold* (patched+recent binutils)
Now works
lang/python26 (WITHOUT GNU Threads)
security/clamav
sysutils/lsof
graphics/tiff

These don't work with the plugin
databases/mysql51-client
security/libksba
databases/memcached

Now broken
lang/perl5.12 (segmentation faults!)
multimedia/x264 (segmentation faults!)
lang/php52 (segmentation faults! mod_php can't be compiled with gcc45 at all)
Dovecot 2

The most frequent errors are:

```
/usr/local/bin/ld: error: /usr/lib/crti.o: multiple definition of '_init'
/usr/local/bin/ld: /usr/lib/crti.o: previous definition here
/usr/local/bin/ld: error: /usr/lib/crti.o: multiple definition of '_fini'
/usr/local/bin/ld: /usr/lib/crti.o: previous definition here
```


```
/var/tmp//ccn8eKnU.lto.o: No such file or directory
```


----------



## camelia (Aug 14, 2010)

Did you use only `-flto' or with `-fuse-linker-plugin'?





			
				&quot said:
			
		

> gcc45[/pman]"]If you are not using *gold* and/or do not specify -fuse-linker-plugin then the objects inside libfoo.a will be extracted and linked asusual, but they will not participate in the LTO optimization process.


----------



## interfasys (Aug 14, 2010)

Only `-flto' since `-fuse-linker-plugin' only works with gold which is not part of ports.


----------



## interfasys (Aug 22, 2010)

Added gcc45 to the list


----------



## camelia (Aug 23, 2010)

interfasys said:
			
		

> Only `-flto' since `-fuse-linker-plugin' only works with gold which is not part of ports.


There is ports/148005 for quite some time. Not to mention that -O4/-flto in Clang *requires* gold. Here is a bit messy diff that enables gold for gcc45, gcc46 and clang. I've built most of my ports with gcc45+gold. However, -flto breaks things too often and gives too little benefit so I rarely test it.


----------



## interfasys (Aug 23, 2010)

The messy diff was indeed messy , but binutils compiled.

The problems is that gcc45 doesn't work anymore (segmentation fault).


----------



## camelia (Aug 23, 2010)

Try to add --enable-threads in gcc45's Makefile or build gold without threading. But providing cmdline and backtrace on the binary built with debugging symbols would be helpful, too.


----------



## interfasys (Aug 23, 2010)

2.20.51 is too broken, it doesn't even compile with gcc base (it fails when compiling an arm file).


----------



## camelia (Aug 23, 2010)

interfasys said:
			
		

> 2.20.51 is too broken, it doesn't even compile with gcc base (it fails when compiling an arm file).


Don't use ancient toolchain in base, compile binutils (with gold) using gcc45/binutils-2.20.51 (without gold). Such is a curse of FreeBSD base that tries to remain GPLv3-free.

IIRC, gold is very buggy in binutils 2.20.1 and doesn't support many options.


----------



## interfasys (Aug 23, 2010)

I thought I had to use gcc base since gcc45 was segfaulting, but it's now fixed and binutils was compiled (with-gold without-threads).

gcc45 compiled.


----------



## interfasys (Aug 23, 2010)

camelia said:
			
		

> ...compile binutils (with gold) using gcc45/binutils-2.20.51 (without gold)...


And is there a trick to upgrade gcc45 using gcc45? Otherwise the old toolchain is used as well.


----------



## camelia (Aug 23, 2010)

Well, that's a bootstrapping step. If you want to skip it then fetch binary package of gcc45. And when you have newer compiler/assembler you can compile gcc45 with more optimization, e.g. -march=native or some gcc45-specific option.

BTW, for non-LTO specific errors use [thread=7454]old thread[/thread].


----------



## interfasys (Sep 16, 2010)

I've compiled both linkers so that incompatible apps can still be compiled by just switching linkers.
Is there a good way of doing this via a Makefile? Using the LD switch is not enough.


----------

