xenogenesi::blog
memento
3d adt android apache2 app apt aria2 build bullet cflags chromium codeigniter debian demoscene dependencies dpkg driver emulator freeglut gcc gfx git glut htaccess javascript json kernel linux make metalink minimal mysql opengl php python raspbian realtime rpi specs template toolchain update-alternatives video wifi wordpress

gcc file specs

One feature not so known about gcc are specs files

gcc -dumpspecs >spec

output the built-in specs file

If we need to add some option, compile/link flag to be used always or on some condition we can add it to the dumped spec file, example:

*link:
-rpath /opt/someroot/lib

add always the rpath to the link options, we can try the spec file with the command line:

gcc -specs=spec test.c
readelf -d a.out |grep RPATH

on startup gcc/g++ look for a spec file on the filesystem, we can guess the full path with strace and grep:

strace -fF -o /tmp/g++.log g++ test.cpp
grep specs /tmp/g++.log

if we build our toolchain we can add a configure option --with-specs=, the argument is a spec code, it isn’t shown on -dumpspecs but will be used, example:

--with-specs="%{shared:-Wl,-rpath -Wl,$(DESTDIR)/lib}%{!shared:-Wl,-rpath -Wl,$(DESTDIR)/lib}"