I am trying to learn how to port GCC to new architectures. Most tutorials say that I only have to create three files named my_processor.c
my_processor.h
and my_processor.md
; however when running ./configure --target=my_processor
machine is not recognized.
Following an answer given in How to write your own code generator backend for gcc?, I added my configuration in config.sub
and ./configure
worked.
Unfortunately, when I use make
, the terminal returns an error saying
checking if mkdir takes one argument... no
*** Configuration my_processor-unknown-none not supported
Makefile:4230: recipe for target 'configure-gcc' failed
make[1]: *** [configure-gcc] Error 1
make[1]: Leaving directory 'objdir'
Makefile:905: recipe for target 'all' failed
make: *** [all] Error 2
The problem seems to be due to a bad configuration in gcc/config.gcc
, maybe because I added my architecture in a wrong place (there are multiple case ${target}, so not sure which choose) or because I am missing something.
The only information that I have found appears in https://gcc.gnu.org/onlinedocs/gcc-4.2.2/gccint/Back-End.html, but it is not complete enough.
So, how could I do to avoid this error?
GCC follows the 3-stage architecture typical of multi-language and multi-CPU compilers. All program trees are converted to a common abstract representation at the "middle end", allowing code optimization and binary code generation facilities to be shared by all languages.
DIFFERENCE BETWEEN g++ & gccg++ is used to compile C++ program. gcc is used to compile C program.
How to build libgcc. You need to invoke the all-target-libgcc and install-target-libgcc make targets while building your GCC Cross-Compiler to build and install libgcc along with your cross-compiler. A static library called libgcc. a is installed into your compiler prefix along with the other compiler-specific files.
Specify the installation directory for the executables called by users (such as gcc and g++ ). The default is exec-prefix /bin . Specify the installation directory for object code libraries and internal data files of GCC. The default is exec-prefix /lib .
Krister Walfridsson's blog has a detailed description of all the steps needed to create a new backend. The first in the series is about the 8 kinds of files to be changed or created. It's also suggested to follow the logic for a Moxie backend that might be easier to start with than risc-v.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With