2

Sometimes when I build a package from source, the resulting binaries seem to contain a reference to the build flags I'm using.

The example I'm working with is the fftw library. Here's how to download and build it.

FWIW, these lines take about ~30 seconds to execute, so give it a try.

cd /tmp
wget http://www.fftw.org/fftw-3.3.4.tar.gz
tar xf fftw-3.3.4.tar.gz
cd fftw-3.3.4
CFLAGS="-I/foo/bar" ./configure --prefix=/tmp   # We aren't going to run 'make install',
                                                # so the --prefix is unimportant.

make -j4

Now let's inspect the compiled output. Notice that the silly -I/foo/bar flag ended up in the binary itself!

$ strings .libs/libfftw3.a | grep gcc
gcc -I/foo/bar

For technical reasons not worth mentioning here (related to a package management tool), I would like to prevent that, or at least understand why it is happening, and if it is important.

BTW: This seems to happen on both Linux and OS X, for both shared and static libraries.

Stuart Berg
  • 17,026
  • 12
  • 67
  • 99

1 Answers1

0

It turns out this was specific to fftw. Thanks to @n.m. for helping me see that.

The fftw sources have a line like the following. (Simplifying here.)

// api/version.c
const char fftwf_cc[] = FFTW_CC;

And via its configure/make scripts, fftw uses something like the following build command (again, drastically simplifying here).

gcc -I/foo/bar -DFFTW_CC='"gcc -I/foo/bar"' -c api/version.c

... so no wonder it ends up getting compiled into the library.

Stuart Berg
  • 17,026
  • 12
  • 67
  • 99