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