How to build a gcc multilib tool chain? - gcc

I'm trying to build a gcc multilib tool chain on AMD64 version of fresh ubuntu 14.04 installation. It only has a x86_64 gcc and g++ installation without multilib support. My configuration line is
../configure --disable-checking --enable-languages=c,c++ --enable-multiarch --enable-multilib --enable-shared --enable-threads=posix --with-system-zlib
When I make it fails somewhere around building 32bit libgcc complaining about a missing sys/cdefs.h
I can't post a build log right now but the error occurs in the folder objdir/x86_64-unknown-linux-gnu/32/libgcc/
What am I doing wrong?

Related

Building MinGW-w64 from Source code problem

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.

warnings while trying to compile old linux kernel with gcc 12.1.0

I am currently hunting a bug using git bisect in linux staging-testing tree.
Some commits are giving following errors after I try to build them:
subcmd-util.h:58:31: error: pointer may be used after ‘realloc’ [-Werror=use-after-free]
58 | ret = realloc(ptr, 1);
check.c:2867:58: error: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 9 [-Werror=format-truncation=]
2867 | snprintf(pvname, sizeof(pvname), "pv_ops[%d]", idx);
I tried adding -Wno-error=use-after-free to KBUILD_FLAGS in main Makefile, tried adding
KBUILD_CFLAGS += $(call cc-disable-warning, use-after-free)
I even tried removing -Werror from CFLAGS in Makefile in folder where problematic files are located, but nothing worked.
More information:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.artixlinux.org/ --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror --with-build-config=bootstrap-lto --enable-link-serialization=1
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.1.0 (GCC)
Linux staging tree: git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git.
One of the commits that gives following warnings: 2ab9c9675fe892e7fe9fa8c0a6125e2b40d2889d.
To compile older version of kernel I needed older compiler ("Linux kernel sources are in general not forward-compatible with new compilers"). In my case the kernel version was 5.16.0 and I could compile it with gcc 11. If you have gcc 11 specific warnings then try gcc 10 and so on.
Except CC flags, I also needed set to HOSTCC flags to use gcc-11 compiler:
make HOSTCC=gcc-11 CC=gcc-11

Buildroot and Crosstool-NG configuration error

Building a root filesystem on Buildroot for a Beaglebone Black target. Using a crosstool-NG toolchain with buildroot and I am getting this error in buildroot:
>>> toolchain-external-custom Configuring
Incorrect selection of kernel headers: expected 4.2.x, got 4.20.x
john#vmpc:/home/emmet/Downloads/crosstool-ng-1.24.0$ arm-cortex_a8-linux-gnueabihf-gcc -v
Using built-in specs.
COLLECT_GCC=arm-cortex_a8-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/home/emmet/x-tools/arm-cortex_a8-linux-gnueabihf/libexec/gcc/arm-cortex_a8-linux-gnueabihf/8.3.0/lto-wrapper
Target: arm-cortex_a8-linux-gnueabihf
Configured with: /home/emmet/Downloads/crosstool-ng-1.24.0/.build/arm-cortex_a8-linux-gnueabihf/src/gcc/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=arm-cortex_a8-linux-gnueabihf --prefix=/home/emmet/x-tools/arm-cortex_a8-linux-gnueabihf --with-sysroot=/home/emmet/x-tools/arm-cortex_a8-linux-gnueabihf/arm-cortex_a8-linux-gnueabihf/sysroot --enable-languages=c,c++ --with-cpu=cortex-a8 --with-fpu=vfpv3 --with-float=hard --with-pkgversion='crosstool-NG 1.24.0' --enable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp --disable-libquadmath --disable-libquadmath-support --disable-libsanitizer --disable-libmpx --with-gmp=/home/emmet/Downloads/crosstool-ng-1.24.0/.build/arm-cortex_a8-linux-gnueabihf/buildtools --with-mpfr=/home/emmet/Downloads/crosstool-ng-1.24.0/.build/arm-cortex_a8-linux-gnueabihf/buildtools --with-mpc=/home/emmet/Downloads/crosstool-ng-1.24.0/.build/arm-cortex_a8-linux-gnueabihf/buildtools --with-isl=/home/emmet/Downloads/crosstool-ng-1.24.0/.build/arm-cortex_a8-linux-gnueabihf/buildtools --enable-lto --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-threads=posix --enable-target-optspace --enable-plugin --enable-gold --disable-nls --disable-multilib --with-local-prefix=/home/emmet/x-tools/arm-cortex_a8-linux-gnueabihf/arm-cortex_a8-linux-gnueabihf/sysroot --enable-long-long
Thread model: posix
gcc version 8.3.0 (crosstool-NG 1.24.0)
Any idea how to fix this?
When using a custom external toolchain in Buildroot you have to tell Buildroot which kernel headers have been used to build the toolchain.
Just enter make menuconfig -> Toolchain -> External toolchain kernel headers series to set it.

gcc can't build 32bit program in 64bit RHEL6?

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.)

Cannot find -lgfortran though gfortran is installed [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
lgfortran not found
I must admit that my question can be considered to be very similar to lgfortran not found, but as I am a newbie in Linux I need more help and I couldn't find what I am looking for in the above post.
I have a fresh linux mint Debian edition installed and I am trying to make a lapack binding for Ada to work.
If I check for gfortran, I get:
gfortran-4.6 -v
Using built-in specs.
COLLECT_GCC=gfortran-4.6
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i486-linux-gnu/4.6/lto-wrapper
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.3-1' --with- bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --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.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --enable-targets=all --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.6.3 (Debian 4.6.3-1)
And if I locate libgfortran, I get:
/usr/lib/gcc/i486-linux-gnu/4.6/libgfortran.a
/usr/lib/gcc/i486-linux-gnu/4.6/libgfortran.so
/usr/lib/gcc/i486-linux-gnu/4.6/libgfortran.spec
/usr/lib/gcc/i486-linux-gnu/4.6/libgfortranbegin.a
/usr/lib/i386-linux-gnu/libgfortran.so.3
/usr/lib/i386-linux-gnu/libgfortran.so.3.0.0
/usr/share/doc/libgfortran3
/var/lib/dpkg/info/libgfortran3.list
/var/lib/dpkg/info/libgfortran3.md5sums
/var/lib/dpkg/info/libgfortran3.postinst
/var/lib/dpkg/info/libgfortran3.postrm
/var/lib/dpkg/info/libgfortran3.shlibs
/var/lib/dpkg/info/libgfortran3.symbols
When I run a makefile, I get:
make all
gcc -c cxbbase.ads
gcc -c cxbbase.ads
gnatmake cxbi.adb -largs ifinc.o -lgfortran -lm
gnatbind -x cxbi.ali
gnatlink cxbi.ali ifinc.o -lgfortran -lm
/usr/gnat/libexec/gcc/i686-pc-linux-gnu/4.5.3/ld: cannot find -lgfortran
collect2: ld returned 1 exit status
gnatlink: error when calling /usr/gnat/bin/gcc
gnatmake: *** link failed.
make: *** [cxbi] Error 4
The makefile that I'm using is here:
http://12000.org/my_notes/ada/lapack_and_blas/lapack_interf_makefile.txt
As I am very new to Linux, I would be very grateful if I could get detailed instructions on how to fix this.
Thank you
The solution was to /usr/lib/gcc/i486-linux-gnu/4.6 to LIBRARY_PATH. This solution is discussed here on Comp Lang Ada:
https://groups.google.com/forum/#!topic/comp.lang.ada/Ii7YljKqu5M
The versions of your GNAT and your GCC don't match. Please use the same version for both.
Your GNAT seems to be version 4.5.3, while your GCC is 4.6.3.
My guess would be that you have to update GNAT (gnat package on Debian). How did you even get your GNAT installed? Debian seems to only have 4.4 and 4.6 in the repos. Additionally, the official packages don't use /usr/gnat at all.

Resources