Re-discovered in https://github.com/gentoo-haskell/gentoo-haskell/issues/1110. PR12291 tracks support for mixed LTO/non-LTO objects. While it's not implemented should ld complain about data loss when partial linking is used? gcc's man page suggest it should but I'm not sure if it's ld's problem or gcc's linker plugin problem. gcc's manpage says: ``` -flinker-output=type During the incremental link (by -r) the linker plugin defaults to rel. With current interfaces to GNU Binutils it is however not possible to incrementally link LTO objects and non-LTO objects into a single mixed object file. If any of object files in incremental link cannot be used for link-time optimization, the linker plugin issues a warning and uses nolto-rel. To maintain whole program optimization, it is recommended to link such objects into static library instead. Alternatively it is possible to use H.J. Lu's binutils with support for mixed objects. ``` Example session (models upstream bug): $ cat a.c void a(void) {} $ cat b.c void a(void); /* from non-lto */ int main(void) { a(); } $ LANG=C bash -x ./mk.bash + x86_64-pc-linux-gnu-gcc-11.0.0 -c a.c + x86_64-pc-linux-gnu-gcc-11.0.0 -flto -c b.c + x86_64-pc-linux-gnu-gcc-11.0.0 a.o b.o -o o1 + x86_64-pc-linux-gnu-ld -r a.o b.o -o o.o + x86_64-pc-linux-gnu-gcc-11.0.0 -flto o.o -o o2 /usr/lib/gcc/x86_64-pc-linux-gnu/11.0.0/../../../../x86_64-pc-linux-gnu/bin/ld: /tmp/ccHmkp4T.ltrans0.ltrans.o: in function `main': <artificial>:(.text+0x5): undefined reference to `a' collect2: error: ld returned 1 exit status Note: `x86_64-pc-linux-gnu-ld -r a.o b.o -o o.o` issued no warnings. Thanks!
Please provide feedbacks for https://sourceware.org/pipermail/binutils/2020-October/113795.html