KERNELCONFIG while building toolchain using crosstool-ng - glibc

I am trying to update our cross compiler toolchain from crosstool to crosstool-ng. We are using an old kernel and build machine. I could install and configure crosstool-ng-1.0.0 on the server and build the toolchain.
One difference that I have noticed between the output of crosstool and crosstool-ng is that the crosstool-ng is missing some of library under output folder. For example libcrypt.a, libdl.a, libnss_dns.so, libpthread.so and so on.
I have noticed that while building with crosstool we are setting KERNELCONFIG to a specific kernel configuration file. In that configuration file we have configurations like:
CONFIG_CRYPTO=y
CONFIG_CRYPTO_HMAC=ycryp
CONFIG_CRYPTO_NULL=m
CONFIG_CRYPTO_MD4=m
CONFIG_CRYPTO_MD5=y
CONFIG_CRYPTO_SHA1=y
CONFIG_CRYPTO_SHA256=m
CONFIG_CRYPTO_SHA512=m
CONFIG_CRYPTO_DES=y
Is this the reason that libraries like libcrypt are missing. In that case is there a way to set KERNELCONFIG in crosstool-ng for example as a build parameter?

All the libraries you mention are part of glibc, and the glibc build does not depend on the kernel configuration at all. You should check if you have enabled building glibc at all.

Related

Cross compilation with Buildroot

Advice on working with Buildroot cross compilation would be helpful.
I am currently using customer specific buildroot and trying to cross compile our applications using the provided toolchain. The toolchain provided by customer is in dir [...]/opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin. The toolchain from buildroot is in buildroot/output/host/usr/bin.
Previously I have worked with Yocto Project and in yocto before using cross compilation we need to install the toolchain/sdk which is generated by bitbake -c populate_sdk <image recipe> and then each time we wish to use the toolchain we need to source the environment script. Do we have similar things in buildroot? Do we need to source any environment script? And also do I need to modify anything in menuconfig? Currently the toolchain set in menuconfig is "Linaro ARM 2018.05".
Can anyone please let me know how to continue with Buildroot? My end goal is to cross-compile and generate binaries using this toolchain.
Your help will be much appreciated.
Thanks in advance.
My understanding is that you want to use an external toolchain for building BSP.
In the buildroot menuconfig navigate to Toolchain and use below settings -
Toolchain type - External Toolchain
Toolchain - Custom toolchain
Toolchain origin - Pre-installed Toolchain
Toolchain Path - here you can choose the path [...]/opt/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin
and make necessary settings for remaining toolchain settings and build.
snapshot

Issues in Cross compiling when linking GMP to GCC

Using the How To Build GCC 4.8.2 ARM Cross-Compiler, I have installed and setup everything and it works just fine as mentioned in the post i.e., I was able to cross compile a simple C code. But, when I try to compile a simple GMP code, I get this error.
fatal error: gmp.h: No such file or directory
Compilation terminated
How should I fix this? My goal is to compile a gmp program. If possible, refer me to good tutorials.
Thanks!
If you want GMP compiled for the target system (ARM), you must compile it by itself using the newly built cross-compiler, not as a part of building GCC. GMP (along with MPFR, MPC, ISL, CLooG, etc.) being placed in the GCC toplevel source directory simply means that it gets compiled and linked for the cross-compiler you're building.
Since the cross-compiler will run on the host system, GMP will also be compiled for the host system, else linking the library would fail, and you wouldn't get a cross-compiler. It may sound silly, but there are reasons for doing it this way, such as buggy prebuilt packages provided by the package manager on the host system or merely to avoid installing those libraries on the host system when all you want is the cross-compilation toolchain.

How to build mingw32-make

I've just build a gcc 5.2.0 on windows according to this material:
http://preshing.com/20141108/how-to-install-the-latest-gcc-on-windows/
Everything went well. But then I've tried to build Qt with this newly built gcc and I'm getting an error that there is no mingw32-make. Checked directory and no, there isn't one.
But then I checked previously installed gcc, which was work of TDM, downloaded from:
http://tdm-gcc.tdragon.net/
and yes, in his build there is mingw32-make.
So, the question is, how is it that he has that tool, and many other which are absent in my build are present in his?
if you create from the gcc5.2.0 source, a build then you've just created the gcc compiler with all its necessary files. e.g. gcc-5.2.0.exe, gcc.exe, g++.exe, etc.
NOT the MinGW runtime environment for gcc, which contains the mingw32-make.exe !
if you follow your link from your question here you build it with the cygwin make.exe.
It's better to download the mingw 32 binary runtime environment for gcc
or
MinGW64 runtime environment for gcc
Then you have all the files needed to work with QT.
if you want to create a mingw build from source, you need first a MinGW runtime environment then you can use that to build your own mingw32-make.exe.

Is newlib for building cross compiler for powerpc e500mc mandatory?

I am trying to build a cross compiler for PowerPC e500mc with target powerpc-e500mc-eabi. As some websites mentioned, i built an bootstrap compiler first. and then tried to compile newlib with it. But i got some error like,
/bin/sh: powerpc-e500mc-eabi-cc: command not found
I want to know, can we directly compile GCC cross compiler without newLib. Also, can anyone tell me the exact pre-requisites for powerpc e500mc architecture. I have GMP, MPC, MPFR, BinUtils not sure whether newLib required or not.
You can build gcc without any C library, there is no need for newlib. Please find a list of dependencies from a crosstool-ng build below.
1. Alternatives
You can build everything manually, what you obviously attempted to do. This is possible but there are various constraints to keep in mind, for instance builds might fail if your filesystem is not case sensitive or if you build inside your source directory. Besides all the dependencies and their versions.
You let crosstool-ng build your cross toolchain. Crosstool-ng is mostly self-contained with few external dependencies. It will download and build all dependencies in the right versions for you, and it comes with various sample configurations. It will check for obstacles like a case insensitive filesystem. It lets you configure your cross toolchain in a similar way you configure a Linux kernel. I've built various cross toolchains by means of it for several years on several host systems without trouble, including Linux, OS X (homebrew) and Windows (cygwin). You find it here: http://crosstool-ng.org/.
I'm going to line out the steps that it takes to build a cross toolchain by means of crosstool-ng. I tested this setup on Windows (cygwin) today with the crosstool-ng from git.
2. Download crosstool-ng, build and install it.
Follow the steps in
docs/2 - Installing crosstool-NG.txt.
3. Configure your cross toolchain.
Follow the steps in
docs/3 - Configuring a toolchain.txt.
4. Example
mkdir powerpc-e500v2-eabi
cd powerpc-e500v2-eabi
ct-ng powerpc-e500v2-linux-gnuspe
The last step will create a configuration from a sample which I thought is similar enough to what you want. In the next step, we will adapt this configuration, the criteria are
no operating system
no C library
EABI
you want e500mc, the sample is e500v2. I leave it up to you to adapt the configuration to it.
4.1. Configuration
ct-ng menuconfig
Operating System
Target OS
Select bare-metal
C-library
C library
Select none
Target options
ABI
Select EABI
C-Compiler
gcc version
Select 5.1.0 (the sample configured a gcc 4.6.4
here)
Deselect C++ (since you do not want a C library
either and it'd pull extra dependencies)
Debug facilities
Deselect gdb (unless you want it, can pull extra dependencies)
4.2. Build
ct-ng build.4
Crosstool-ng will download and build the following dependencies.
gmp-6.0.0a
mpfr-3.1.2
isl-0.14
mpc-1.0.2
binutils-2.25
gcc-5.1.0
It will install the cross toolchain in
${HOME}/x-tools/powerpc-e500v2-eabi.
You can specify a different install prefix in the configuration.
This build issue can be fixed by creating a symlink powerpc-e500mc-eabi-cc pointing to powerpc-e500mc-eabi-gcc.

How to find configure option/glags used to create makefile for the gcc I'm using?

I have got the mips-gcc toolchain source code and binaries from some chipset maker. I want to build the source of toolchain but I don't know the configure options/flags that were used to build the source. Is there any way so that I can get these options flags ?
Try gcc -v.
This should give you the configure parameters.

Resources