I am attempting to compile a program that utilises the --whole-archive flag to LD in its linking process. At the same time, I am using IPO. The program incorporates some static libraries; according to the documentation, IPO is incompatible with static libraries unless the library is archived with xiar or when -ipo_obj is used in addition to -ipo. This works well, up until the point where said library is linked against another (shared) library with the --whole-archive option. It appears that the IPO symbols are still present in the static library and because all symbols are exported, the IPO symbols cause unresolved symbol errors. Consider the following pseudo-compile:
icc -ipo -o staticlib.a objectf1.o objectf2.o
IPO: doing stuff
xiar: calling ar
icc -ipo -o biglib.so -Wl,--whole-archive staticlib.a -Wl,--no-whole-archive -lsomelib -lanotherlib
IPO: doing stuff (symbol warnings)
(ld?) ERROR: unresolved symbols ipo_XXXXXXXX in staticlib.a(...)
This seems odd. Why are the IPO symbols still present in staticlib.a? Does keeping the IPO information make the binaries extremely large? It would make more sense to use the IPO information and discarding it during the linking stage.
I've tried to use -ipo_obj in addition to -ipo, which did not seem to make a difference.
Of course, when the --whole-archive flag is omitted, the compile succeeds. But the application I am building relies on this flag to function.