Visual Studio 2012 linker errors with /GL /LTCG
|Reported by:||Steve Rothkin||Owned by:|
|Blocking:||Reproduced by developer:||no|
|Analyzed by developer:||no|
Summary of the bug:
How to reproduce:
Configure and build in MSYS with ./configure --toolchain=msvc --cpu=i686 --arch=i686 --enable-shared --disable-static --disable-programs --disable-doc --disable-swresample --disable-postproc --disable-zlib --disable-bzlib --enable-runtime-cpudetect --extra-ldflags="-DEBUG -INCREMENTAL:NO -OPT:REF" --optflags="-Zi -O2 -Oy-" --extra-cflags="-I/m -MD" Linker will report errors like _ff_get_cpu_flags_ppc is not defined.
The problem is caused by source code lines like
if (ARCH_PPC) flags = ff_get_cpu_flags_ppc();
which refer to functions that aren't part of the build because they are configured out.
It seems that many compilers (including Visual Studio when not using whole program compilation and link-time optimization) recognize that the above statement is dead code and optimize it out during compile. But the Visual Studio compiler apparently leaves it in when /GL (whole program optimization) is enabled.
The solution is to change all of these blocks of code to look like this:
flags = ff_get_cpu_flags_ppc();