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

跪求大佬添加ARMCC编译器支持 #1753

Closed
as564335sa opened this issue Oct 20, 2021 · 26 comments
Closed

跪求大佬添加ARMCC编译器支持 #1753

as564335sa opened this issue Oct 20, 2021 · 26 comments

Comments

@as564335sa
Copy link
Contributor

我是做嵌入式开发的,从单片机到linux,目前基本全部替换到vscode+xmake,但是单片机上用gcc编译出来的bin体积要比keil自带编译器armcc大很多,所以想用xmake调用armcc编译器,像隔壁EIDE那样

@waruqi
Copy link
Member

waruqi commented Oct 20, 2021

哦 keil 哈,我之前好像也提过一个 issue 备着:#345

@xmake-io xmake-io deleted a comment from FStell01 Oct 20, 2021
@Zmmfly
Copy link
Contributor

Zmmfly commented Oct 21, 2021

xmake create创建的默认工程,试着用xmake f -p cross -v --sdk=R:\Keil_v5\ARM\ARMCLANG --cross=arm,也不报错,也不输出编译器类型

configure
{
    theme = default
    clean = true
    network = public
    proxy_pac = pac.lua
    buildir = build
    plat = cross
    sdk = R:\Keil_v5\ARM\ARMCLANG
    arch = arm
    cross = arm
    kind = static
    target_os = linux
    host = windows
    ccache = true
    ndk_stdcxx = true
    mode = release
}

但是再xmake就提示error: cannot find known tool script for R:\Keil_v5\ARM\ARMCLANG\bin\armclang
xmake v2.5.7+202108290043. xmake -v

error: ...mdir\core\sandbox\modules\import\core\base\scheduler.lua:56: cannot find known tool script for R:\Keil_v5\ARM\ARMCLANG\bin\armclang
stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:829: in function 'raise'
        ...mdir\core\sandbox\modules\import\core\base\scheduler.lua:56: in function 'co_start_withopt'
        @programdir\modules\private\async\runjobs.lua:199: in function <@programdir\modules\private\async\runjobs.lua:159>
        [C]: in function 'trycall'
        @programdir\core\base\scheduler.lua:481: in function 'co_group_begin'
        ...mdir\core\sandbox\modules\import\core\base\scheduler.lua:94: in function 'co_group_begin'
        @programdir\modules\private\async\runjobs.lua:159: in function 'runjobs'
        @programdir\actions\build\build.lua:220: in function 'build'
        @programdir\actions\build\main.lua:133: in function <@programdir\actions\build\main.lua:123>
        [C]: in function 'trycall'
        @programdir\core\sandbox\modules\try.lua:121: in function 'try'
        @programdir\actions\build\main.lua:122: in function <@programdir\actions\build\main.lua:96>
        [C]: in function 'load'
        @programdir\core\base\task.lua:519: in function 'run'
        @programdir\core\main.lua:277: in function 'cotask'
        @programdir\core\base\scheduler.lua:365: in function <@programdir\core\base\scheduler.lua:362>

可能是无法识别编译器的类型吧
要是toolchain("armclang")能开放定义编译和链接的命令就好了,一个xmake.lua定义任意类型的编译器

@waruqi
Copy link
Member

waruqi commented Oct 21, 2021

要是toolchain("armclang")能开放定义编译和链接的命令就好了,一个xmake.lua定义任意类型的编译器

理论上是可以,不过这块涉及比较大的改动,并且开放的接口涉及还不稳,暂时不弄了,毕竟未知编译器 不会太多,大多都是 gcc 系的,其他的 xmake 内部集成下就行了

@waruqi
Copy link
Member

waruqi commented Oct 21, 2021

@Zmmfly @as564335sa 能否给个 armcc/armclang 编译的工程例子,比如 makefile 的。或者 keil 工程的完整 hello world 或者 static library 例子工程

我需要参考下相关 编译器 flags 和完整命令

@waruqi
Copy link
Member

waruqi commented Oct 25, 2021

我现在只能翻到一些零散的Flags片段,https://github.com/RT-Thread/rt-thread/blob/9bc3896e41716f6415e948ffea153a5453fe4b34/bsp/w60x/rtconfig.py

如果有现成 hello world 工程,以及 makefile 和 commands 可供参考,我近期可以弄下,不然只能先放置了,暂时没时间去折腾研究

@as564335sa
Copy link
Contributor Author

QQ截图20211025144939
hello.zip
sha上传了个工程和配置截图 @waruqi

@waruqi
Copy link
Member

waruqi commented Oct 25, 2021

QQ截图20211025144939 hello.zip sha上传了个工程和配置截图 @waruqi

你这工程太大,有没有 hello world 级别的,就一两文件。我要放到 tests/projects下面做例子工程的。。

@waruqi
Copy link
Member

waruqi commented Oct 25, 2021

还有 主要有哪些 cpu arch,哪些工程 target 类型,target output 的可执行后缀名 有哪些,能简单做个科普么。。我看 keil 里面各种 例子, flags 差异都很大。。我得大概有个概念,才好设计整体构建配置

还有目前工具链,主要由 armcc/armclang两个是么。。

@as564335sa
Copy link
Contributor Author

arch

arch和gcc里的差不多,单片机主要就是cortex m系列;
target扩展名是axf格式的,应该跟gcc的elf差不多,keil里有format工具转成hex和bin;
工具链就是armcc和armclang,这是两个版本,一个是V5,一个是V6,常用的是V5,就是armcc;
flags我看armcc的help比gcc要少的多;

我生成了两个工程,一个是keil的,一个是vscode的EIDE插件生成的,它能调用armcc,而且有makefile,我觉得可以参考这个;EIDE插件比较方便了,但是我还是喜欢xmake简单粗暴的方式,管理lib之类的方便的多
aaa.zip
hello.zip

@waruqi
Copy link
Member

waruqi commented Oct 25, 2021

好的 回头我研究下

@waruqi
Copy link
Member

waruqi commented Oct 26, 2021

hello.zip 这个我用keil 打开编译不过,提示 no section match

@as564335sa
Copy link
Contributor Author

这是缺少.s启动文件,建了个stm32的工
stm32.zip

@waruqi
Copy link
Member

waruqi commented Oct 26, 2021

这是缺少.s启动文件,建了个stm32的工 stm32.zip

这个代码量有点多哈,我不太好内置到 tests/projects 下面,有点大 有没有小一点的,就一两文件。。

@as564335sa
Copy link
Contributor Author

这样配置一下cmsis就行,这样就可以了
hello.zip

@waruqi
Copy link
Member

waruqi commented Oct 26, 2021

这样配置一下cmsis就行,这样就可以了 hello.zip

这个可以

@waruqi
Copy link
Member

waruqi commented Oct 26, 2021

能否再给个 带有 static library 的 hello world 例子给我? 最好有两个 target ,一个可执行程序,一个静态库,存在依赖关系

@waruqi
Copy link
Member

waruqi commented Oct 26, 2021

另外,我问下这两编译器 支持 c++ 么

@waruqi
Copy link
Member

waruqi commented Oct 26, 2021

armcc 版本的 我差不多跑通了,还差 static 的demo

armclang 的。。我不知道 keil 里面怎么切过去,flags看到的还是 armcc 的。。所以armclang 有哪些 flags 我不清楚,指定 arch 也不是用 --cpu 参数,具体有哪些有效值 我也不清楚。。能贴下吗

@as564335sa
Copy link
Contributor Author

切换编译器
armclang
静态库
static
cpu
cpu

@xq114
Copy link
Contributor

xq114 commented Oct 26, 2021

@waruqi
Copy link
Member

waruqi commented Oct 26, 2021

工具链还有armasm https://docs.microsoft.com/en-us/cpp/assembler/arm/arm-assembler-command-line-reference?view=msvc-160

这里只处理 keil mdk里面的,其他工具链请求请单开 issues

@waruqi
Copy link
Member

waruqi commented Oct 26, 2021

初步支持了

armcc

xmake f -p cross -a cortex-m3 --toolchain=armcc -c
xmake -v
[ 20%]: compiling.release src\system_ARMCM3.c
C:\Keil_v5\ARM\armcc\bin\armcc -c --cpu cortex-m3 -Isrc\lib\cmsis -D__EVAL -D__M
ICROLIB -DNDEBUG -o build\.objs\hello\cross\cortex-m3\release\src\system_ARMCM3.
c.o src\system_ARMCM3.c
checking for flags (-O3) ... no
[ 20%]: compiling.release src\main.c
C:\Keil_v5\ARM\armcc\bin\armcc -c --cpu cortex-m3 -Isrc\lib\cmsis -D__EVAL -D__M
ICROLIB -DNDEBUG -o build\.objs\hello\cross\cortex-m3\release\src\main.c.o src\m
ain.c
checking for flags (-O3) ... no
[ 20%]: compiling.release src\startup_ARMCM3.s
C:\Keil_v5\ARM\armcc\bin\armasm --cpu cortex-m3 -Isrc\lib\cmsis -o build\.objs\h
ello\cross\cortex-m3\release\src\startup_ARMCM3.s.o src\startup_ARMCM3.s
checking for flags (-O3) ... no
[ 30%]: compiling.release src\foo\foo.c
C:\Keil_v5\ARM\armcc\bin\armcc -c --cpu cortex-m3 -DNDEBUG -o build\.objs\foo\cr
oss\cortex-m3\release\src\foo\foo.c.o src\foo\foo.c
[ 60%]: archiving.release libfoo.a
C:\Keil_v5\ARM\armcc\bin\armar -cr build\cross\cortex-m3\release\libfoo.a build\
.objs\foo\cross\cortex-m3\release\src\foo\foo.c.o
[ 80%]: linking.release hello
C:\Keil_v5\ARM\armcc\bin\armlink -o build\cross\cortex-m3\release\hello build\.o
bjs\hello\cross\cortex-m3\release\src\startup_ARMCM3.s.o build\.objs\hello\cross
\cortex-m3\release\src\system_ARMCM3.c.o build\.objs\hello\cross\cortex-m3\relea
se\src\main.c.o --cpu cortex-m3 --userlibpath build\cross\cortex-m3\release libf
oo.a
[100%]: build ok!

armclang

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

例子工程:

https://github.com/xmake-io/xmake/tree/dev/tests/projects/mdk/hello

add_rules("mode.debug", "mode.release")

target("foo")
    add_rules("mdk.static")
    add_files("src/foo/*.c")

target("hello")
    add_deps("foo")
    add_rules("mdk.console")
    add_files("src/*.c", "src/*.s")
    add_defines("__EVAL", "__MICROLIB")
    add_includedirs("src/lib/cmsis")

有两个 rule mdk.staticmdk.console 分别对应两种 target 类型

@waruqi
Copy link
Member

waruqi commented Oct 26, 2021

目前只是初步支持,哪些是需要内置的必须 macro,还有哪些需要内置的 flags 可以说下,对这块我不太熟

@waruqi
Copy link
Member

waruqi commented Oct 27, 2021

没问题的话 我先关了 有需要改进的,之后再开其他issues

@waruqi waruqi closed this as completed Oct 27, 2021
@waruqi waruqi added this to the v2.5.9 milestone Oct 27, 2021
@geekroscom
Copy link

@waruqi
Copy link
Member

waruqi commented Jun 7, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants