我正在尝试在我的waveshare stm32开发板上运行busybox,但我的SOC具有“armv7-m”架构而不是“armv7-a”。所以我将游行标志放入 busybox 的 menuconfig 中(-march=armv7-m) Additional CFLAGS
。但是当我尝试编译它时,它Conflicting architecture profiles M/A
在链接时为每个文件抛出了数千个此错误的瞬间。所以,我决定也为链接器添加这个标志(-march=armv7-m) Additional LDFLAGS
,但这没有帮助。
我的平台:
Host:
| OS: Ubuntu 20 LTS
| Kernel: Microsoft WSL2 Linux Kernel
| Cross compile Toolchain: Linaro latest stable version
|__
Target:
| Board: Waveshare CoreH7XXI
| SOC: stm32h743 (Single Core Cortex M7 @400MHz)
| Architecture: ARMV7-M
| Onboard DRAM: 8MB - 400KB(reserved by u-boot) = 7.6MB
| Linux Kernel: 5.8.10 (stable 2020-09-17)
| Busybox: latest stable version
|__
makefile日志(太长了,所以我删除了中间部分):
LINK busybox_unstripped
Your linker does not support --sort-section,alignment
Your linker does not support --sort-common
Static linking against glibc, can't use --gc-sections
Trying libraries: m resolv rt
Failed: -Wl,--start-group -lm -lresolv -lrt -Wl,--end-group
Output of:
arm-linux-gnueabihf-gcc -Wall -Wshadow -Wwrite-strings -Wundef -Wstrict-prototypes -Wunused -Wunused-parameter -Wunused-function -Wunused-value -Wmissing-prototypes -Wmissing-declarations -Wno-format-security -Wdeclaration-after-statement -Wold-style-definition -finline-limit=0 -fno-builtin-strlen -fomit-frame-pointer -ffunction-sections -fdata-sections -fno-guess-branch-probability -funsigned-char -static-libgcc -falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1 -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-builtin-printf -Os -march=armv7-m -static -march=armv7-m -o busybox_unstripped -Wl,--start-group applets/built-in.o archival/lib.a archival/libarchive/lib.a console-tools/lib.a coreutils/lib.a coreutils/libcoreutils/lib.a debianutils/lib.a klibc-utils/lib.a e2fsprogs/lib.a editors/lib.a findutils/lib.a init/lib.a libbb/lib.a libpwdgrp/lib.a loginutils/lib.a mailutils/lib.a miscutils/lib.a modutils/lib.a networking/lib.a networking/libiproute/lib.a networking/udhcp/lib.a printutils/lib.a procps/lib.a runit/lib.a selinux/lib.a shell/lib.a sysklogd/lib.a util-linux/lib.a util-linux/volume_id/lib.a archival/built-in.o archival/libarchive/built-in.o console-tools/built-in.o coreutils/built-in.o coreutils/libcoreutils/built-in.o debianutils/built-in.o klibc-utils/built-in.o e2fsprogs/built-in.o editors/built-in.o findutils/built-in.o init/built-in.o libbb/built-in.o libpwdgrp/built-in.o loginutils/built-in.o mailutils/built-in.o miscutils/built-in.o modutils/built-in.o networking/built-in.o networking/libiproute/built-in.o networking/udhcp/built-in.o printutils/built-in.o procps/built-in.o runit/built-in.o selinux/built-in.o shell/built-in.o sysklogd/built-in.o util-linux/built-in.o util-linux/volume_id/built-in.o -Wl,--end-group -Wl,--start-group -lm -lresolv -lrt -Wl,--end-group
==========
libbb/lib.a(inet_common.o): In function `INET6_resolve':
inet_common.c:(.text.INET6_resolve+0x22): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
coreutils/lib.a(mktemp.o): In function `mktemp_main':
mktemp.c:(.text.mktemp_main+0x4e): warning: the use of `mktemp' is dangerous, better use `mkstemp'
networking/lib.a(ipcalc.o): In function `ipcalc_main':
ipcalc.c:(.text.ipcalc_main+0x148): warning: Using 'gethostbyaddr' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
libbb/lib.a(inet_common.o): In function `INET_resolve':
inet_common.c:(.text.INET_resolve+0x2c): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
networking/lib.a(inetd.o): In function `reread_config_file':
inetd.c:(.text.reread_config_file+0x152): warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
networking/lib.a(netstat.o): In function `ip_port_str':
netstat.c:(.text.ip_port_str+0x2c): warning: Using 'getservbyport' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: error: applets/built-in.o: Conflicting architecture profiles M/A
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: failed to merge target specific data of file applets/built-in.o
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: error: libbb/lib.a(appletlib.o): Conflicting architecture profiles M/A
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: failed to merge target specific data of file libbb/lib.a(appletlib.o)
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: error: libbb/lib.a(compare_string_array.o): Conflicting architecture profiles M/A
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: failed to merge target specific data of file libbb/lib.a(compare_string_array.o)
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: error: libbb/lib.a(concat_path_file.o): Conflicting architecture profiles M/A
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: failed to merge target specific data of file libbb/lib.a(concat_path_file.o)
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: error: libbb/lib.a(default_error_retval.o): Conflicting architecture profiles M/A
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: failed to merge target specific data of file libbb/lib.a(default_error_retval.o)
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: error: libbb/lib.a(get_last_path_component.o): Conflicting architecture profiles M/A
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: failed to merge target specific data of file libbb/lib.a(get_last_path_component.o)
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: error: libbb/lib.a(last_char_is.o): Conflicting architecture profiles M/A
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: failed to merge target specific data of file libbb/lib.a(last_char_is.o)
.
.
.
.
.
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: failed to merge target specific data of file libbb/lib.a(xgethostbyname.o)
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: error: libbb/lib.a(xrealloc_vector.o): Conflicting architecture profiles M/A
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: failed to merge target specific data of file libbb/lib.a(xrealloc_vector.o)
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: error: libbb/lib.a(xregcomp.o): Conflicting architecture profiles M/A
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: failed to merge target specific data of file libbb/lib.a(xregcomp.o)
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: error: libbb/lib.a(perror_nomsg.o): Conflicting architecture profiles M/A
/opt/gcc-arm-linux/bin/../lib/gcc/arm-linux-gnueabihf/5.4.1/../../../../arm-linux-gnueabihf/bin/ld: failed to merge target specific data of file libbb/lib.a(perror_nomsg.o)
collect2: error: ld returned 1 exit status
Note: if build needs additional libraries, put them in CONFIG_EXTRA_LDLIBS.
Example: CONFIG_EXTRA_LDLIBS="pthread dl tirpc audit pam"
make: *** [Makefile:718: busybox_unstripped] Error 1
不添加arm-v7-m
标志,它会针对皮质 A 进行编译:
$ readelf -A busybox
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "7-A"
Tag_CPU_arch: v7
Tag_CPU_arch_profile: Application
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_FP_arch: VFPv3
Tag_Advanced_SIMD_arch: NEONv1
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_rounding: Needed
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: int
Tag_ABI_VFP_args: VFP registers
Tag_CPU_unaligned_access: v6
答案1
您应该使用-mcpu
flag 而不是-march
.
例子:
-mcpu=cortex-m7