https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67094
Bug ID: 67094 Summary: Compiling and linking through compiler driver with '-x c++' fails to link with stream of errors Product: gcc Version: 5.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: noloader at gmail dot com Target Milestone: --- When compiling the Crypto++ library with CXXFLAGS that includes `-x c++`, the test program fails at linking. Without the CXXFLAGS, the program does not have a problem with compiling and linking. Below is the tail of linking the test program (cryptest.exe). g++ -x c++ -DNDEBUG -g2 -O3 -fPIC -march=native -Wall -Wextra -Wno-type-limits -Wno-unknown-pragmas -pipe -c dlltest.cpp g++ -o cryptest.exe -x c++ -DNDEBUG -g2 -O3 -fPIC -march=native -Wall -Wextra -Wno-type-limits -Wno-unknown-pragmas -pipe bench.o bench2.o test.o validat0.o validat1.o validat2.o validat3.o adhoc.o datatest.o regtest.o fipsalgt.o dlltest.o ./libcryptopp.a -pthread bench.o:1:1: error: stray ‘\177’ in program ELF > � @ @ � � B C ^ bench.o:1:1: error: stray ‘\2’ in program bench.o:1:1: error: stray ‘\1’ in program bench.o:1:1: error: stray ‘\1’ in program bench.o:1:1: error: stray ‘\3’ in program [stream of problems...] ********** I can't duplicate this with a simple test program, but I can offer a test case. I tried to duplicate with/without symbols, PIC, NDEBUG and optimization. To duplicate: $ git clone https://github.com/weidai11/cryptopp.git cryptopp $ cd cryptopp $ export CXXFLAGS="-x c++" $ make g++ -x c++ -DNDEBUG -g2 -O3 -fPIC -march=native -Wall -Wextra -Wno-type-limits -Wno-unknown-pragmas -pipe -c randpool.cpp g++ -x c++ -DNDEBUG -g2 -O3 -fPIC -march=native -Wall -Wextra -Wno-type-limits -Wno-unknown-pragmas -pipe -c base32.cpp ... g++ -o cryptest.exe -x c++ -DNDEBUG -g2 -O3 -fPIC -march=native -Wall -Wextra -Wno-type-limits -Wno-unknown-pragmas -pipe bench.o bench2.o test.o validat0.o validat1.o validat2.o validat3.o adhoc.o datatest.o regtest.o fipsalgt.o dlltest.o ./libcryptopp.a -pthread [stream of problems...] ********** $ uname -a Linux localhost.localdomain 4.1.3-200.fc22.x86_64 #1 SMP Wed Jul 22 19:51:58 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/5.1.1/lto-wrapper Target: x86_64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --disable-libgcj --with-default-libstdcxx-abi=c++98 --with-isl --enable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version 5.1.1 20150618 (Red Hat 5.1.1-4) (GCC)