I tried to compile the Linux kernel 3.10.31 on Ubuntu 16.04 LTS.
I used to compile the exact same kernel on Ubuntu 12.04 LTS, and everything works well.
On Ubuntu 16.04, the gcc version is gcc-5;
On Ubuntu 12.04, the gcc version is gcc-4.6.
It seems that the Linux kernel kernel before 3.18 cannot compile with the gcc-5. The kernel 3.10.31 reports the following error when it is compiled by make
fatal error: linux/compiler-gcc5.h: No such file or directory
I tried to install gcc-4.7 onto Ubuntu 16.04 and change the /usr/bin/gcc to point to the gcc-4.7. This could solve the above error. However, it leads to new issues after I run make
$linux/arch/x86/Makefile:98: stack protector enabled but no compiler support
make[1]: Nothing to be done for 'all'.
make[1]: Nothing to be done for 'relocs'.
CHK include/generated/uapi/linux/version.h
CHK include/generated/utsrelease.h
CC kernel/bounds.s
gcc-4.7.real: error: unrecognized command line option ‘-no-pie’
linux/./Kbuild:35: recipe for target 'kernel/bounds.s' failed
make[1]: *** [kernel/bounds.s] Error 1
Makefile:835: recipe for target 'prepare0' failed
make: *** [prepare0] Error 2
My question is:
Is there a neat way to use the old compiling chain to compile the old kernel 3.10.31 on Ubuntu 16.04?
Thank you very much for your help! Any advice is really appreciated.
I think I figured out a solution.
We don't have to install the old version gcc. We only need to copy the file compiler-gcc5.h from here or from here into include/linux/. It will solve the compilation issue.
Ubuntu 16.04 now still supports gcc-4.7 so you can install it and then you can choose the version of gcc before using it by update-alternatives.
For examples:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 40
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 50
sudo update-alternatives --config gcc # here you choose by hint
If you directly download compiler-gcc5.h, you may meet problems like arch/x86/kvm/svm.c error invalid character that I met when compiling 3.3.8 in Ubuntu 16.04.3 x64.
Open the Makefile, look for CFLAGS_EXTRA and add the following option to it -fno-pie.
See, https://askubuntu.com/questions/851433/kernel-doesnt-support-pic-mode-for-compiling.
Related
I'm trying to compile GCC version 4.8.4 using the following configuration parameters:
--prefix=<path to gcc src> --enable-languages=c,c++ --build=x86_64-linux-gnu
However, when I try to make I get the following error:
make[5]: Entering directory '/DIR/gcc/objdir/x86_64-linux
gnu/libstdc++-v3/po'
msgfmt -o de.mo ../../../../libstdc++-v3/po/de.po
msgfmt -o fr.mo ../../../../libstdc++-v3/po/fr.po
msgfmt: /DIR/gcc/objdir/x86_64-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6: version CXXABI_1.3.8 not found (required by /usr/lib/x86_64-linux-gnu/libicuuc.so.55)
Makefile:460: recipe for target fr.mo failed
make[5]: *** [fr.mo] Error 1
make[5]: *** Waiting for unfinished jobs....
msgfmt: /DIR/gcc/objdir/x86_64-linux-gnu/libstdc++-v3/src/.libs/libstdc++.so.6: version CXXABI_1.3.8 not found (required by /usr/lib/x86_64-linux-gnu/libicuuc.so.55)
Try 1: I've tried setting LD_LIBRARY_PATH to /usr/lib/x86_64-linux-gnu/:/usr/lib/lib32/. Yet it does not seem to work.
Try 2: I've tried changing the GCC version used to compile it. I've used versions 4.7, 4.5, and 5. This also does not seem to work.
It seems that when compiling GCC, the wrong libstdc++.so.6 is pull?
Any ideas or aclarations are welcome.
PS: I'm using Ubuntu 16.04 and Linux kernel 4.4.0-62
Building gcc-4.8.4 : Unpack mpfr-3.1.3.tar.xz, gmp-6.1.0.tar.xz, mpc-1.0.3.tar.gz into gcc-4.8.4/. Rename to have gcc-4.8.4/{mpfr/, gmp/, mpc/}.
gcc requires a build directory outside gcc-4.8.4/ : mkdir build-gcc
! If you configured inside gcc-4.8.4/, you will have to delete gcc-4.8.4/, and start from scratch.
cd build-gcc/
../gcc-4.8.4/configure --prefix=/usr/local/gcc484 --program-suffix=484 --enable-clocale=gnu --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-languages=c,c++ --disable-multilib --disable-libstdcxx-pch --with-mpfr-include=$(pwd)/../gcc-4.8.4/mpfr/src --with-mpfr-lib=$(pwd)/mpfr/src/.libs
make
gcc-4.8.4 can be built with Ubuntu 14.04, not 16.04 . Result: gcc48-c++_4.8.4-2ubuntu14_amd64.deb (24.4MB) https://drive.google.com/file/d/0B7S255p3kFXNeWI3N1E2MXdrVm8/view?usp=sharing
Ubuntu 16.04 : gcc48, g++48 were tested with some applications, one has 400 c++ files : OK.
No dependencies, install with sudo dpkg -i gcc48-c++_4.8.4-2ubuntu14_amd64.deb Provides /usr/local/bin/{ gcc48, g++48 }
I am compiling code to run on an arm neon and the make files have the following command line included.
-mcpu=cortex-a9 -march=armv7 -mfpu=neon -DARM_NEON
The details of GCC version are as follows:
gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
However when I try to compile, gcc keeps throwing the following error:
gcc: warning: '-mcpu=' is deprecated; use '-mtune=' or '-march=' instead
gcc: error: unrecognized command line option '-mfpu=neon'
I am pretty sure that the code could be compiled previously. Though a long time ago. Could it be changes in version of GCC? or is it do with 32 bit and 64 bit compilers?
I was trying to cross compile for an arm processor on my intel x86_64 Ubuntu machine. I needed to add the configuration for the host in the makefiles and use arm-linux-gnueabihf-gcc instead of gcc.
I can't seem to build Rust as a cross-compiler, either on Windows with MSYS2 or on a fresh install of Debian Wheezy. The error is the same for both. I run this configure:
./configure --target=arm-unknown-linux-gnueabihf,x86_64-pc-windows-gnu
make works, but then make install fails with:
[...]
prepare: tmp/dist/rustc-1.0.0-dev-x86_64-pc-windows-gnu-image/bin/rustlib/x86_64-pc-windows-gnu/lib/rustdoc-*.dll
prepare: tmp/dist/rustc-1.0.0-dev-x86_64-pc-windows-gnu-image/bin/rustlib/x86_64-pc-windows-gnu/lib/fmt_macros-*.dll
prepare: tmp/dist/rustc-1.0.0-dev-x86_64-pc-windows-gnu-image/bin/rustlib/x86_64-pc-windows-gnu/lib/libmorestack.a
prepare: tmp/dist/rustc-1.0.0-dev-x86_64-pc-windows-gnu-image/bin/rustlib/x86_64-pc-windows-gnu/lib/libcompiler-rt.a
compile: arm-unknown-linux-gnueabihf/rt/arch/arm/morestack.o
make[1]: arm-linux-gnueabihf-gcc: Command not found
/home/Sandro/rust/mk/rt.mk:94: recipe for target 'arm-unknown-linux-gnueabihf/rt/arch/arm/morestack.o' failed
make[1]: *** [arm-unknown-linux-gnueabihf/rt/arch/arm/morestack.o] Error 127
make[1]: Leaving directory '/home/Sandro/rust'
/home/Sandro/rust/mk/install.mk:22: recipe for target 'install' failed
make: *** [install] Error 2
Everything builds fine if I don't specify a cross architecture. Am I missing some special configure flag to make this work?
The error message says that make did not find the arm-linux-gnueabihf-gcc binary, which is supposed to be a C compiler producing ARM code. That means that you probably don't have any ARM C cross-compilation toolchain installed.
I know Ubuntu has packages for cross compilers (gcc-arm-linux-gnueabihf in 14.04) so Debian may have the same packages. You can also find fully packaged ARM C cross-compilers for Windows and Linux on the Linaro website. If you are building for the Rapsberry Pi, you can also find toolchains to build for Raspbian and Archlinux on https://github.com/raspberrypi/tools.
Here is an example under Linux with a Linaro toolchain (should be distribution-agnostic for the host)
$ wget http://releases.linaro.org/14.11/components/toolchain/binaries/arm-linux-gnueabihf/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf.tar.xz
$ tar -xf gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf.tar.xz
$ export PATH=$PATH:$PWD/gcc-linaro-4.9-2014.11-x86_64_arm-linux-gnueabihf/bin
$ cd <your_configured_rustc_build_directory>
$ make
You can then use the cross compiler with the following line. You can provide the full path to the arm-linux-gnueabihf-gcc binary if you don't want to put it in your PATH.
rustc --target=arm-unknown-linux-gnueabihf -C linker=arm-linux-gnueabihf-gcc hello.rs
If you are using Cargo, you can specify the linker to use for each target in the .cargo/config with this option:
[target.arm-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
I have a new installation of Ubuntu linux and I am trying to update my gcc complier. The latest gcc compiler depends on gmp, mpfr, and mpc, so I downloaded those and placed the source into the gcc 4.8.1 source folder, as instructed.
configure seems to have run just fine. I did not include any options, because none seemed appropriate. I just ran with the defaults.
When I run make, I get the following error:
configure: error: C++ compiler missing or inoperational
make[2]: \*** [configure-stage1-libcpp] Error 1
make[2]: Leaving directory `/home/clay/programming/C++/gcc-4.8.1'
make[1]: \*** [stage1-bubble] Error 2
make[1]: Leaving directory `/home/clay/programming/C++/gcc-4.8.1'
make: \*** [all] Error 2
I am running out of a terminal window as root, and I did a make distclean and tried a second time, but no dice. I know it can find both gcc and cc because it says so in the make output.
Any ideas?
You need a C++ compiler to build GCC. On Ubuntu, the C++ compiler is in the package g++, separate from gcc (which is a C compiler, not a C++ compiler), so be sure to:
sudo apt-get install g++
first you should ensure a C++ compiler to build on your machine
yum install gcc-c++
Could you please describe that how have you installed gcc-multilib and g++-multilib on 32bit debian machine to generate 64 bit code?
I installed gcc-4.7.2 on my 32bit debian system(and also installed binutils-2.23). When i try to compile a simple hello world program with -m64 flag as
# gcc -m64 hello.c
I am getting following error message:
"hello.c:1:0: sorry, unimplemented: 64-bit mode not compiled in" .
Please tell me the steps to generate the 64bit code on 32bit debian system.
You need to re-install gcc with this option in the configure.