https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66027
--- Comment #4 from JD <t at sharklasers dot com> --- Removing the -O3 flag from the first two invocations changes the behavior: g++ -std=c++14 -c -fPIC -march=native -flto -fuse-linker-plugin -fno-fat-lto-objects ASTContext_preproc.cpp -o ASTContext_preproc.o g++ -std=c++14 -c -fPIC -march=native -flto -fuse-linker-plugin -fno-fat-lto-objects ASTConsumer_preproc.cpp -o ASTConsumer_preproc.o ar cru libAST.a ASTContext_preproc.o ASTConsumer_preproc.o g++ -flto=4 -std=c++14 -march=native -fuse-linker-plugin -shared -o bla.so CIndex_preproc.cpp libAST.a /usr/bin/ld: /tmp/ccPyzc8a.ltrans0.ltrans.o: relocation R_X86_64_32 against `_ZZN4llvm11isa_impl_clIN5clang24OMPThreadPrivateDeclAttrEPKNS1_4AttrEE4doitES5_E19__PRETTY_FUNCTION__.lto_priv.73' can not be used when making a shared object; recompile with -fPIC /tmp/ccPyzc8a.ltrans0.ltrans.o: error adding symbols: Bad value collect2: error: ld returned 1 exit status Adding the -fPIC flag as told makes the example compile successfully with and without -O3. --------------------- Removing the -march=native flags causes a compilation error: g++ -std=c++14 -c -fPIC -O3 -flto -fuse-linker-plugin -fno-fat-lto-objects ASTContext_preproc.cpp -o ASTContext_preproc.o g++ -std=c++14 -c -fPIC -O3 -flto -fuse-linker-plugin -fno-fat-lto-objects ASTConsumer_preproc.cpp -o ASTConsumer_preproc.o ar cru libAST.a ASTContext_preproc.o ASTConsumer_preproc.o g++ -flto=4 -std=c++14 -fuse-linker-plugin -shared -o bla.so CIndex_preproc.cpp libAST.a In file included from gcc5.1/lib64/gcc/x86_64-unknown-linux-gnu/5.1.0/include/x86intrin.h:27:0, from gcc5.1/include/c++/5.1.0/x86_64-unknown-linux-gnu/bits/opt_random.h:33, from gcc5.1/include/c++/5.1.0/random:50, from gcc5.1/include/c++/5.1.0/bits/stl_algo.h:66, from gcc5.1/include/c++/5.1.0/algorithm:62, from llvm/include/llvm/ADT/StringRef.h:13, from CIndexer.h:19, from CIndex.cpp:15: gcc5.1/lib64/gcc/x86_64-unknown-linux-gnu/5.1.0/include/ia32intrin.h: In function 'unsigned int __crc32b(unsigned int, unsigned char)': gcc5.1/lib64/gcc/x86_64-unknown-linux-gnu/5.1.0/include/ia32intrin.h:63:42: error: '__builtin_ia32_crc32qi' was not declared in this scope return __builtin_ia32_crc32qi (__C, __V); ^ ... ... I added the output of gcc -march=native -Q --help=target