https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86517
--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> --- Created attachment 44397 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44397&action=edit Full reproducer As mentioned in my first commit, -shared was only used in order to reduce the test-case. I'm attaching full version that show issue with: $ rm x.a ; gcc -fPIC -c -O2 lib*.i -flto && ar rv x.a lib*.o && gcc -rdynamic -fPIE [1-9].i -c -O2 -flto && gcc -pie [1-9].o -rdynamic x.a -pthread -ldl -lxml2 -flto That works: $ rm x.a ; gcc -fPIC -c -O2 lib*.i && ar rv x.a lib*.o && gcc -rdynamic -fPIE [1-9].i -c -O2 && gcc -pie [1-9].o -rdynamic x.a -pthread -ldl -lxml2