如何防止 GCC 传入默认标志?

发布于 2024-08-09 02:56:26 字数 1334 浏览 2 评论 0原文

我正在尝试为 ARM 架构交叉编译 linux。

主机是运行 ubuntu-jaunty 的 X86 机器。我从 http://ftp.arm 下载了 ARM 的交叉编译工具链.linux.org.uk/pub/armlinux/toolchain/。我下载了2.95.3版本的工具链。

我遇到的问题是 GCC 自行传递一些默认标志,导致 GCC 输出错误:

/usr/local/arm/2.95.3/bin/arm-linux-gcc -specs=/home/feroze/wnr834m/marvell_WNR834M/gcc_specs -D__KERNEL__ -I/home/feroze/wnr834m/marvell_WNR834M/linux-88fxx81 -1_1_3_gtk/include -Wall -Wstrict-prototypes -Wno-trigraphs -Os -fno-strict-aliasing -fno-common -DLED_DUAL_COLOR -DFOR_ROUTER -I/home/feroze/wnr834m/marvell_WNR834M/linux-88fxx81-1_1_3_gtk/arch/arm /mach-mv88fxx81/Soc/gpp/ -Uarm -fno-common -pipe -mapcs-32 -D__LINUX_ARM_ARCH__=5 -march=armv5 -mtune=arm9tdmi -mshort-load-bytes -msoft-float -Uarm -march=strongarm - DKBUILD_BASENAME=main -c -o init/main.o init/main.c cc1:-march= 开关的错误值(strongarm) make[1]: *** [init/main.o] 错误 1 make[1]: 离开目录 `/home/feroze/wnr834m/marvell_WNR834M/linux-88fxx81-1_1_3_gtk'

我检查了整个 makefile,找不到任何 LINUX_ARM_ARCH_5 和 -march=armv5 所在的位置被定义。我在 makefile 中定义 -march=strongarm,但随后它会被 ARMv5 定义附加。

因此,我从 gcc 创建了一个 defs 文件,将其修改为仅包含 ARMv4 的选项,然后通过指定 -specs= 选项来使用它。然而,这仍然不能解决问题。

有人可以帮忙吗?我该如何解决这个问题?

谢谢!

费罗泽

I am trying to cross-compile linux for an ARM architecture.

The host is an X86 machine running ubuntu-jaunty. I downloaded a cross-compile toolchain for ARM from http://ftp.arm.linux.org.uk/pub/armlinux/toolchain/. I downloaded the 2.95.3 version of the toolchain.

The problem I am having is that GCC is passing in some default flags by itself that is causing GCC to then output error:

/usr/local/arm/2.95.3/bin/arm-linux-gcc -specs=/home/feroze/wnr834m/marvell_WNR834M/gcc_specs -D__KERNEL__ -I/home/feroze/wnr834m/marvell_WNR834M/linux-88fxx81-1_1_3_gtk/include -Wall -Wstrict-prototypes -Wno-trigraphs -Os -fno-strict-aliasing -fno-common -DLED_DUAL_COLOR -DFOR_ROUTER -I/home/feroze/wnr834m/marvell_WNR834M/linux-88fxx81-1_1_3_gtk/arch/arm/mach-mv88fxx81/Soc/gpp/ -Uarm -fno-common -pipe -mapcs-32 -D__LINUX_ARM_ARCH__=5 -march=armv5 -mtune=arm9tdmi -mshort-load-bytes -msoft-float -Uarm -march=strongarm -DKBUILD_BASENAME=main -c -o init/main.o init/main.c
cc1: bad value (strongarm) for -march= switch
make[1]: *** [init/main.o] Error 1
make[1]: Leaving directory `/home/feroze/wnr834m/marvell_WNR834M/linux-88fxx81-1_1_3_gtk'

I checked the whole makefile, and could not find any place where LINUX_ARM_ARCH_5 and -march=armv5 are being defined. I am defining -march=strongarm in the makefile, but then it gets appended by theh ARMv5 defines.

So, I created a defs file from gcc, modified it to only have options for ARMv4, and then used it by specifying the -specs= option. However, that still doesnt solve the problem.

Can somemone help? How do I resolve this?

Thanks!

feroze

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

猥︴琐丶欲为 2024-08-16 02:56:26

-march 标志在 arch/ARM/Makefile 中设置,并且取决于您在配置文件中选择的计算机。如果您不需要 armv5 标志,请务必在配置文件中选择正确的体系结构。

你应该假设内核附加的 CFLAGS 是正确的(假设你的配置没问题),如果你的工具链不支持其中之一,那么你别无选择,只能使用 原始 crosstol 脚本 应该与 2.95.3 一起使用

编辑:原始答案
您想构建什么?
2.95.3 工具链相当古老。您应该尝试更新的工具链。您可以在此处找到预编译的版本
选择 EABI 开始。

这不是对您的问题的直接答案,但如果您正在构建 Linux 内核,则不需要弄乱 Makefile。如果您可以获得更“标准”的工具链,您将获得更多帮助。

The -march flag is set in arch/ARM/Makefile, and depends on the machine you selected in your config file. If you don't want the armv5 flag, be sure to select the correct architecture in the config file.

You should assume the kernel appended CFLAGS are right (provided your config is ok) and if your toolchain does not support one of them, then you have no choice but to cross compile a toolchain by yourself, using the original crosstol script that should work with 2.95.3

Edit : original answer
What are you trying to build ?
a 2.95.3 toolchain is fairly ancient. You should try a more recent toolchain. You can find a precompiled one here
Pick the EABI one to start.

This is not a direct answer to your problem, but if you are building the linux kernel, you should not need to mess with the Makefiles. You will get more help if you can get a more "standard" toolchain.

入怼 2024-08-16 02:56:26

这并不能严格帮助您消除问题,但您可以执行gcc -dM -Egcc -dM -E - xc /dev/null 打印出 gcc 的所有预定义 #define 的列表。将 -dM 与另一个标志(例如 -march)结合起来,您也许能够找出导致 #define 问题的原因。

This won't strictly help you eliminate the issue, but you can do gcc -dM -E <empty_file.c> or gcc -dM -E -x c /dev/null to print out a listing of all the predefined #defines for gcc. Combine -dM with another flag like your -march and you might be able to track down what's causing your #define issue.

毁梦 2024-08-16 02:56:26

请务必检查您的环境变量,因为它们可以说服 make 执行意想不到的操作。

如果 Makefile 包含另一个文件,则它可能会在调用 CC 之前修改 CFLAGS。您可以在 CC 调用之前打印 CFLAGS 的内容吗?

Be sure to check your environment variables, as they can persuade make to do unexpected things.

If the Makefile includes another file, it could be modifying CFLAGS before CC is called. Can you print the contents of CFLAGS just before the CC call?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文