How to build binutils for a specific target - gcc

I'm trying to configure binutils for an ARM processor, specifically the ARMv5TE. The processor is the Marvell 88F5281. Presently the device is running NetBSD, so I want to make sure I configure binutils for the right target arch / OS.
Is there a way to list a combination of targets / OSes when configuring binutils?
So far I found, arm-*-netbsdelf from the following page, http://gcc.gnu.org/install/specific.html#arm-x-eabi
But I am still wondering if there is a list of targets / OSes when I run the configure script from the command line.

A good place to start might be the NetBSD build.sh, which is designed to build a complete cross compiler toolset for a NetBSD target on a POSIX host.
Download and extract the source tree for the NetBSD version your target is running
Run './build.sh -m evbarm tools'
When completed it should tell you where to find built binutils and cross compiler
Note - if the target is bigendian you will need to use evbarm-eb in the build.sh command.

Related

GCC Cross Compiler for linux under msys2

I'm looking for a cross compiler to compile for linux under the msys2 environment.
I'm looking for somethink like x86_64-w64-linux-gcc. But I can't find it.
Which package I have to install?
You'll need a VM or a Linux machine to test the resulting binaries, so I'd just compile on one in the first place.
But cross-compilation should be possible too:
Boot up your favorite Linux distribution in a VM.
Install the libraries you want to have. Install g++ to get libstdc++, and possibly other basic libraries.
Copy the root directory / from the VM to the Windows machine.
You only need headers and libraries, not everything. You'll have to experiment to know what directories can or can't be safely removed.
Install Clang on the Windows machine. Installing LLD is also a good idea (it's a separate package in MSYS2; or, if you're using the official Clang binaries, it's bundled with them).
We're using Clang, because it's inherently a cross-compiler, i.e. doesn't require separate binaries to target a different platform, unlike GCC.
Compile with Clang with --target=x86_64-pc-linux-gnu --sysroot=path/to/root/directory.
-fuse-ld=lld is probably a good idea as well.
The string x86_64-pc-linux-gnu was obtained by running clang++ --version on a Linux machine.
You might need a few more flags, but this should be a good starting point.

Gcc address sanitizer offline

I'm using GCC 4.8.1 with address sanitizer option turned on, i.e. I'm compiling and linking using -fsanitize=address. With this old version GCC doesn't provide a worth output. It needs a symbolizer. No need for extra applications on newer versions. I can't install LLVM packages on target machine, so my question is: is it possible to perform the analysis offline? I mean: can I get the output from the target machine and then analyze the result using symbolizer on the development machine?
You can pipe unsymbolized output of sanitized executable to asan_symbolize script, either on target or on development machine.
Note that by default asan_symbolize tries to locate symbols in executables on machine it's run on. When if target and development executables do not match you'll need to use -s flag to specify target sysroot.

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.

Tools for Linux 2.6.39 Compilation

I have started working on linux for about 6 months or so and now I
wanted to compile Linux version 2.6.39. Here are my questions for
the upgrade :
a. How will I get the GCC, Make, BinUtil and other tool dependency
of linux with their versions.
b. After compiling the tools how to make toolchain for linux
compilation.
I have searched various websites for this. I got information in bits and pieces and for specific linux versions. Is their a site or something where I can get all the information about the upcoming linux upgrades with the details.
My Current Linux machine details are :
Distro : CentOS 4.8
Linux version : 2.6.9
Gcc Version : 3.4.6
Binutils : 2.15.92
Make : 3.80
-Tommy
There are 2 options, depending on that type of kernel you want to build:
If you want a kernel for your machine (or a similar one), you can use the GCC that you already have from your distro.
If you want a kernel for another architecture (like ARM, MIPS, etc) you NEED a cross-compiler. You can build a cross-compiler (a whole toolchain, actually) using something like crosstool-ng.
With crosstool-ng you can also build yourself a toolchain for the first case. This tool take care of downloading the tarballs with the sources for GCC, Binutils, glibc, etc.
If you just want to upgrade the kernel on your machine, regardless of the version, the steps are mostly the same:
Get the source with
wget https://www.kernel.org/pub/linux/kernel/v3.0/linux-3.2.9.tar.bz2 or something similar
extract them with tar xjvf linux-*.tar.bz2 and then exter that folder
make oldconfig or make menuconfig or even better make localmodconfig
make
make install as root

Build software on Linux using cross toolchain

Motorola provides a cross compiling toolchain for building Software for their Set Top Box VIP1710. You have to extract it to /usr/local/kreatel and there you have a tree of build tools:
./bin
./bin/mipsel-kreatel-linux-gnu-addr2line
./bin/mipsel-kreatel-linux-gnu-ar
./bin/mipsel-kreatel-linux-gnu-as
./bin/mipsel-kreatel-linux-gnu-c++
./bin/mipsel-kreatel-linux-gnu-c++filt
./bin/mipsel-kreatel-linux-gnu-cpp
./bin/mipsel-kreatel-linux-gnu-g++
./bin/mipsel-kreatel-linux-gnu-gcc
...
./include
./lib
Now how do I make those configure scripts using my cross-compiling tools instead of my systems' gcc?
the --host parameter to configure, like this
./configure --host=arm-9tdmi-linux-gnu
where arm-9tdmi-linux-gnu is the identfication of the target system in my case - you can have multiple targets in one crosstool installation btw.

Resources