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

armclang .S文件编译报错,以及--cpu报错 #1962

Closed
Zmmfly opened this issue Jan 7, 2022 · 4 comments
Closed

armclang .S文件编译报错,以及--cpu报错 #1962

Zmmfly opened this issue Jan 7, 2022 · 4 comments
Labels
Milestone

Comments

@Zmmfly
Copy link
Contributor

Zmmfly commented Jan 7, 2022

描述问题

1. 编译.S文件时,报错: error: "<command line>", line 2: Error: A1167E: Invalid line start

2. 修复.S文件报错后 error: armclang: error: unsupported option '--cpu'

期待的结果

  • 0 Error(s), 0 Warning(s).

错误信息

1. .S文件报错

$ xmake -vD
R:\Keil_v5\ARM\armclang\bin\armasm --cpu cortex-m0plus -Iinclude -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include --pd "USE_FULL_LL_DRIVER SETA 1" --pd "HSE_VALUE=8000000 SETA 1" --pd "HSE_STARTUP_TIMEOUT=100 SETA 1" --pd "LSE_STARTUP_TIMEOUT=5000 SETA 1" --pd "LSE_VALUE=32768 SETA 1" --pd "EXTERNAL_CLOCK_VALUE=12288000 SETA 1" --pd "HSI_VALUE=16000000 SETA 1" --pd "LSI_VALUE=32000 SETA 1" --pd "VDD_VALUE=3300 SETA 1" --pd "PREFETCH_ENABLE=1 SETA 1" --pd "INSTRUCTION_CACHE_ENABLE=1 SETA 1" --pd "DATA_CACHE_ENABLE=1 SETA 1" --pd "STM32G031xx SETA 1" -o build\.objs\boot\corss\cortex-m0plus\release\src\startup_stm32g031xx.S.o src\startup_stm32g031xx.S
error: "<command line>", line 2: Error: A1167E: Invalid line start
    2 00000000 HSE_VALUE=8000000 SETA 1
"<command line>", line 3: Error: A1167E: Invalid line start
    3 00000000 HSE_STARTUP_TIMEOUT=100 SETA 1
"<command line>", line 4: Error: A1167E: Invalid line start
    4 00000000 LSE_STARTUP_TIMEOUT=5000 SETA 1
"<command line>", line 5: Error: A1167E: Invalid line start
    5 00000000 LSE_VALUE=32768 SETA 1
"<command line>", line 6: Error: A1167E: Invalid line start
    6 00000000 EXTERNAL_CLOCK_VALUE=12288000 SETA 1
"<command line>", line 7: Error: A1167E: Invalid line start
    7 00000000 HSI_VALUE=16000000 SETA 1
"<command line>", line 8: Error: A1167E: Invalid line start
    8 00000000 LSI_VALUE=32000 SETA 1
"<command line>", line 9: Error: A1167E: Invalid line start
    9 00000000 VDD_VALUE=3300 SETA 1
"<command line>", line 10: Error: A1167E: Invalid line start
   10 00000000 PREFETCH_ENABLE=1 SETA 1
"<command line>", line 11: Error: A1167E: Invalid line start
   11 00000000 INSTRUCTION_CACHE_ENABLE=1 SETA 1
"<command line>", line 12: Error: A1167E: Invalid line start
   12 00000000 DATA_CACHE_ENABLE=1 SETA 1
11 Errors, 0 Warnings

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:833: in function 'os.raiselevel'
        (...tail calls...)
        @programdir\modules\private\async\runjobs.lua:232: in field 'catch'
        @programdir\core\sandbox\modules\try.lua:127: in global 'try'
        @programdir\modules\private\async\runjobs.lua:200: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:371: in function <@programdir\core\base\scheduler.lua:368>

2. error: armclang: error: unsupported option '--cpu'

修复.1 修复后又报错

$ xmake -vD
[ 14%]: compiling.release ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_adc.c
R:\Keil_v5\ARM\armclang\bin\armclang -c -target=arm-arm-none-eabi -mcpu=cortex-m0plus -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\drivers\corss\cortex-m0plus\release\__\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_adc.c.o ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_adc.c
[ 14%]: compiling.release ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_crc.c
R:\Keil_v5\ARM\armclang\bin\armclang -c -target=arm-arm-none-eabi -mcpu=cortex-m0plus -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\drivers\corss\cortex-m0plus\release\__\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_crc.c.o ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_crc.c
[ 14%]: compiling.release ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_dma.c
R:\Keil_v5\ARM\armclang\bin\armclang -c -target=arm-arm-none-eabi -mcpu=cortex-m0plus -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\drivers\corss\cortex-m0plus\release\__\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_dma.c.o ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_dma.c
[ 14%]: compiling.release ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_exti.c
R:\Keil_v5\ARM\armclang\bin\armclang -c -target=arm-arm-none-eabi -mcpu=cortex-m0plus -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\drivers\corss\cortex-m0plus\release\__\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_exti.c.o ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_exti.c
[ 14%]: compiling.release ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_gpio.c
R:\Keil_v5\ARM\armclang\bin\armclang -c -target=arm-arm-none-eabi -mcpu=cortex-m0plus -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\drivers\corss\cortex-m0plus\release\__\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_gpio.c.o ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_gpio.c
[ 14%]: compiling.release ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_lpuart.c
R:\Keil_v5\ARM\armclang\bin\armclang -c -target=arm-arm-none-eabi -mcpu=cortex-m0plus -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\drivers\corss\cortex-m0plus\release\__\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_lpuart.c.o ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_lpuart.c
[ 14%]: compiling.release ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_pwr.c
R:\Keil_v5\ARM\armclang\bin\armclang -c -target=arm-arm-none-eabi -mcpu=cortex-m0plus -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\drivers\corss\cortex-m0plus\release\__\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_pwr.c.o ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_pwr.c
[ 14%]: compiling.release ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_rcc.c
R:\Keil_v5\ARM\armclang\bin\armclang -c -target=arm-arm-none-eabi -mcpu=cortex-m0plus -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\drivers\corss\cortex-m0plus\release\__\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_rcc.c.o ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_rcc.c
[ 14%]: compiling.release ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_spi.c
R:\Keil_v5\ARM\armclang\bin\armclang -c -target=arm-arm-none-eabi -mcpu=cortex-m0plus -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\drivers\corss\cortex-m0plus\release\__\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_spi.c.o ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_spi.c
[ 14%]: compiling.release ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_usart.c
R:\Keil_v5\ARM\armclang\bin\armclang -c -target=arm-arm-none-eabi -mcpu=cortex-m0plus -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\drivers\corss\cortex-m0plus\release\__\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_usart.c.o ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_usart.c
[ 14%]: compiling.release ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_utils.c
R:\Keil_v5\ARM\armclang\bin\armclang -c -target=arm-arm-none-eabi -mcpu=cortex-m0plus -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\drivers\corss\cortex-m0plus\release\__\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_utils.c.o ..\drivers\STM32G0xx_HAL_Driver\Src\stm32g0xx_ll_utils.c
[ 14%]: compiling.release src\startup_stm32g031xx.S
R:\Keil_v5\ARM\armclang\bin\armclang -c --cpu cortex-m0plus -Iinclude -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\boot\corss\cortex-m0plus\release\src\startup_stm32g031xx.S.o src\startup_stm32g031xx.S
[ 14%]: compiling.release src\adc.c
R:\Keil_v5\ARM\armclang\bin\armclang -c -target=arm-arm-none-eabi -mcpu=cortex-m0plus -Iinclude -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\boot\corss\cortex-m0plus\release\src\adc.c.o src\adc.c
[ 14%]: compiling.release src\crc.c
R:\Keil_v5\ARM\armclang\bin\armclang -c -target=arm-arm-none-eabi -mcpu=cortex-m0plus -Iinclude -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\boot\corss\cortex-m0plus\release\src\crc.c.o src\crc.c
[ 14%]: compiling.release src\gpio.c
R:\Keil_v5\ARM\armclang\bin\armclang -c -target=arm-arm-none-eabi -mcpu=cortex-m0plus -Iinclude -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\boot\corss\cortex-m0plus\release\src\gpio.c.o src\gpio.c
[ 14%]: compiling.release src\main.c
R:\Keil_v5\ARM\armclang\bin\armclang -c -target=arm-arm-none-eabi -mcpu=cortex-m0plus -Iinclude -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\boot\corss\cortex-m0plus\release\src\main.c.o src\main.c
[ 14%]: compiling.release src\spi.c
R:\Keil_v5\ARM\armclang\bin\armclang -c -target=arm-arm-none-eabi -mcpu=cortex-m0plus -Iinclude -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\boot\corss\cortex-m0plus\release\src\spi.c.o src\spi.c
[ 14%]: compiling.release src\stm32g0xx_it.c
R:\Keil_v5\ARM\armclang\bin\armclang -c -target=arm-arm-none-eabi -mcpu=cortex-m0plus -Iinclude -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\boot\corss\cortex-m0plus\release\src\stm32g0xx_it.c.o src\stm32g0xx_it.c
[ 14%]: compiling.release src\system_stm32g0xx.c
R:\Keil_v5\ARM\armclang\bin\armclang -c -target=arm-arm-none-eabi -mcpu=cortex-m0plus -Iinclude -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\boot\corss\cortex-m0plus\release\src\system_stm32g0xx.c.o src\system_stm32g0xx.c
[ 14%]: compiling.release src\usart.c
R:\Keil_v5\ARM\armclang\bin\armclang -c -target=arm-arm-none-eabi -mcpu=cortex-m0plus -Iinclude -I..\drivers\STM32G0xx_HAL_Driver\Inc -I..\drivers\CMSIS\Include -I..\drivers\CMSIS\Device\ST\STM32G0xx\Include -DUSE_FULL_LL_DRIVER -DHSE_VALUE=8000000 -DHSE_STARTUP_TIMEOUT=100 -DLSE_STARTUP_TIMEOUT=5000 -DLSE_VALUE=32768 -DEXTERNAL_CLOCK_VALUE=12288000 -DHSI_VALUE=16000000 -DLSI_VALUE=32000 -DVDD_VALUE=3300 -DPREFETCH_ENABLE=1 -DINSTRUCTION_CACHE_ENABLE=1 -DDATA_CACHE_ENABLE=1 -DSTM32G031xx -o build\.objs\boot\corss\cortex-m0plus\release\src\usart.c.o src\usart.c
error: @programdir\modules\private\async\runjobs.lua:232: @programdir\modules\private\action\build\object.lua:78: @programdir\modules\core\tools\gcc.lua:501: armclang: error: unsupported option '--cpu'
armclang: fatal error: no target architecture given; use --target=arm-arm-none-eabi or --target=aarch64-arm-none-eabi
stack traceback:
    [C]: in function 'error'
    [@programdir\core\base\os.lua:829]:
    [@programdir\modules\core\tools\gcc.lua:501]: in function 'catch'
    [@programdir\core\sandbox\modules\try.lua:127]: in function 'try'
    [@programdir\modules\core\tools\gcc.lua:445]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:280]:
    [@programdir\modules\private\action\build\object.lua:78]: in function 'script'
    [@programdir\modules\private\action\build\object.lua:91]: in function 'build_object'
    [@programdir\modules\private\action\build\object.lua:116]: in function 'jobfunc'
    [@programdir\modules\private\async\runjobs.lua:208]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:280]: in function 'trycall'
    [@programdir\core\sandbox\modules\try.lua:121]: in function 'try'
    [@programdir\modules\private\async\runjobs.lua:200]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:371]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:829: in function 'os.raiselevel'
        (...tail calls...)
        @programdir\modules\private\async\runjobs.lua:232: in field 'catch'
        @programdir\core\sandbox\modules\try.lua:127: in global 'try'
        @programdir\modules\private\async\runjobs.lua:200: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:371: in function <@programdir\core\base\scheduler.lua:368>

相关环境

请提供编译和运行环境信息,下面是一些必须填写的基础信息,便于我们针对性排查问题:

  • xmake版本:xmake v2.6.2+HEAD.90e499cb2
  • xmake运行平台:Win10 LTSC
  • xmake目标平台:STM32G0

其他信息

  1. 经查阅Keil文档,armclang中asm文件同样为armclang.exe来进行编译,仅根据参数来区分GNU Syntax和Arm Syntax.
    Keil Arm assmbler
  2. target其实应该区分为arm-arm-none-eabiaarch64-arm-none-eabi,但目前固定为arm-arm-none-eabi似乎也没什么大问题,keil还是32位的用得多些

修复

1..S 报错

修改安装目录下xmake/toolchains/armclang/xmake.lua 中 as 命令为 armclang

toolchain("armclang")

    set_homepage("https://www2.keil.com/mdk5/compiler/6")
    set_description("ARM Compiler Version 6 of Keil MDK")

    set_kind("cross")

    set_toolset("cc", "armclang")
    set_toolset("cxx", "armclang")
    set_toolset("ld", "armlink")
    set_toolset("ar", "armar")
    -- set_toolset("as", "armasm")
    set_toolset("as", "armclang")

2. 完全修复

直接替换xmake/toolchains/armclang/xmake.lua内容

--!A cross-platform build utility based on Lua
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
--     http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
-- Copyright (C) 2015-present, TBOOX Open Source Group.
--
-- @author      ruki
-- @file        xmake.lua
--

toolchain("armclang")

    set_homepage("https://www2.keil.com/mdk5/compiler/6")
    set_description("ARM Compiler Version 6 of Keil MDK")

    set_kind("cross")

    set_toolset("cc", "armclang")
    set_toolset("cxx", "armclang")
    set_toolset("ld", "armlink")
    set_toolset("ar", "armar")
    -- set_toolset("as", "armasm")
    set_toolset("as", "armclang")

    on_check(function (toolchain)
        import("lib.detect.find_tool")
        import("detect.sdks.find_mdk")
        local mdk = find_mdk()
        if mdk and mdk.sdkdir_armclang and find_tool("armclang") then
            toolchain:config_set("sdkdir", mdk.sdkdir_armclang)
            toolchain:configs_save()
            return true
        end
    end)

    on_load(function (toolchain)
        local arch = toolchain:arch()
        if arch then
            toolchain:add("cxflags", "-target=arm-arm-none-eabi")
            toolchain:add("cxflags", "-mcpu=" .. arch:lower())
            -- toolchain:add("asflags", "--cpu " .. arch)
            toolchain:add("ldflags", "--cpu " .. arch)
            toolchain:add("asflags", "-target=arm-arm-none-eabi")
            toolchain:add("asflags", "-mcpu=" .. arch:lower())
        end
    end)

target加入add_asflags("-masm=auto"),- 0 Error(s), 0 Warning(s).达成^_^.

@Zmmfly Zmmfly added the bug label Jan 7, 2022
@waruqi
Copy link
Member

waruqi commented Jan 7, 2022

改了 28fe6eb

target其实应该区分为arm-arm-none-eabi 和 aarch64-arm-none-eabi,但目前固定为arm-arm-none-eabi似乎也没什么大问题,keil还是32位的用得多些

要分也可以,但是要根据特定传进来的 arch 来区分哪些是 aarch64的。。目前传的 arch 就是 cpu 。。我不清楚哪些是 arm64 。。你知道的话,也可以帮忙提个 pr 改下

@waruqi waruqi added this to the v2.6.3 milestone Jan 7, 2022
@Zmmfly
Copy link
Contributor Author

Zmmfly commented Jan 9, 2022

@waruqi 已经添加aarch64支持,增加了armclang 的 -mcpu和 armlink --cpu参数差异的支持,如果没问题的话就提交PR了?
https://github.com/Zmmfly/xmake/commit/c0576c2fc972a17797ac9fe98e5e6deb00ba822a

$ R:\Keil_v5\ARM\ARMCLANG\bin>armclang -mcpu=list --target=arm-arm-none-eabi
The following arguments to option 'mcpu' can be selected:
  -mcpu=cortex-m0
  -mcpu=cortex-m0plus
  -mcpu=cortex-m1
  -mcpu=cortex-m3
  -mcpu=cortex-m4
  -mcpu=cortex-m7
  -mcpu=cortex-m23
  -mcpu=cortex-m33
  -mcpu=cortex-m35p
  -mcpu=cortex-m55
  -mcpu=cortex-r4
  -mcpu=cortex-r4f
  -mcpu=sc000
  -mcpu=sc300

$ R:\Keil_v5\ARM\ARMCLANG\bin>armlink --cpu=list
The following arguments to option 'cpu' can be selected:
 --cpu=6-M
 --cpu=6S-M
 --cpu=7-R
 --cpu=7-M
 --cpu=7E-M
 --cpu=8-M.Base
 --cpu=8-M.Main
 --cpu=8-M.Main.dsp
 --cpu=8.1-M.Main
 --cpu=8.1-M.Main.dsp
 --cpu=8.1-M.Main.mve
 --cpu=8.1-M.Main.mve.fp
 --cpu=Cortex-M0
 --cpu=Cortex-M0plus
 --cpu=SC000
 --cpu=Cortex-M1
 --cpu=Cortex-M1.os_extension
 --cpu=Cortex-M1.no_os_extension
 --cpu=Cortex-M3
 --cpu=Cortex-M3-rev0
 --cpu=SC300
 --cpu=Cortex-M4
 --cpu=Cortex-M4.no_fp
 --cpu=Cortex-M7
 --cpu=Cortex-M7.fp.sp
 --cpu=Cortex-M7.no_fp
 --cpu=Cortex-M23
 --cpu=Cortex-M33
 --cpu=Cortex-M33.no_fp
 --cpu=Cortex-M33.no_dsp
 --cpu=Cortex-M33.no_dsp.no_fp
 --cpu=Cortex-M35P
 --cpu=Cortex-M35P.no_fp
 --cpu=Cortex-M35P.no_dsp
 --cpu=Cortex-M35P.no_dsp.no_fp
 --cpu=Cortex-M55
 --cpu=Cortex-M55.no_mvefp
 --cpu=Cortex-M55.no_fp
 --cpu=Cortex-M55.no_mve
 --cpu=Cortex-M55.no_mve.no_fp
 --cpu=Cortex-R4
 --cpu=Cortex-R4F

@Zmmfly
Copy link
Contributor Author

Zmmfly commented Jan 9, 2022

已更新,按照命令给出的提示,armlink时不需要替换plus为+,测试也OK。
Zmmfly@0702f04

@waruqi
Copy link
Member

waruqi commented Jan 9, 2022

就一个 arm64 判断,搞的有点复杂了,而且原本有内置 s:replace("", "", {plain = true}) 可用

另外所有 string 操作,直接用 s:xx 替代 string.xx(s, ..) 保持风格一致

你可以先开 pr 我到时候 review后 你再改下

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

2 participants