I am trying to build gcc version 10.00.1 from source with debugging flags to enable some functions such as methods from the STL to be able to print in GDB. Right now GDB will say things such as "cannot find method std::stringstream::str" even when I have the -g3 flag on when compiling my program.
The documentation of gcc says to configure the application using the --enable-libstdcxx-debug flag to be able to enable this support. I decided to build the application with the same flags my distro configured gcc with which are
-v --with-pkgversion='Debian 9.2.1-28' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-mutex
after a successful make and make install I still have the same problem with GDB not finding the methods. I decided to build libstdc++ by itself with just the --enable-libstdc++-debug flag. But I cannot find where the libstdc++.so.6 file anywhere in the build. I have not ran a make install yet either as I do not want to break my system. Where should the libstdc++.so.6 be located in the build? Thanks
I have not ran a make install yet either as I do not want to break my system.
Use --prefix option to configure to specify an alternative install location to avoid replacing your system gcc.
I decided to build libstdc++ by itself with just the --enable-libstdc++-debug flag.
Make sure you make clean after re-configure, so that make rebuilds it with the new compiler and linker flags.
Related
I am trying to build MinGW-w64 on Windows, I have downloaded MinGW-w64 and GCC-12.2.0 source code and I used Msys2 as an environment, and followed these steps on this link: How to build mingw-w64
and I built it statically successfully and I can creating programs with it,
my problem is when try to build it as static and shared, and when I built it, and trying to test it with a simple HelloWorld program I am getting this error:
c:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/12.2.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lgcc_s: No such file or directory
c:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/12.2.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lgcc_s: No such file or directory
collect2.exe: error: ld returned 1 exit status
and this is my configuration:
../src/gcc/configure --prefix=/mingw32 --with-sysroot=/mingw32 --build=i686-w64-mingw32 --host=i686-w64-mingw32 --target=i686-w64-mingw32 --with-pkgversion='Built by Dahy Alla
m Ali' --enable-languages=c,c++ --enable-shared --enable-static --enable-libstdcxx-filesystem-ts --enable-libstdcxx-time --enable-threads=win32 --enable-plugins --enable-libatomic --enable-ful
ly-dynamic-string --enable-checking=release --enable-version-specific-runtime-libs --enable-lto --enable-bootstrap --disable-multilib --disable-win32-registry --disable-sjlj-exceptions -disabl
e-libstdcxx-pch --disable-libstdcxx-verbose --disable-rpath --disable-nls --disable-werror --with-arch=i686 --with-gnu-ld --with-gnu-as --with-boot-ldflags=-static-libstdc++ --with-stage1-ldfl
ags=-static-libstdc++
Please help me, and sorry for my English, and I am new to Stackoverflow.
I tried solve it, but I couldn't.
I found the recent version of CLion come bundled with MinGW. However, it seems that LTO (Link Time Optimization) is disabled (--disable-lto). Could anyone tell me why? Thx.
C:\Program Files\JetBrains\CLion 2021.1\bin\mingw\bin>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
Target: x86_64-w64-mingw32
Configured with: ../gcc-11.2.0/configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --build=x86_64-alpine-linux-musl --prefix=/win --enable-checking=release --enable-fully-dynamic-string --enable-languages=c,c++ --enable-libatomic --enable-libgomp --enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes --enable-seh-exceptions --enable-shared --enable-static --enable-threads=posix --enable-version-specific-runtime-libs --disable-bootstrap --disable-graphite --disable-libada --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-libquadmath --disable-lto --disable-nls --disable-multilib --disable-rpath --disable-symvers --disable-werror --disable-win32-registry --with-gnu-as --with-gnu-ld --with-system-libiconv --with-system-libz --with-gmp=/win/makedepends --with-mpfr=/win/makedepends --with-mpc=/win/makedepends
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.2.0 (GCC)
We made it pretty minimal to be able to compile simple projects like "Hello, world!" and that's it. It also does not include any tooling like MSYS2, so it's even not possible to install additional development libraries there.
When I use -fsanitize=address to link some object into a binary, g++ says the two lib in the title do not exist.
My g++ version is:
$ /opt/rh/devtoolset-2/root/usr/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/opt/rh/devtoolset-2/root/usr/bin/g++
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-2/root/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/opt/rh/devtoolset-2/root/usr --mandir=/opt/rh/devtoolset-2/root/usr/share/man --infodir=/opt/rh/devtoolset-2/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,fortran,lto --enable-plugin --with-linker-hash-style=gnu --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/cloog-install --with-mpc=/builddir/build/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/mpc-install --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC)
Do I need to manually compile libasan if I use g++?
Sanitizer runtimes typically come in a separate package. E.g. on Debian you'll need to install libasanN ("N" depends on your GCC version).
I can not compile a simple c program without specifying '-march=native', I need to run it as: 'gcc -march=native -o hello hello.c'.
I did:
export CFLAGS='-march=native'
export CXXFLAGS='-march=native'
but didn't help.
user#server:~$ gcc -march=native -Q --help=target
...
-march=corei7-avx
...
Output of gcc -v:
user#server:~$ gcc -v
Using built-in specs.
gcc: error: missing argument to ‘-march=’
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Debian 4.7.2-5)
Where and how can I add this option to be default?
Two options:
Hard way. You may dump your specs file with gcc -dumpspecs > specs
command. Now put this file to /usr/lib/gcc/x86_64-linux-gnu/4.7/
folder and edit it to add option as described in documentation.
In your case I suggest to start from removing all
march=<something> lines, this might trivially help. But general case is troubles and creativity at this point.
Easy way: rename gcc binary to, say gcc-4.7 and make alias with
alias gcc='gcc-4.7 -march=native'
I have installed gcc-4.6.2 from source, but it can't build 32bit program, it seemed doesn't have 32bit lib. error report by gcc:
/usr/local/gcc-4.6.2/lib/gcc/x86_64-redhat-linux/4.6.2/crtbegin.o: could not read symbols: File in wrong format
my gcc-4.6.2 config is:
Target: x86_64-redhat-linux
Configured with: ../gcc-4.6.2/configure --prefix=/usr/local/gcc-4.6.2 --mandir=/usr/share/man --infodir=/usr/share/info --enable-bootstrap --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --enable-languages=c,c++ --with-gmp=/usr/local/gmp-5.0.1 --with-mpfr=/usr/local/mpfr-2.4.2 --with-mpc=/usr/local/mpc-1.0.1 --without-ppl --without-cloog --with-arch-32=i686 --build=x86_64-redhat-linux --disable-multilib
Thread model: posix
Configure and build gcc with:
--enable-multilib --with-multilib-list=m32,m64
Once you install it, you can then compile for 32-bit by passing the "-m32" option to gcc. Note that you will also need 32-bit versions of all needed libraries (like glibc.)