我是 GCC 新手,打算将 GCC 编译器移植到新架构。
- 第 1 步:为新架构实现 GCC (gcc-4.6.1)
- 第 2 步:为新架构实现 binutils (binutils-2.21.1)
- 第 3 步:...
现在我处于第 1 步,我的问题是,
我可以在不实现 binutils 和其他工具的情况下构建 GCC 吗?输出类似于“{target}-linux-elf-gcc”
并且需要使用以下命令获取并检查程序集输出;
$ {new-machine}-linux-elf-gcc -S main.c
最佳答案
如果我正确理解你的问题,你想为给定的架构编译你的 GCC 版本。
下载 binutils 包,配置它并编译它,安装它并准备好构建 GCC。
下载您感兴趣的GCC版本包并配置参数,这些参数清楚地解释了目标架构和其他细节。 请参阅此页面以获取更多配置帮助:https://gcc.gnu.org/install/configure.html
If you are building this GCC on your native machine, most likely a set of kernel headers for your platform will be available and you don’t need to be concerned with headers. But for cross-compiling, a set of kernel headers from a source tree configured for your target must be made available.
示例配置,适用于 native 编译器: ./configure --prefix=PREFIX
对于 native 交叉编译器: ./configure --target=powerpc-linux --prefix=/usr --with-headers=/usr/src/linux/include --enable-languages=c --disable-threads
构建 GCC 后,接下来需要使用新生成的 GCC 工具链构建 glibc。
此后,您应该能够使用新创建的工具链编译任何其他包。 如果您想编译一个在该测试程序中具有较少依赖项的小型测试程序,您可以在准备好 GCC 后执行此操作。
关于linux - 将 GCC 移植到新架构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26133266/