armclang报未使用的命令行参数
Xmake 版本
2.9.8
操作系统版本和架构
Windows11
描述问题
[ 77%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_rtc.c
C:\Keil_v5\ARM\armclang\bin\armclang -c --target=arm-arm-none-eabi -mcpu=cortex-m4 -Ilibs\n32l40x\CMSIS\device -Ilibs\n32l40x\CMSIS\core -Ilibs\n32l40x\n32l40x_std_periph_driver\inc -ffunction-sections -fdata-sections -funsigned-char -fshort-enums -Oz -flto -g -gdwarf-4 -o build\.objs\n32l40x\cross\cortex-m4\release\libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_rtc.c.o libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_rtc.c
armclang: warning: argument unused during compilation: '-c' [-Wunused-command-line-argument]
终端内直接运行命令又没有这个warning
期待的结果
没有这个warning
工程配置
主要是这个规则
rule("embed")
on_config(function(target)
local is_mdk = false
if target:has_tool("cc", "armcc", "armclang") then
is_mdk = true
end
if is_mdk then
-- target:add("cxflags", "-Wno-unused-command-line-argument", {public=true})
target:add("cxflags", "-ffunction-sections", "-fdata-sections", {public=true})
target:add("cxflags", "-funsigned-char", "-fshort-enums", {public=true})
target:add("cxflags", "-Oz", "-flto", {public=true, force = true})
target:add("cxflags", "-g", "-gdwarf-4", {public=true})
target:add("ldflags", "--lto", {public=true, force = true})
target:add("ldflags", "--info sizes --info totals --info unused --info veneers", {public=true, force=true})
target:add("ldflags", "--summary_stderr --info summarysizes --map --load_addr_map_info --xref --callgraph --symbols", {public=true, force=true})
target:add("asflags", "-Wa,armasm,--diag_suppress=A1950W", "-masm=auto", {force = true})
else
-- target:add("cxflags", "-mthumb", {public=true})
local common_flags = "-mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard"
target:add("defines", "__FPU_PRESENT=1", {public=true})
target:add("cxflags", common_flags, {public=true})
target:add("cxflags", "-Wl,--gc-sections -ffunction-sections -fdata-sections", {public=true})
target:add("cxflags", "-funsigned-char -fshort-enums", {public=true})
target:add("asflags", "-c "..common_flags.." -x assembler-with-cpp -Wa,-mimplicit-it=thumb", {public=true})
target:add("ldflags", common_flags, {public=true})
target:add("cxflags", "--specs=nano.specs --specs=nosys.specs -u _printf_float -u _scanf_float", {public=true})
end
end)
after_build(function(target)
if target:get("kind") ~= "binary" then
return
end
local elf_file = target:targetfile()
local bin_file = path.join(path.directory(elf_file), path.basename(elf_file) .. ".bin")
local cc = target:tool("cc")
-- 如果是MDK编译器,使用fromelf工具转换为bin文件
if target:has_tool("cc", "armcc", "armclang") then
local fromelf = path.join(path.directory(cc),"fromelf.exe")
os.runv(fromelf, {"--bin", "--output="..bin_file, elf_file})
-- 否则使用objcopy
else
-- 拼接 objcopy 路径, gsub有两个返回值, 所以使用括号包裹
local objcopy = path.join(path.directory(cc), (path.filename(cc):gsub("gcc", "objcopy")))
os.runv(objcopy, {"-O", "binary", path.absolute(elf_file), path.absolute(bin_file)})
end
end)
附加信息和错误日志
每一个文件都有这警告,但是单独按xmake -v中给出的编译命令运行又没有,调试起来没头绪
Bot detected the issue body's language is not English, translate it automatically.
Title: armclang reports unused command line parameters
给个完整可复现的 最小工程。
Bot detected the issue body's language is not English, translate it automatically.
Give a complete and reproducible minimum project.
Bot detected the issue body's language is not English, translate it automatically.
Give a complete and reproducible minimum project.
这两天没 win 环境,要等下周才有空看了
Bot detected the issue body's language is not English, translate it automatically.
I haven't had a win environment these two days, so I'll have to wait for a while to watch it next week
没遇到你的问题,只有一个 lto 的错误
PS C:\Users\Downloads\n32l40x_template_final> xmake f -p cross -a cortex-m4 --toolchain=armclang -c
PS C:\Users\Downloads\n32l40x_template_final> xmake
[ 17%]: cache compiling.release src\main.c
[ 17%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_can.c
[ 17%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_adc.c
[ 17%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_comp.c
[ 17%]: cache compiling.release libs\n32l40x\CMSIS\device\system_n32l40x.c
[ 17%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\misc.c
error: error: use of LTO is disallowed in this variant of Arm Compiler for Embedded
> in src\main.c
我禁用 lto 后,一切正常,没任何警告。
PS C:\Users\Downloads\n32l40x_template_final> xmake
[ 19%]: cache compiling.release src\main.c
[ 19%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_adc.c
[ 19%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_can.c
[ 19%]: cache compiling.release libs\n32l40x\CMSIS\device\system_n32l40x.c
[ 19%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\misc.c
[ 19%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_comp.c
[ 22%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_crc.c
[ 24%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_dac.c
[ 26%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_dbg.c
[ 28%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_dma.c
[ 30%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_exti.c
[ 33%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_flash.c
[ 35%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_gpio.c
[ 37%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_i2c.c
[ 39%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_iwdg.c
[ 41%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_lcd.c
[ 44%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_lptim.c
[ 46%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_lpuart.c
[ 48%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_opamp.c
[ 50%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_pwr.c
[ 53%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_rcc.c
[ 55%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_rtc.c
[ 57%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_spi.c
[ 59%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_tim.c
[ 61%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_usart.c
[ 64%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_wwdg.c
[ 68%]: linking.release libn32l40x.a
[ 83%]: linking.release firmware.axf
Program Size: Code=1288 RO-data=360 RW-data=4 ZI-data=6244
[100%]: build ok, spent 5.25s
跟你一样的编译器
[ 64%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_wwdg.c
C:\Keil_v5\ARM\armclang\bin\armclang -c --target=arm-arm-none-eabi -mcpu=cortex-m4 -Ilibs\n32l40x\CMSIS\core -Ilibs\n32l40x\CMSIS\device -Ilibs\n32l40x\n32l40x_std_periph_driver\inc -ffunction-sections -fdata-sections -funsigned-char -fshort-enums -g -gdwarf-4 -o build\.objs\n32l40x\cross\cortex-m4\release\libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_wwdg.c.o libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_wwdg.c
跟你一样的编译器
[ 64%]: cache compiling.release libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_wwdg.c C:\Keil_v5\ARM\armclang\bin\armclang -c --target=arm-arm-none-eabi -mcpu=cortex-m4 -Ilibs\n32l40x\CMSIS\core -Ilibs\n32l40x\CMSIS\device -Ilibs\n32l40x\n32l40x_std_periph_driver\inc -ffunction-sections -fdata-sections -funsigned-char -fshort-enums -g -gdwarf-4 -o build\.objs\n32l40x\cross\cortex-m4\release\libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_wwdg.c.o libs\n32l40x\n32l40x_std_periph_driver\src\n32l40x_wwdg.c
那就很奇怪了;一开始怀疑是环境问题,但是在家跑也报错,不知道是不是和MDK还有armclang的版本有关,MDK目前是用的5.42a,我换个老版本再试试
这边是 5.38
Bot detected the issue body's language is not English, translate it automatically.
This is 5.38