作为m68k交叉编译器的GCC

6
我正在尝试将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。最后一次尝试在安装了binutils之后运行“make”时失败了。它会给出以下错误:
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库不应该是问题。有什么办法可以继续吗?我只需要汇编程序,所以我不介意对象文件的格式是什么。谢谢!


谢谢,一个问题解决了!你能否检查我的编辑并告诉我接下来该怎么做? - aspirino67
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42557#c5 - Ignacio Vazquez-Abrams
抱歉打扰您,但我遇到了一个新的错误。您能检查一下我的新编辑吗?非常感谢。 - aspirino67
@aspirino67 你的目标硬件是哪一种?有一个针对68000的gcc 6.2端口可用(Amiga,但也可能适用于其他机器)。还要检查vbcc。 - Jean-François Fabre
gcc中的68k支持自2.95版本以来通常被认为没有得到改善(相反,情况可能更糟)。根据我的经验,最近的gcc生成了很多非常愚蠢的68k代码。我的建议是使用旧版本(使用旧版本编译)。 - tofro
显示剩余2条评论
2个回答

2

我曾经也做过你现在正在做的事情。

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

如果你正在学习m68k汇编语言,我曾经托管过Matt Godbolt的修改版gcc-explorer (https://godbolt.org/)。你可以在这里找到可运行的docker镜像 (https://hub.docker.com/r/esantoro/acso-explorer/),并在这里找到更多详细信息 (https://znpy.wordpress.com/2017/05/08/decommisioning-acso-explorer-santoro-tk/)。

希望对你有所帮助,

znpy


1

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

  • unpack the gcc archive, e.g. to /opt/cross/gcc-6.5.0
  • create a separate build folder, e.g. /opt/cross/xcc-6.5.0 - never build inside gcc's source folder!
  • create the prefix folder, that's where binaries are installed to, e.g. /opt/cross/gcc65
  • ensure that these folders exist and are writable, then
  • configure from within that build folder using an absolute path for configure

    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 gccs的编译器探索器,网址为https://franke.ms/cex/


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接