我曾经使用arm-none-eabi-gcc / arm-none-eabi-g ++编译我的微控制器代码,一切正常。我在Mac上使用自制的Cask gcc-arm嵌入式。昨天我更新了它,现在当我为Cortex M4架构编译时,我在链接阶段得到了每个目标文件的这些错误消息(用M3编译好):
/usr/local/Caskroom/gcc-arm-embedded/6-2017-q1-update/gcc-arm-none-eabi-6-2017-q1-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/bin/ld: error: anobjectfile.o: Conflicting CPU architectures 1/13
/usr/local/Caskroom/gcc-arm-embedded/6-2017-q1-update/gcc-arm-none-eabi-6-2017-q1-update/bin/../lib/gcc/arm-none-eabi/6.3.1/../../../../arm-none-eabi/bin/ld: failed to merge target specific data of file example.o
在查看内容时,一切看起来都很好:
$ arm-none-eabi-readelf -A example.o
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "Cortex-M4"
Tag_CPU_arch: v7E-M
Tag_CPU_arch_profile: Microcontroller
Tag_THUMB_ISA_use: Thumb-2
Tag_FP_arch: VFPv4-D16
Tag_ABI_PCS_wchar_t: 2
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_align_preserved: 8-byte, except leaf SP
Tag_ABI_enum_size: small
Tag_ABI_HardFP_use: SP only
Tag_ABI_VFP_args: VFP registers
Tag_ABI_optimization_goals: Aggressive Size
Tag_CPU_unaligned_access: v6
这是一个用于编译C文件的命令行:
arm-none-eabi-gcc -ffunction-sections -Wall -Werror -I… -std=c99 -DBOARD_DISCOVERY_F429
-DPORT_CPU=stm32f429 -DPORT_CPU_FAMILY=arm -DPORT_CPU_FAMILY_SUBFAMILY=CM4F
-DPORT_CPU_FLAVOR=stm32f4xx -g -Os -DNDEBUG -mcpu=cortex-m4 -mfpu=fpv4-sp-d16
-mfloat-abi=hard -fno-math-errno -mtune=cortex-m4 -D__thumb2__=1 -march=armv7e-m -mthumb
-DUSE_STDPERIPH_DRIVER -DSTM32F429_439xx -mapcs-frame -mno-sched-prolog -fshort-wchar
-D__LITTLE_ENDIAN -ffunction-sections -fdata-sections -fno-builtin-malloc
-fno-builtin-realloc -fno-builtin-free -fno-strict-aliasing -DTARGET_LITTLE_ENDIAN
-DHSE_VALUE=8000000 -DPLL_M=8 -g -c -o example.o example.c
对于C ++文件:
arm-none-eabi-g++ -ffunction-sections -Wall -Werror -I… -fno-exceptions -fno-rtti
-std=c++11 -DBOARD_DISCOVERY_F429 -DPORT_CPU=stm32f429 -DPORT_CPU_FAMILY=arm
-DPORT_CPU_FAMILY_SUBFAMILY=CM4F -DPORT_CPU_FLAVOR=stm32f4xx -g -Os -DNDEBUG
-mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fno-math-errno -mtune=cortex-m4
-D__thumb2__=1 -march=armv7e-m -mthumb -DUSE_STDPERIPH_DRIVER -DSTM32F429_439xx
-mapcs-frame -mno-sched-prolog -fshort-wchar -D__LITTLE_ENDIAN -ffunction-sections
-fdata-sections -fno-builtin-malloc -fno-builtin-realloc -fno-builtin-free
-fno-strict-aliasing -DTARGET_LITTLE_ENDIAN -DHSE_VALUE=8000000 -DPLL_M=8 -g -c
-o example.o example.cpp
链接:
arm-none-eabi-gcc -Wl,--gc-sections -Wl,-Map=executable.map -o executable.elf executable.o
file1.o file2.o … -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fno-math-errno
-mtune=cortex-m4 -march=armv7e-m -mthumb -Wl,--no-wchar-size-warning -g
-T…/stm32f40x.ld -specs=…/specs -Wl,--start-group …/lib1.a …/lib2.a … -Wl,--end-group
查看multi-lib:
$ arm-none-eabi-gcc -print-multi-lib
.;
thumb;@mthumb
hard;@mfloat-abi=hard
thumb/v6-m;@mthumb@march=armv6s-m
thumb/v7-m;@mthumb@march=armv7-m
thumb/v7e-m;@mthumb@march=armv7e-m
thumb/v7-ar;@mthumb@march=armv7
thumb/v8-m.base;@mthumb@march=armv8-m.base
thumb/v8-m.main;@mthumb@march=armv8-m.main
thumb/v7e-m/fpv4-sp/softfp;@mthumb@march=armv7e-m@mfpu=fpv4-sp-d16@mfloat-abi=softfp
thumb/v7e-m/fpv4-sp/hard;@mthumb@march=armv7e-m@mfpu=fpv4-sp-d16@mfloat-abi=hard
thumb/v7e-m/fpv5-sp/softfp;@mthumb@march=armv7e-m@mfpu=fpv5-sp-d16@mfloat-abi=softfp
thumb/v7e-m/fpv5-sp/hard;@mthumb@march=armv7e-m@mfpu=fpv5-sp-d16@mfloat-abi=hard
thumb/v7e-m/fpv5/softfp;@mthumb@march=armv7e-m@mfpu=fpv5-d16@mfloat-abi=softfp
thumb/v7e-m/fpv5/hard;@mthumb@march=armv7e-m@mfpu=fpv5-d16@mfloat-abi=hard
thumb/v7-ar/fpv3/softfp;@mthumb@march=armv7@mfpu=vfpv3-d16@mfloat-abi=softfp
thumb/v7-ar/fpv3/hard;@mthumb@march=armv7@mfpu=vfpv3-d16@mfloat-abi=hard
thumb/v8-m.main/fpv5-sp/softfp;@mthumb@march=armv8-m.main@mfpu=fpv5-sp-d16@mfloat-abi=softfp
thumb/v8-m.main/fpv5-sp/hard;@mthumb@march=armv8-m.main@mfpu=fpv5-sp-d16@mfloat-abi=hard
thumb/v8-m.main/fpv5/softfp;@mthumb@march=armv8-m.main@mfpu=fpv5-d16@mfloat-abi=softfp
thumb/v8-m.main/fpv5/hard;@mthumb@march=armv8-m.main@mfpu=fpv5-d16@mfloat-abi=hard
有一个匹配我的参数的配置:
thumb/v7e-m/fpv4-sp/hard;@mthumb@march=armv7e-m@mfpu=fpv4-sp-d16@mfloat-abi=hard
任何人都知道我的配置有什么问题?
答案 0 :(得分:2)
一位同事发现了这个问题。出于某些原因,我们需要更改编译器规范。为此,我们将其添加到链接命令行:-specs = ... / specs
我们使用以下命令<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="actionMenuTextColor">@color/text_color</item>
</style>
问题是编译器的新版本有新规格,所以我们必须再次生成它们,这解决了这个问题。