Cross-compiling source code for MIPS32 target - gcc

I have source code pack which includes eCos source, GSS-3.2.1 compiler and and GCC-toolchain. I want to compile source code for MIPS32 target CPU. The host PC is Ubuntu Linux x86/64. The 'Readme' file have short instructions for building GCC 3.2.1 and eCos library.
As was specified there, in order to compile eCos, I will need to download GCC version 3.2.1 (GCC 3.2.1). In addition, there are note: "The build instructions given here are for the default GCC target platform CPU(i686-linux). This means that the library files created here can not be loaded onto a BRCM MIPS CPU."
Whereas, I want to create files specifically for Broadcom MIPS32 CPU. (BCM33xx)
So, its not clear, how to compile source code for embedded MIPS32 CPU on Linux x86/64 host PC?
Edit: Source package includes also gcc cross-compiler toolchain (gcc-toolchain.tar), containing folder tree:
/usr/local/ecos20/gnutools/mipsisa32-elf-i386-linux/
Then it's not clear does anything else is needed to compile code and all library files for MIPS32?

Related

how to run ELF 64-bit LSB executable, UCB RISC-V, version 1 (GNU/Linux), dynamically linked on Linux

I am trying to do profiling of the code written in C++ with the target Architecture RISC-V. The code has been cross-compiled using RISC-V GNU Toolchain. My executable is unit_tests "ELF 64-bit LSB executable, UCB RISC-V, version 1 (GNU/Linux), dynamically linked,nterpreter /lib/ld-linux-riscv64-lp64d.so.1, for GNU/Linux 4.15.0, with debug_info, not stripped" this information is retrieved using the file command.
What I am trying to do is the profiling of this using gprof. But to do the gprof gmon.out needs to be generated, to generate gmon.out the executable should be run first. I cannot run the binary elf of other architecture in some different architecture. I need a suggestion for this on which emulator or simulator does this for me or I can run on?
I have tried installing qemu using the follwing link:
https://www.google.com/url?q=https://risc-v-getting-started-guide.readthedocs.io/en/latest/linux-qemu.html&sa=D&source=hangouts&ust=1597422417473000&usg=AFQjCNERr6pHYmj0SU6an3WkBRGQI52aTw
but not able to successfully install it.
Also have tried with spike but got "bad synccall" error. Any leads how can I resolve this issue.
I solved this issue using qemu in user mode. Following the instructions in the below link:
Manual-qemu-user
Where I could run the binary elf generated for target RISC-V, which I could run on x86 Linux machine.

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 get old toolchain for Linux

We have a project that was working fine in Red Hat Enterprise Linux Server release 6.2. Since GCC version is getting updated periodically, we wanted to have our project to be independent of GCC upgrade in local system. Hence we wanted to keep GCC toolchain (binaries and libraries) in our project rather than standard location in the machine. ldd of our binaries generated out of our project should depend on the libraries in my our project not from the gcc libraries available in local system (because it might change at any time).
How do I do that? Where I shall get specific GCC toolchain for intel 64 bit (C & C++ compilers) ?
Current GCC Version: gcc-4.4.6-3.el6.x86_64

gcc arm-none-eabi binaries don't run

I build a cross compile toolchain on OSX with:
binutils-2.23.52
gcc-4.6.4
gcc-core-4.6.4
gcc-g++-4.6.4
gdb-7.6.1
gmp-4.3.2
mpc-1.0.1
mpfr-2.4.2
newlib-2.0.0
for the target EFM32 wich is a ARM Cortex-m3, so the gcc target is arm-none-eabi.
All compiled fine.
But making programs with this toolchain like blink.c don't actually run on the EFM32 board.
I checked the blink.bin I did with a binary created with a IAR commercial toolchain delivered in the demos from energymicro, also gcc based and the they look very different internally (as expected :).
So has my toolchain wrong libs/versions or is it simply a matter of gcc/ld/ar switches wrong and what would be the steps to systematicly analyse this?

Is it possible to build gcc statically using buildroot?

I am using buildroot to build a fresh gcc cross-compiler on a dedicated machine.
It worked fine, but I now need to run this gcc from another machine, on which I have not the same libc version :-(. Of course gcc then crashed.
Is it possible to build gcc statically using buildroot ?
You could try passing -static to the linker (via LDFLAGS), but be aware that full static linking is not supported by glibc anymore (resp. it needs a glibc build which supports static linking).
This is due to the fact that nss libraries (name server switch) will be loaded dynamically (unless you compile your own glibc - but that defeats the purpose of nss). This might be enough for you however to reduce dependencies against system libraries.
But I could assume that a statically linked gcc is fairly huge - this might result in long startup times.
If your objective is only to make a relocatable toolchain, statically link with expat, gmp, mpfr and mpc should enough. You can simply apply https://patchwork.ozlabs.org/patch/359841/

Resources