From 51312f70fde779f59dcc48b41132291c10d3ad0b Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 23 Nov 2023 11:44:14 +0700 Subject: [PATCH] move make to examples/build_system add -Wl,--no-warn-rwx-segment for gcc 12+ --- .../build_system}/make/cpu/arm1176.mk | 0 .../build_system}/make/cpu/cortex-a53.mk | 0 .../build_system}/make/cpu/cortex-a72.mk | 0 .../build_system}/make/cpu/cortex-m0.mk | 0 .../build_system}/make/cpu/cortex-m0plus.mk | 0 .../build_system}/make/cpu/cortex-m3.mk | 0 .../build_system}/make/cpu/cortex-m33.mk | 0 .../build_system}/make/cpu/cortex-m4.mk | 0 .../build_system}/make/cpu/cortex-m7.mk | 0 .../build_system}/make/toolchain/arm_gcc.mk | 9 ++++++++- .../make/toolchain/arm_gcc_rules.mk | 0 .../build_system}/make/toolchain/arm_iar.mk | 0 .../make/toolchain/arm_iar_rules.mk | 0 examples/make.mk | 18 ++++++++---------- examples/rules.mk | 2 +- tools/build_family.py | 3 ++- 16 files changed, 19 insertions(+), 13 deletions(-) rename {tools => examples/build_system}/make/cpu/arm1176.mk (100%) rename {tools => examples/build_system}/make/cpu/cortex-a53.mk (100%) rename {tools => examples/build_system}/make/cpu/cortex-a72.mk (100%) rename {tools => examples/build_system}/make/cpu/cortex-m0.mk (100%) rename {tools => examples/build_system}/make/cpu/cortex-m0plus.mk (100%) rename {tools => examples/build_system}/make/cpu/cortex-m3.mk (100%) rename {tools => examples/build_system}/make/cpu/cortex-m33.mk (100%) rename {tools => examples/build_system}/make/cpu/cortex-m4.mk (100%) rename {tools => examples/build_system}/make/cpu/cortex-m7.mk (100%) rename {tools => examples/build_system}/make/toolchain/arm_gcc.mk (87%) rename {tools => examples/build_system}/make/toolchain/arm_gcc_rules.mk (100%) rename {tools => examples/build_system}/make/toolchain/arm_iar.mk (100%) rename {tools => examples/build_system}/make/toolchain/arm_iar_rules.mk (100%) diff --git a/tools/make/cpu/arm1176.mk b/examples/build_system/make/cpu/arm1176.mk similarity index 100% rename from tools/make/cpu/arm1176.mk rename to examples/build_system/make/cpu/arm1176.mk diff --git a/tools/make/cpu/cortex-a53.mk b/examples/build_system/make/cpu/cortex-a53.mk similarity index 100% rename from tools/make/cpu/cortex-a53.mk rename to examples/build_system/make/cpu/cortex-a53.mk diff --git a/tools/make/cpu/cortex-a72.mk b/examples/build_system/make/cpu/cortex-a72.mk similarity index 100% rename from tools/make/cpu/cortex-a72.mk rename to examples/build_system/make/cpu/cortex-a72.mk diff --git a/tools/make/cpu/cortex-m0.mk b/examples/build_system/make/cpu/cortex-m0.mk similarity index 100% rename from tools/make/cpu/cortex-m0.mk rename to examples/build_system/make/cpu/cortex-m0.mk diff --git a/tools/make/cpu/cortex-m0plus.mk b/examples/build_system/make/cpu/cortex-m0plus.mk similarity index 100% rename from tools/make/cpu/cortex-m0plus.mk rename to examples/build_system/make/cpu/cortex-m0plus.mk diff --git a/tools/make/cpu/cortex-m3.mk b/examples/build_system/make/cpu/cortex-m3.mk similarity index 100% rename from tools/make/cpu/cortex-m3.mk rename to examples/build_system/make/cpu/cortex-m3.mk diff --git a/tools/make/cpu/cortex-m33.mk b/examples/build_system/make/cpu/cortex-m33.mk similarity index 100% rename from tools/make/cpu/cortex-m33.mk rename to examples/build_system/make/cpu/cortex-m33.mk diff --git a/tools/make/cpu/cortex-m4.mk b/examples/build_system/make/cpu/cortex-m4.mk similarity index 100% rename from tools/make/cpu/cortex-m4.mk rename to examples/build_system/make/cpu/cortex-m4.mk diff --git a/tools/make/cpu/cortex-m7.mk b/examples/build_system/make/cpu/cortex-m7.mk similarity index 100% rename from tools/make/cpu/cortex-m7.mk rename to examples/build_system/make/cpu/cortex-m7.mk diff --git a/tools/make/toolchain/arm_gcc.mk b/examples/build_system/make/toolchain/arm_gcc.mk similarity index 87% rename from tools/make/toolchain/arm_gcc.mk rename to examples/build_system/make/toolchain/arm_gcc.mk index bba0607df..071b13f68 100644 --- a/tools/make/toolchain/arm_gcc.mk +++ b/examples/build_system/make/toolchain/arm_gcc.mk @@ -9,6 +9,8 @@ GDB = $(CROSS_COMPILE)gdb OBJCOPY = $(CROSS_COMPILE)objcopy SIZE = $(CROSS_COMPILE)size +CC_VERSION := $(shell $(CC) -dumpversion) + # --------------------------------------- # Compiler Flags # --------------------------------------- @@ -65,7 +67,12 @@ LDFLAGS += \ -Wl,-cref \ -Wl,-gc-sections \ -# Some toolchain such as renesas rx does not support --print-memory-usage flags +# renesas rx does not support --print-memory-usage flags ifneq ($(FAMILY),rx) LDFLAGS += -Wl,--print-memory-usage endif + +# from version 12 +ifeq (12,$(firstword $(sort 12 $(CC_VERSION)))) +LDFLAGS += -Wl,--no-warn-rwx-segment +endif diff --git a/tools/make/toolchain/arm_gcc_rules.mk b/examples/build_system/make/toolchain/arm_gcc_rules.mk similarity index 100% rename from tools/make/toolchain/arm_gcc_rules.mk rename to examples/build_system/make/toolchain/arm_gcc_rules.mk diff --git a/tools/make/toolchain/arm_iar.mk b/examples/build_system/make/toolchain/arm_iar.mk similarity index 100% rename from tools/make/toolchain/arm_iar.mk rename to examples/build_system/make/toolchain/arm_iar.mk diff --git a/tools/make/toolchain/arm_iar_rules.mk b/examples/build_system/make/toolchain/arm_iar_rules.mk similarity index 100% rename from tools/make/toolchain/arm_iar_rules.mk rename to examples/build_system/make/toolchain/arm_iar_rules.mk diff --git a/examples/make.mk b/examples/make.mk index 448d7883d..b646b46ce 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -2,14 +2,10 @@ # Common make definition for all examples # --------------------------------------- -# Supported toolchain: gcc, iar -TOOLCHAIN ?= gcc - #-------------- TOP and CURRENT_PATH ------------ -# Set TOP to be the path to get from the current directory (where make was -# invoked) to the top of the tree. $(lastword $(MAKEFILE_LIST)) returns -# the name of this makefile relative to where make was invoked. +# Set TOP to be the path to get from the current directory (where make was invoked) to the top of the tree. +# $(lastword $(MAKEFILE_LIST)) returns the name of this makefile relative to where make was invoked. THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST)) # strip off /tools/top.mk to get for example ../../.. @@ -38,7 +34,6 @@ __check_defined = \ $(if $(value $1),, \ $(error Undefined make flag: $1$(if $2, ($2)))) - # Build directory BUILD := _build/$(BOARD) @@ -73,7 +68,10 @@ else SRC_C += $(subst $(TOP)/,,$(wildcard $(TOP)/$(FAMILY_PATH)/*.c)) endif -#-------------- Cross Compiler ------------ +#-------------- Toolchain ------------ + +# Supported toolchain: gcc, iar +TOOLCHAIN ?= gcc # Can be set by board, default to ARM GCC CROSS_COMPILE ?= arm-none-eabi- @@ -139,8 +137,8 @@ endif # CPU specific flags ifdef CPU_CORE -include $(TOP)/tools/make/cpu/$(CPU_CORE).mk + include ${TOP}/examples/build_system/make/cpu/$(CPU_CORE).mk endif # toolchain specific -include $(TOP)/tools/make/toolchain/arm_$(TOOLCHAIN).mk +include ${TOP}/examples/build_system/make/toolchain/arm_$(TOOLCHAIN).mk diff --git a/examples/rules.mk b/examples/rules.mk index 227849a18..b02665cdd 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -37,7 +37,7 @@ vpath %.c . $(TOP) vpath %.s . $(TOP) vpath %.S . $(TOP) -include $(TOP)/tools/make/toolchain/arm_$(TOOLCHAIN)_rules.mk +include ${TOP}/examples/build_system/make/toolchain/arm_$(TOOLCHAIN)_rules.mk OBJ_DIRS = $(sort $(dir $(OBJ))) diff --git a/tools/build_family.py b/tools/build_family.py index fb90e0edb..cd9884313 100644 --- a/tools/build_family.py +++ b/tools/build_family.py @@ -34,6 +34,7 @@ def build_family(example, family, make_option): # sum all element of same index (column sum) return list(map(sum, list(zip(*result)))) + if __name__ == '__main__': # IAR CC if make_iar_option not in sys.argv: @@ -44,7 +45,7 @@ if __name__ == '__main__': for d in os.scandir("examples"): if d.is_dir() and 'cmake' not in d.name: for entry in os.scandir(d.path): - if entry.is_dir() and 'cmake' not in entry.name: + if entry.is_dir() and 'cmake' not in entry.name and entry.name != 'build_system': all_examples.append(d.name + '/' + entry.name) filter_with_input(all_examples) all_examples.sort()