设为首页 加入收藏

TOP

UBOOT编译--- UBOOT的编译和链接选项详解(六)(四)
2023-07-23 13:30:30 】 浏览:137
Tags:UBOOT 编译 --- 项详解
KBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral) # Prohibit date/time macros, which would make the build non-deterministic KBUILD_CFLAGS += $(call cc-option,-Werror=date-time) # Report stack usage if supported ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-stack-usage.sh $(CC)),y) KBUILD_CFLAGS += -fstack-usage endif #(1) 顶层config.mk KBUILD_CFLAGS += $(KCFLAGS)

展开为:

KBUILD_CFLAGS=-Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -fshort-wchar -Os -fno-stack-protector -fno-delete-null-pointer-checks -g -fstack-usage -Wno-format-nonliteral -Werror=date-time

参数讲解见本文末尾参考小节

7. 预处理需要的编译选项$(cpp_flags)

#(1) 顶层config.mk
# Use UBOOTINCLUDE when you must reference the include/ directory.
# Needed to be compatible with the O= option
UBOOTINCLUDE    := \
		-Iinclude \
		$(if $(KBUILD_SRC), -I$(srctree)/include) \
		$(if $(CONFIG_$(SPL_)SYS_THUMB_BUILD), \
			$(if $(CONFIG_HAS_THUMB2),, \
				-I$(srctree)/arch/$(ARCH)/thumb1/include),) \
		-I$(srctree)/arch/$(ARCH)/include \          //-I./arch/arm/include
		-include $(srctree)/include/linux/kconfig.h  //-include ./include/linux/kconfig.h
		
......		

NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) 
// $(CC) -print-file-name=include : 打印GCC默认搜索include头文件的路径

......		

# FIX ME
cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) $(NOSTDINC_FLAGS)

预处理编译选项$(cpp_flags)定义在顶层Makefile中,主要由:编译系统kbuild需要的预处理选项 $(KBUILD_CPPFLAGS)、平台代码预处理需要的编译选项 $(PLATFORM_CPPFLAGS)、UBOOT要使用的头文件路径、CC默认搜索include头文件的路径组成。

展开为:

cpp_flags=-D__KERNEL__ -D__UBOOT__ -D__ARM__ -fno-pic -mstrict-align -ffunction-sections -fdata-sections -fno-common -ffixed-r9 -fno-common -ffixed-x18 -pipe -march=armv8-a -mgeneral-regs-only -D__LINUX_ARM_ARCH__=8 -Iinclude -I./arch/arm/include -include ./include/linux/kconfig.h -nostdinc -isystem /home/h/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/7.3.1/include

8. 编译需要的编译选项$(c_flags)

#(1) 顶层config.mk
c_flags := $(KBUILD_CFLAGS) $(cpp_flags)

编译选项$(c_flags)定义在顶层Makefile中,主要由 $(KBUILD_CFLAGS) (编译系统kbuild需要的编译选项)和 $(cpp_flags)(uboot整体代码预处理需要的编译选项)组成。

展开为:

c_flags=-Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -fshort-wchar -Os -fno-stack-protector -fno-delete-null-pointer-checks -g -fstack-usage -Wno-format-nonliteral -Werror=date-time -D__KERNEL__ -D__UBOOT__ -D__ARM__ -fno-pic -mstrict-align -ffunction-sections -fdata-sections -fno-common -ffixed-r9 -fno-common -ffixed-x18 -pipe -march=armv8-a -mgeneral-regs-only -D__LINUX_ARM_ARCH__=8 -Iinclude -I./arch/arm/include -include ./include/linux/kconfig.h -nostdinc -isystem /home/h/my-work/03_toolchain/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/../lib/gcc/aarch64-linux-gnu/7.3.1/include

参数讲解见本文末尾参考小节

9. 链接需要的编译选项$(LDFLAGS_FINAL)

#(1) 顶层config.mk
LDFLAGS_FINAL :=
......
LDFLAGS_FINAL += -Bstatic

export LDFLAGS_FINAL

#(2) arch/arm/config.mk
LDFLAGS_FINAL += --gc-sections

展开为:

LDFLAGS_FINAL= --gc-sections -Bstatic  //指定从-L指定的目录列表中查找libfoo.a

参数讲解见本文末尾参考小节

10. 参考

[1] -Wall:打开全部编译告警;
[2] -Wstrict-prototypes:如果在未指定参数类型的情况下声明或定义函数,则发出警告。 (如果前面有一个指定参数类型的声明,则允许在没有警告的情

首页 上一页 1 2 3 4 5 下一页 尾页 4/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇痞子衡嵌入式:对比恩智浦全系列M.. 下一篇UBOOT编译--- UBOOT编译过程目标..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目