GCC - 如何添加对新架构的支持?

GCC - How to add support to a new architecture?

我正在尝试学习如何将 GCC 移植到新的体系结构。大多数教程都说我只需要创建三个名为 my_processor.c my_processor.hmy_processor.md 的文件;但是,当 运行 ./configure --target=my_processor 机器无法识别时。

根据 How to write your own code generator backend for gcc? 中给出的答案,我在 config.sub 中添加了我的配置并且 ./configure 成功了。

不幸的是,当我使用 make 时,终端 returns 报错说

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

这个问题似乎是由于 gcc/config.gcc 中的错误配置造成的,可能是因为我在错误的地方添加了我的体系结构(有多个 case ${target},所以不确定选择哪个)或者因为我错过了一些东西。

我找到的唯一信息出现在https://gcc.gnu.org/onlinedocs/gcc-4.2.2/gccint/Back-End.html,但不够完整。

那么,我该怎么做才能避免这个错误呢?

Krister Walfridsson's blog has a detailed description of all the steps needed to create a new backend. The first in the series是关于要更改或创建的8种文件。还建议遵循 Moxie 后端的逻辑,这可能比 risc-v 更容易开始。