I've tried to build flac 1.3.1 from the tarball using GCC 4.7 and got this error:
/bin/bash ../../libtool --tag=CC --mode=compile /usr/bin/gcc-4.7 -std=gnu99 -DHAVE_CONFIG_H -I. -I../.. -I../.. -I./include -I../../include -DNDEBUG -D_FORTIFY_SOURCE=2 -DFLAC__USE_VISIBILITY_ATTR -I/usr/include -O3 -funroll-loops -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wnested-externs -Wshadow -Wundef -Wmissing-declarations -Wunreachable-code -Winline -Wdeclaration-after-statement -D_FORTIFY_SOURCE=2 -fvisibility=hidden -Wextra -c -o metadata_iterators.lo metadata_iterators.c
libtool: compile: /usr/bin/gcc-4.7 -std=gnu99 -DHAVE_CONFIG_H -I. -I../.. -I../.. -I./include -I../../include -DNDEBUG -D_FORTIFY_SOURCE=2 -DFLAC__USE_VISIBILITY_ATTR -I/usr/include -O3 -funroll-loops -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wnested-externs -Wshadow -Wundef -Wmissing-declarations -Wunreachable-code -Winline -Wdeclaration-after-statement -D_FORTIFY_SOURCE=2 -fvisibility=hidden -Wextra -c metadata_iterators.c -fPIC -DPIC -o .libs/metadata_iterators.o
libtool: compile: /usr/bin/gcc-4.7 -std=gnu99 -DHAVE_CONFIG_H -I. -I../.. -I../.. -I./include -I../../include -DNDEBUG -D_FORTIFY_SOURCE=2 -DFLAC__USE_VISIBILITY_ATTR -I/usr/include -O3 -funroll-loops -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wnested-externs -Wshadow -Wundef -Wmissing-declarations -Wunreachable-code -Winline -Wdeclaration-after-statement -D_FORTIFY_SOURCE=2 -fvisibility=hidden -Wextra -c metadata_iterators.c -o metadata_iterators.o >/dev/null 2>&1
make[5]: *** [metadata_iterators.lo] Error 1
make[5]: Leaving directory `/home/mario/audacity/flac-audacity-1.3.1/src/libFLAC'
make[4]: *** [all-recursive] Error 1
make[4]: Leaving directory `/home/mario/audacity/flac-audacity-1.3.1/src/libFLAC'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/mario/audacity/flac-audacity-1.3.1/src'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/mario/audacity/flac-audacity-1.3.1'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/mario/audacity/flac-audacity-1.3.1'
Running the compiler line without using libtool's compile mode, drops more light:
$ /usr/bin/gcc-4.7 -std=gnu99 -DHAVE_CONFIG_H -I. -I../.. -I../.. -I./include -I../../include -DNDEBUG -D_FORTIFY_SOURCE=2 -DFLAC__USE_VISIBILITY_ATTR -I/usr/include -O3 -funroll-loops -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return -Wcast-align -Wnested-externs -Wshadow -Wundef -Wmissing-declarations -Wunreachable-code -Winline -Wdeclaration-after-statement -D_FORTIFY_SOURCE=2 -fvisibility=hidden -Wextra -c -o metadata_iterators.lo metadata_iterators.c
In file included from /usr/include/stdio.h:937:0,
from metadata_iterators.c:38:
metadata_iterators.c: In function ‘read_metadata_block_data_cb_.constprop.21’:
/usr/include/i386-linux-gnu/bits/stdio2.h:282:1: error: inlining failed in call to always_inline ‘fread’: indirect function call with a yet undetermined callee
metadata_iterators.c:2146:12: error: called from here
In file included from /usr/include/stdio.h:937:0,
from metadata_iterators.c:38:
/usr/include/i386-linux-gnu/bits/stdio2.h:282:1: error: inlining failed in call to always_inline ‘fread’: indirect function call with a yet undetermined callee
metadata_iterators.c:2161:13: error: called from here
In file included from /usr/include/stdio.h:937:0,
from metadata_iterators.c:38:
/usr/include/i386-linux-gnu/bits/stdio2.h:282:1: error: inlining failed in call to always_inline ‘fread’: indirect function call with a yet undetermined callee
metadata_iterators.c:2492:13: error: called from here
Notice that flac builds just fine in the same environment if using GCC 4.8 or 4.9, so it might actually be a bug in the compiler itself.
After some investigation I found that, for some strange reason, the
-finline-functionsoption, which is implicitly added with-O3(see GCC reference), was causing the problem.Fortunately, I've also found that, at least in the local setup where I could reproduce the issue, I did not need to completely disable the -finline-functions optimization, but just to do it for small functions (whatever the compiler's heuristics things is "small enough") by passing -fno-inline-small-functions, and I haven't found a better "fix" so I'm proposing that at the moment.
Worth mentioning too that this is not an issue with gcc 4.8 either, so perhaps it's indeed a bug that might have got fixed by the many "General Optimizer Improvements" that have been incorporated with that release (see GCC 4.8 release notes here).
On a loosely related note, I found some known bugs in previous versions of GCC (like this one), so perhaps is not that an unlikely theory, after all, that this is caused by a bug in the compiler.
Based on the comments above, I'm now proposing a simple patch for configure.ac that seems to fix the issue when building with GCC 4.7.
Please review, thanks!
Applied. Thanks.