Building gcc 4.7.2 on SmartOS (and friends)

By Alasdair Lumsden on 29 Dec 2012

Building gcc 472 on Smartos

If you hit this lovely error when building gcc 4.7.2, fret not:

/bin/sh ./libtool --tag=CC   --mode=link /ws/ec-userland/components/gcc47/build/i86/./gcc/xgcc -B/ws/ec-userland/components/gcc47/build/i86/./gcc/ -B/usr/i386-pc-solaris2.11/bin/ -B/usr/i386-pc-solaris2.11/lib/ -isystem /usr/i386-pc-solaris2.11/include -isystem /usr/i386-pc-solaris2.11/sys-include    -march=i486 -mtune=i386 -fomit-frame-pointer -Wall -Werror  -Wc,-pthread -g -O2    -Wl,-M,/ws/ec-userland/components/gcc47/source/gcc-4.7.2/libitm/clearcap.map   -o libitm.la -version-info 1:0:0 -Wl,-M,libitm.map-sun -rpath /usr/lib aatree.lo alloc.lo alloc_c.lo alloc_cpp.lo barrier.lo beginend.lo clone.lo eh_cpp.lo local.lo query.lo retry.lo rwlock.lo useraction.lo util.lo sjlj.lo tls.lo method-serial.lo method-gl.lo method-ml.lo  x86_sse.lo x86_avx.lo   
libtool: link: /ws/ec-userland/components/gcc47/build/i86/./gcc/collect-ld -r -o .libs/libitm.la-1.o .libs/aatree.o .libs/alloc.o .libs/alloc_c.o .libs/alloc_cpp.o .libs/barrier.o .libs/beginend.o .libs/clone.o .libs/eh_cpp.o .libs/local.o .libs/query.o .libs/retry.o .libs/rwlock.o .libs/useraction.o .libs/util.o .libs/sjlj.o .libs/tls.o .libs/method-serial.o .libs/method-gl.o .libs/method-ml.o .libs/x86_sse.o .libs/x86_avx.o 
ld: fatal: relocation error: R_386_32: file .libs/beginend.o: section [23].rel.debug_frame: symbol .text._ZN3GTM7aa_treeIjNS_16gtm_alloc_actionEE7clear_1EPNS_7aa_nodeIjS1_EE (section): symbol has been discarded with discarded section: [11].text._ZN3GTM7aa_treeIjNS_16gtm_alloc_actionEE7clear_1EPNS_7aa_nodeIjS1_EE
make[5]: *** [libitm.la] Error 1
make[5]: Leaving directory `/ws/ec-userland/components/gcc47/build/i86/i386-pc-solaris2.11/libitm'

Simply add this lovely undocumented flag to ./configure: –disable-libitm

libitm is for transactional memory and not really needed. It seems buggered on Solaris. Unsure if this is due to a bug in Sun ld or not.