GCC 作为 m68k 交叉编译器

GCC as m68k cross-compiler

我正在尝试将 binutils 和 GCC 重新编译为 m68k 架构的交叉编译器。我遵循这些说明:

http://darkdust.net/writings/megadrive/crosscompiler

但是,这个过程总是在一个部分或另一个部分失败。我已经尝试使用 binutils 2.16.1 和 gcc 3.4.6、binutils 2.15 和 gcc 3.4.2 以及 binutils 2.15 和 gcc 3.4.6。

当在 gcc 上 运行 "make" 时,在制作和安装 binutils 之后最后一次尝试失败。它给出以下错误:

gcc   -g -O2 -DIN_GCC -DCROSS_COMPILE  -W -Wall -Wwrite-strings -Wstrict-
prototypes -Wmissing-prototypes -pedantic -Wno-long-long    -DHAVE_CONFIG_H    
-I. -I. -I../../gcc-3.4.2/gcc -I../../gcc-3.4.2/gcc/. -I../../gcc-
3.4.2/gcc/../include   \
-DTARGET_MACHINE=\"m68k-coff\" \
-c ../../gcc-3.4.2/gcc/collect2.c -o collect2.o

In file included from /usr/include/fcntl.h:289:0,
             from ../../gcc-3.4.2/gcc/system.h:214,
             from ../../gcc-3.4.2/gcc/collect2.c:30:

In function ‘open’,
inlined from ‘collect_execute’ at ../../gcc-3.4.2/gcc/collect2.c:1535:20:
/usr/include/x86_64-linux-gnu/bits/fcntl2.h:50:4: error: call to 
‘__open_missing_mode’ declared with attribute error: open with O_CREAT or 
O_TMPFILE in second argument needs 3 arguments
__open_missing_mode ();
^
Makefile:1364: recipe for target 'collect2.o' failed
make[1]: *** [collect2.o] Error 1
make[1]: Leaving directory '/home/gabriel/src/gcc-build/gcc'
Makefile:23339: recipe for target 'all-gcc' failed
make: *** [all-gcc] Error 2

我不希望修复此错误,但有人知道 binutils 和 gcc 版本的组合有效吗?我应该使用特定版本的 gcc 来成功重新编译 gcc 吗?

感谢您对此的任何见解!

编辑:

我的 linux 有 GCC 5.4.0,所以我刚刚下载了 5.4.0 源代码来尝试重建它以进行 m68k 交叉编译。我现在在 gcc 源上 运行 "make" 时收到以下错误:

*** Configuration m68k-unkown-coff not supported

这可能是什么原因造成的?是因为我需要旧版本的 GCC 吗? (我使用的 binutils 版本肯定支持 m68k 目标)。我使用的教程总是定义“--target=m68k-coff”,应该改为“--target=m68k-unkown-coff”吗?

编辑 2:

所以我尝试为 m68k-elf 进行编译,但现在出现此错误:

checking for m68k-elf-gcc... /home/gabriel/src/gcc-build/./gcc/xgcc -B/home/gabriel/src/gcc-build/./gcc/ -B/opt/m68k/m68k-elf/bin/ -B/opt/m68k/m68k-elf/lib/ -isystem /opt/m68k/m68k-elf/include -isystem /opt/m68k/m68k-elf/sys-include
checking for suffix of object files... configure: error: in `/home/gabriel/src/gcc-build/m68k-elf/libgcc':
configure: error: cannot compute suffix of object files: cannot compile

我运行 download_prerequisites在构建之前所以它应该不是MPC库的问题。知道如何继续吗?我只需要汇编程序,所以我不介意目标文件的格式是什么。谢谢!

我过去常常做你现在正在做的事情。

我的建议是使用 crosstool-ng (http://crosstool-ng.github.io),因为它几乎可以自动完成所有工作。

如果你正在研究 m68k 汇编,我曾经托管过 Matt Godbolt (https://godbolt.org/). You can find a runnable docker image here (https://hub.docker.com/r/esantoro/acso-explorer/) and some more details here (https://znpy.wordpress.com/2017/05/08/decommisioning-acso-explorer-santoro-tk/)

的 gcc-explorer 修改版

希望对您有所帮助,

znpy

您可以使用当前 Linux 构建大多数版本。要安装先决条件,请查看 https://github.com/bebbo/amiga-gcc

  • 解压 gcc 存档,例如至 /opt/cross/gcc-6.5.0
  • 创建一个单独的构建文件夹,例如/opt/cross/xcc-6.5.0 - 永远不要在 gcc 的源文件夹中构建!
  • 创建前缀文件夹,这是安装二进制文件的地方,例如/opt/cross/gcc65
  • 确保这些文件夹存在且可写,然后
  • 使用配置的绝对路径从构建文件夹中进行配置

    cd /opt/cross/xcc-6.5.0/
    /opt/cross/gcc-6.5.0/configure --target=m68k-elf --program-prefix=m68k-elf- --enable-languages=c,c++ --prefix=/opt/cross/gcc65 --disable-libssp --disable-nls --disable-multilib
    make all-gcc
    make install-gcc
    

我也是 运行 68k gcc 的编译器浏览器 https://franke.ms/cex/