为什么相同的CFLAGS可以在makefile中重复两次?

问题描述 投票:-1回答:2

这是makefile的片段:

CFLAGS += -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16

CFLAGS  = -g -O2 -Wall
CFLAGS += -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16

第一行与第三行完全相同。

注释第一行后,“ make”没有错。

但是在注释第三行后,“ make”出了错。错误:

/tmp/ccIrbEv9.s: Assembler messages:
/tmp/ccIrbEv9.s:77: Error: selected processor does not support `rbit r0,r0' in ARM mode
/tmp/ccIrbEv9.s:368: Error: selected processor does not support `rbit r0,r0' in ARM mode
/tmp/ccIrbEv9.s:402: Error: selected processor does not support `rbit r0,r0' in ARM mode
/tmp/ccIrbEv9.s:1276: Error: selected processor does not support `rbit r0,r0' in ARM mode
/tmp/ccIrbEv9.s:1305: Error: selected processor does not support `rbit r0,r3' in ARM mode
/tmp/ccIrbEv9.s:1371: Error: selected processor does not support `rbit r0,r0' in ARM mode
/tmp/ccIrbEv9.s:1400: Error: selected processor does not support `rbit r0,r3' in ARM mode
/tmp/ccIrbEv9.s:1544: Error: selected processor does not support `rbit r0,r0' in ARM mode
/tmp/ccIrbEv9.s:1573: Error: selected processor does not support `rbit r0,r3' in ARM mode
/tmp/ccIrbEv9.s:1643: Error: selected processor does not support `rbit r0,r0' in ARM mode
/tmp/ccIrbEv9.s:1672: Error: selected processor does not support `rbit r0,r3' in ARM mode
/tmp/ccIrbEv9.s:2989: Error: selected processor does not support `rbit r0,r0' in ARM mode
/tmp/ccIrbEv9.s:3021: Error: selected processor does not support `rbit r0,r0' in ARM mode
/tmp/ccIrbEv9.s:3060: Error: selected processor does not support `rbit r0,r0' in ARM mode
/tmp/ccIrbEv9.s:3096: Error: selected processor does not support `rbit r0,r0' in ARM mode
/tmp/ccIrbEv9.s:3342: Error: selected processor does not support `rbit r0,r0' in ARM mode
/tmp/ccIrbEv9.s:3371: Error: selected processor does not support `rbit r0,r3' in ARM mode
/tmp/ccIrbEv9.s:3443: Error: selected processor does not support `rbit r0,r0' in ARM mode
/tmp/ccIrbEv9.s:3472: Error: selected processor does not support `rbit r0,r3' in ARM mode
/tmp/ccIrbEv9.s:3783: Error: selected processor does not support `rbit r0,r0' in ARM mode
Makefile:27: recipe for target 'Src/stm32f7xx_hal_dma2d.o' failed 

我感到困惑。

gcc makefile arm stm32 cortex-m
2个回答
2
投票

CFLAGS = -g -O2 -Wall

此行将覆盖第一行(请注意分配),因此,如果删除第三行,则编译时将不使用这些选项,并且将应用工具链默认值。在这种非常特殊的情况下,似乎编译器不接受默认目标的源。


0
投票

注意两者之间的区别

CFLAGS += ...

和:

CFLAGS = ...

加号使一切有所不同。它通过附加标志来修改CFLAGS值。如果没有加号,则该值将被替换,并且先前的值将丢失。

  1. 第一个CFLAGS += ...可以被删除,因为它的值被CFLAGS = ...替换。

  2. [CFLAGS = ...可以删除,因为代码也将在没有它们的情况下进行编译。

  3. 最后一个CFLAGS += ...不能删除,因为它提供了对于代码必不可少的编译器标志。

© www.soinside.com 2019 - 2024. All rights reserved.