Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编译MDK项目选择armclang编译器报错 #5809

Closed
jzz007 opened this issue Nov 11, 2024 · 13 comments
Closed

编译MDK项目选择armclang编译器报错 #5809

jzz007 opened this issue Nov 11, 2024 · 13 comments
Labels
Milestone

Comments

@jzz007
Copy link

jzz007 commented Nov 11, 2024

Xmake 版本

xmake v2.9.6 HEAD.abd15c255

操作系统版本和架构

Windows 10 version 22H2

描述问题

按官网教程

xmake f -p cross -a cortex-m3 --toolchain=armclang -c
xmake

无法编译,报错

error: Fatal error: A3900U: Unrecognized option '--target=arm-none-eabi'.

期待的结果

期望可以编译成功。
目前已找到解决方法,修改xmake安装目录下的toolchains\armclang\xmake.lua第70行,添加--注释掉这一行,之后再次运行xmake即可成功编译
修复后

        toolchain:set("toolset", "as", as)
        toolchain:add("cxflags", "--target=" .. arch_target)
        toolchain:add("cxflags", "-mcpu="   .. arch_cpu)
        -- toolchain:add("asflags", "--target=" .. arch_target)
        toolchain:add("asflags", (as == "armclang" and "-mcpu=" or "--cpu=") .. arch_cpu)
        toolchain:add("ldflags", "--cpu "   .. arch_cpu_ld)

工程配置

使用的官方github仓库下tests\projects\embed\mdk\hello示例

附加信息和错误日志

已经有解决方案

@jzz007 jzz007 added the bug label Nov 11, 2024
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: Compile MDK project and select armclang compiler to report an error

@waruqi
Copy link
Member

waruqi commented Nov 11, 2024

我这里可以,去掉反而报错,提示要加这个

armclang: fatal error: no target architecture given; use --target=arm-arm-none-eabi or --target=aarch64-arm-none-eabi

而且你这提示的是

'--target=arm-none-eabi'.

但是代码里根本没这个 arch

只有

arch_target = "arm-arm-none-eabi"

@jzz007
Copy link
Author

jzz007 commented Nov 11, 2024

这=-= 开始报这个错我以为是拼写错误尝试改过 后来改回来了。现在两个图是不注释掉的报错和注释掉的编译成功
图片
图片

@jzz007
Copy link
Author

jzz007 commented Nov 11, 2024

我这里把68行注释会有这个报错

error: armclang: fatal error: no target architecture given; use --target=arm-arm-none-eabi or --target=aarch64-arm-none-eabi
图片

@waruqi
Copy link
Member

waruqi commented Nov 11, 2024

不清楚,我这里可以,你可以看下 编译器版本,是不是过低了

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Not sure, I can do it here. You can check the compiler version to see if it is too low.

@jzz007
Copy link
Author

jzz007 commented Nov 12, 2024

之前测试肯定不是最新版本,我尝试使用今天能下载到的最新版本5.41测试,结果是这样的报错。
image
另外我再测试了一下把asflags那一行注释掉,取得了你提到的一样的报错

armclang: fatal error: no target architecture given; use --target=arm-arm-none-eabi or --target=aarch64-arm-none-eabi

所以这个问题其实就是不同版本的Keil需要的编译参数也不一样

@waruqi
Copy link
Member

waruqi commented Nov 12, 2024

版本兼容问题,你确认下最低支持版本是多少,可以根据版本来做兼容,也可以直接提个 pr 过来。

后面那个汇编问题,我不清楚,有可能新版本不支持 test example 里面的一些汇编语法,你可以自己调下代码 排查下。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


For version compatibility issues, please confirm what the minimum supported version is. You can make compatibility based on the version, or you can directly submit a PR.

I don't know about the assembly issue at the end. It's possible that the new version doesn't support some assembly syntax in the test example. You can adjust the code yourself to check.

waruqi added a commit that referenced this issue Nov 12, 2024
@waruqi
Copy link
Member

waruqi commented Nov 12, 2024

版本问题我修了,可以再试下 xmake update -s dev

@waruqi waruqi added this to the v2.9.7 milestone Nov 12, 2024
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


I have fixed the version problem. You can try xmake update -s dev again.

@jzz007
Copy link
Author

jzz007 commented Nov 12, 2024

当前的这个测试正常了 回头我再多测试几个,看这个代码应该是所有版本都OK了,感谢!

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


The current test is normal. I will test a few more later and see that all versions of this code should be OK. Thank you!

@waruqi waruqi closed this as completed Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants