diff options
Diffstat (limited to 'recipes-security/optee-imx/optee-os/0001-optee-os-fix-gcc10-compilation-issue-and-missing-cc-.patch')
-rw-r--r-- | recipes-security/optee-imx/optee-os/0001-optee-os-fix-gcc10-compilation-issue-and-missing-cc-.patch | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/recipes-security/optee-imx/optee-os/0001-optee-os-fix-gcc10-compilation-issue-and-missing-cc-.patch b/recipes-security/optee-imx/optee-os/0001-optee-os-fix-gcc10-compilation-issue-and-missing-cc-.patch new file mode 100644 index 00000000..509c7fb6 --- /dev/null +++ b/recipes-security/optee-imx/optee-os/0001-optee-os-fix-gcc10-compilation-issue-and-missing-cc-.patch | |||
@@ -0,0 +1,158 @@ | |||
1 | From 027a3b9a33fbb23e1d1d7ed6411d4d112d2a55a1 Mon Sep 17 00:00:00 2001 | ||
2 | From: Andrey Zhizhikin <andrey.z@gmail.com> | ||
3 | Date: Sat, 30 May 2020 22:00:59 +0000 | ||
4 | Subject: [PATCH] optee-os: fix gcc10 compilation issue and missing cc-options | ||
5 | |||
6 | Backport PR 3891 from upstream to imx fork, which addressed compilation | ||
7 | failure when GCC10 is used. | ||
8 | |||
9 | Additional changes ported fixed cc-options macro, which allows to query | ||
10 | compiler used if the desired option exists before it could be set. This | ||
11 | solves also the build issues when GCC9 is used to build this component. | ||
12 | |||
13 | Upstream-Status: Backport [https://github.com/OP-TEE/optee_os/pull/3891] | ||
14 | |||
15 | Signed-off-by: Andrey Zhizhikin <andrey.z@gmail.com> | ||
16 | --- | ||
17 | core/arch/arm/arm.mk | 21 ++++++++++++++++----- | ||
18 | core/core.mk | 5 +---- | ||
19 | mk/cc-option.mk | 9 +++++++++ | ||
20 | mk/gcc.mk | 2 +- | ||
21 | ta/mk/ta_dev_kit.mk | 3 +++ | ||
22 | ta/ta.mk | 1 + | ||
23 | 6 files changed, 31 insertions(+), 10 deletions(-) | ||
24 | create mode 100644 mk/cc-option.mk | ||
25 | |||
26 | diff --git a/core/arch/arm/arm.mk b/core/arch/arm/arm.mk | ||
27 | index aa101be8..4123d85d 100644 | ||
28 | --- a/core/arch/arm/arm.mk | ||
29 | +++ b/core/arch/arm/arm.mk | ||
30 | @@ -1,3 +1,16 @@ | ||
31 | +# Setup compiler for the core module | ||
32 | +ifeq ($(CFG_ARM64_core),y) | ||
33 | +arch-bits-core := 64 | ||
34 | +else | ||
35 | +arch-bits-core := 32 | ||
36 | +endif | ||
37 | +CROSS_COMPILE_core := $(CROSS_COMPILE$(arch-bits-core)) | ||
38 | +COMPILER_core := $(COMPILER) | ||
39 | +include mk/$(COMPILER_core).mk | ||
40 | + | ||
41 | +# Defines the cc-option macro using the compiler set for the core module | ||
42 | +include mk/cc-option.mk | ||
43 | + | ||
44 | CFG_LTC_OPTEE_THREAD ?= y | ||
45 | # Size of emulated TrustZone protected SRAM, 448 kB. | ||
46 | # Only applicable when paging is enabled. | ||
47 | @@ -88,7 +101,7 @@ arm32-platform-aflags-no-hard-float ?= | ||
48 | |||
49 | arm64-platform-cflags-no-hard-float ?= -mgeneral-regs-only | ||
50 | arm64-platform-cflags-hard-float ?= | ||
51 | -arm64-platform-cflags-generic ?= -mstrict-align | ||
52 | +arm64-platform-cflags-generic := -mstrict-align $(call cc-option,-mno-outline-atomics,) | ||
53 | |||
54 | ifeq ($(DEBUG),1) | ||
55 | # For backwards compatibility | ||
56 | @@ -117,14 +130,12 @@ core-platform-aflags += $(platform-aflags-generic) | ||
57 | core-platform-aflags += $(platform-aflags-debug-info) | ||
58 | |||
59 | ifeq ($(CFG_ARM64_core),y) | ||
60 | -arch-bits-core := 64 | ||
61 | core-platform-cppflags += $(arm64-platform-cppflags) | ||
62 | core-platform-cflags += $(arm64-platform-cflags) | ||
63 | core-platform-cflags += $(arm64-platform-cflags-generic) | ||
64 | core-platform-cflags += $(arm64-platform-cflags-no-hard-float) | ||
65 | core-platform-aflags += $(arm64-platform-aflags) | ||
66 | else | ||
67 | -arch-bits-core := 32 | ||
68 | core-platform-cppflags += $(arm32-platform-cppflags) | ||
69 | core-platform-cflags += $(arm32-platform-cflags) | ||
70 | core-platform-cflags += $(arm32-platform-cflags-no-hard-float) | ||
71 | @@ -196,5 +207,5 @@ ta-mk-file-export-add-ta_arm64 += CROSS_COMPILE64 ?= $$(CROSS_COMPILE)_nl_ | ||
72 | ta-mk-file-export-add-ta_arm64 += CROSS_COMPILE_ta_arm64 ?= $$(CROSS_COMPILE64)_nl_ | ||
73 | endif | ||
74 | |||
75 | -# Set cross compiler prefix for each submodule | ||
76 | -$(foreach sm, core $(ta-targets), $(eval CROSS_COMPILE_$(sm) ?= $(CROSS_COMPILE$(arch-bits-$(sm))))) | ||
77 | +# Set cross compiler prefix for each TA target | ||
78 | +$(foreach sm, $(ta-targets), $(eval CROSS_COMPILE_$(sm) ?= $(CROSS_COMPILE$(arch-bits-$(sm))))) | ||
79 | diff --git a/core/core.mk b/core/core.mk | ||
80 | index c05815f3..68f45552 100644 | ||
81 | --- a/core/core.mk | ||
82 | +++ b/core/core.mk | ||
83 | @@ -8,6 +8,7 @@ arch-dir := core/arch/$(ARCH) | ||
84 | platform-dir := $(arch-dir)/plat-$(PLATFORM) | ||
85 | include $(platform-dir)/conf.mk | ||
86 | include mk/config.mk | ||
87 | +# $(ARCH).mk also sets the compiler for the core module | ||
88 | include core/arch/$(ARCH)/$(ARCH).mk | ||
89 | |||
90 | PLATFORM_$(PLATFORM) := y | ||
91 | @@ -16,10 +17,6 @@ PLATFORM_FLAVOR_$(PLATFORM_FLAVOR) := y | ||
92 | $(call cfg-depends-all,CFG_PAGED_USER_TA,CFG_WITH_PAGER CFG_WITH_USER_TA) | ||
93 | include core/crypto.mk | ||
94 | |||
95 | -# Setup compiler for this sub module | ||
96 | -COMPILER_$(sm) ?= $(COMPILER) | ||
97 | -include mk/$(COMPILER_$(sm)).mk | ||
98 | - | ||
99 | cppflags$(sm) += -D__KERNEL__ | ||
100 | |||
101 | cppflags$(sm) += -Icore/include | ||
102 | diff --git a/mk/cc-option.mk b/mk/cc-option.mk | ||
103 | new file mode 100644 | ||
104 | index 00000000..4699fbcc | ||
105 | --- /dev/null | ||
106 | +++ b/mk/cc-option.mk | ||
107 | @@ -0,0 +1,9 @@ | ||
108 | +_cc-option-supported = $(if $(shell $(CC$(sm)) $(1) -c -x c /dev/null -o /dev/null 2>/dev/null >/dev/null || echo "Not supported"),,1) | ||
109 | +_cc-opt-cached-var-name = $(subst =,~,$(strip cached-cc-option-$(1)-$(subst $(empty) $(empty),,$(CC$(sm))))) | ||
110 | +define _cc-option | ||
111 | +$(eval _var_name := $(call _cc-opt-cached-var-name,$(1))) | ||
112 | +$(eval $(_var_name) := $(if $(filter $(origin $(_var_name)),undefined),$(call _cc-option-supported,$(1)),$($(_var_name)))) | ||
113 | +$(if $($(_var_name)),$(1),$(2)) | ||
114 | +endef | ||
115 | +cc-option = $(strip $(call _cc-option,$(1),$(2))) | ||
116 | + | ||
117 | diff --git a/mk/gcc.mk b/mk/gcc.mk | ||
118 | index 1f2c5990..c53a23b1 100644 | ||
119 | --- a/mk/gcc.mk | ||
120 | +++ b/mk/gcc.mk | ||
121 | @@ -12,7 +12,7 @@ nostdinc$(sm) := -nostdinc -isystem $(shell $(CC$(sm)) \ | ||
122 | -print-file-name=include 2> /dev/null) | ||
123 | |||
124 | # Get location of libgcc from gcc | ||
125 | -libgcc$(sm) := $(shell $(CC$(sm)) $(CFLAGS$(arch-bits-$(sm))) $(comp-cflags$(sm)) \ | ||
126 | +libgcc$(sm) := $(shell $(CC$(sm)) $(CFLAGS$(arch-bits-$(sm))) \ | ||
127 | -print-libgcc-file-name 2> /dev/null) | ||
128 | |||
129 | # Define these to something to discover accidental use | ||
130 | diff --git a/ta/mk/ta_dev_kit.mk b/ta/mk/ta_dev_kit.mk | ||
131 | index fa0bddfe..ae70ef87 100644 | ||
132 | --- a/ta/mk/ta_dev_kit.mk | ||
133 | +++ b/ta/mk/ta_dev_kit.mk | ||
134 | @@ -78,6 +78,9 @@ clean: | ||
135 | @$(cmd-echo-silent) ' CLEAN $(O)' | ||
136 | ${q}if [ -d "$(O)" ]; then $(RMDIR) $(O); fi | ||
137 | |||
138 | +include $(ta-dev-kit-dir$(sm))/mk/$(COMPILER_$(sm)).mk | ||
139 | +include $(ta-dev-kit-dir$(sm))/mk/cc-option.mk | ||
140 | + | ||
141 | subdirs = . | ||
142 | include $(ta-dev-kit-dir)/mk/subdir.mk | ||
143 | |||
144 | diff --git a/ta/ta.mk b/ta/ta.mk | ||
145 | index 32353de3..9c64319d 100644 | ||
146 | --- a/ta/ta.mk | ||
147 | +++ b/ta/ta.mk | ||
148 | @@ -98,6 +98,7 @@ $(foreach f, $(libfiles), \ | ||
149 | |||
150 | # Copy .mk files | ||
151 | ta-mkfiles = mk/compile.mk mk/subdir.mk mk/gcc.mk mk/cleandirs.mk \ | ||
152 | + mk/cc-option.mk \ | ||
153 | ta/arch/$(ARCH)/link.mk ta/arch/$(ARCH)/link_shlib.mk \ | ||
154 | ta/mk/ta_dev_kit.mk | ||
155 | |||
156 | -- | ||
157 | 2.17.1 | ||
158 | |||