summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>2020-05-30 22:27:24 +0000
committerOtavio Salvador <otavio@ossystems.com.br>2020-06-23 08:44:02 -0300
commitfb3c377da24217614c0e84a738c9e2f61742f54c (patch)
treea1a3965c98b6a865f01f982568e855edd3da7ba6
parentb354d998bff234fea016d4e14d937c5af7eaf150 (diff)
downloadmeta-freescale-fb3c377da24217614c0e84a738c9e2f61742f54c.tar.gz
optee-os: backport gcc10 compilation fix from upstream
Backport PR 3891 [1] from OP-TEE upstream repository. This PR solves GCC10 compilation issue when new compiler option `outline-atomics` is not implemented and causes the linker error. In addition, above upstream PR solves issue with 'cc-option` macro, which is necessary to be used to provide comptibility with GCC <10 to disable the `outline-atomics` option, since it is present only in GCC10. [1]: https://github.com/OP-TEE/optee_os/pull/3891 Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>
-rw-r--r--recipes-security/optee-imx/optee-os/0001-arm64-Disable-outline-atomics-when-compiling.patch64
-rw-r--r--recipes-security/optee-imx/optee-os/0001-optee-os-fix-gcc10-compilation-issue-and-missing-cc-.patch158
-rw-r--r--recipes-security/optee-imx/optee-os_3.2.0.imx.bb2
3 files changed, 159 insertions, 65 deletions
diff --git a/recipes-security/optee-imx/optee-os/0001-arm64-Disable-outline-atomics-when-compiling.patch b/recipes-security/optee-imx/optee-os/0001-arm64-Disable-outline-atomics-when-compiling.patch
deleted file mode 100644
index 605daccc..00000000
--- a/recipes-security/optee-imx/optee-os/0001-arm64-Disable-outline-atomics-when-compiling.patch
+++ /dev/null
@@ -1,64 +0,0 @@
1From ef5327d7e9d74a433b0a1f2ca2f4cf3953797350 Mon Sep 17 00:00:00 2001
2From: Andrey Zhizhikin <andrey.z@gmail.com>
3Date: Fri, 22 May 2020 21:01:15 +0000
4Subject: [PATCH] arm64: Disable outline-atomics when compiling
5
6This is a backport of upstream patch [1] with adaptions to optee-imx
7version in this layer.
8
9Original patch uses $(call cc-option,-mno-outline-atomics,) to disable
10outline-atomics which itself is broken and required 4 additional patches
11to be compatible with gcc and clang.
12
13This is resolved in the upstream PR [2], which is applicable to the
14latest upstream version.
15
16NXP fork contains old version of OP-TEE, and therefore would receive the
17update for Makefiles with new version. Since it is not required to make
18current NXP version compatible with old compiler versions on master
19branch - outline-atomics are disabled directly.
20
21Original patch description:
22---------------------------------------------------------------------
23Disables the automatic detection of LSE (Large System Extension)
24instructions when compiling AArch64 code. GCC 10 implements this
25detection in libgcc using __getauxval(), which optee doesn't implement.
26This requires that the proper -mcpu is passed to GCC so that the code
27can be correctly compiled to use either LSE or load-store-exclusive.
28
29Fixes linker errors like the following when compiling with GCC 10:
30
31 aarch64-linux-ld.bfd: libgcc.a(lse-init.o):
32 in function `init_have_lse_atomics':
33 lse-init.c:44: undefined reference to `__getauxval'
34 core/arch/arm/kernel/link.mk:38:
35 recipe for target 'build/core/all_objs.o' failed
36---------------------------------------------------------------------
37
38Upstream-Status: Backport [e07c2b062846df4385542f4e4fe08b40cf7d8191]
39
40Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
41
42[1]: https://github.com/OP-TEE/optee_os/pull/3891/commits/e07c2b062846df4385542f4e4fe08b40cf7d8191
43[2]: https://github.com/OP-TEE/optee_os/pull/3891
44Signed-off-by: Andrey Zhizhikin <andrey.z@gmail.com>
45---
46 core/arch/arm/arm.mk | 2 +-
47 1 file changed, 1 insertion(+), 1 deletion(-)
48
49diff --git a/core/arch/arm/arm.mk b/core/arch/arm/arm.mk
50index aa101be8..8cb2b2e2 100644
51--- a/core/arch/arm/arm.mk
52+++ b/core/arch/arm/arm.mk
53@@ -88,7 +88,7 @@ arm32-platform-aflags-no-hard-float ?=
54
55 arm64-platform-cflags-no-hard-float ?= -mgeneral-regs-only
56 arm64-platform-cflags-hard-float ?=
57-arm64-platform-cflags-generic ?= -mstrict-align
58+arm64-platform-cflags-generic ?= -mstrict-align -mno-outline-atomics
59
60 ifeq ($(DEBUG),1)
61 # For backwards compatibility
62--
632.17.1
64
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 @@
1From 027a3b9a33fbb23e1d1d7ed6411d4d112d2a55a1 Mon Sep 17 00:00:00 2001
2From: Andrey Zhizhikin <andrey.z@gmail.com>
3Date: Sat, 30 May 2020 22:00:59 +0000
4Subject: [PATCH] optee-os: fix gcc10 compilation issue and missing cc-options
5
6Backport PR 3891 from upstream to imx fork, which addressed compilation
7failure when GCC10 is used.
8
9Additional changes ported fixed cc-options macro, which allows to query
10compiler used if the desired option exists before it could be set. This
11solves also the build issues when GCC9 is used to build this component.
12
13Upstream-Status: Backport [https://github.com/OP-TEE/optee_os/pull/3891]
14
15Signed-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
26diff --git a/core/arch/arm/arm.mk b/core/arch/arm/arm.mk
27index 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)))))
79diff --git a/core/core.mk b/core/core.mk
80index 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
102diff --git a/mk/cc-option.mk b/mk/cc-option.mk
103new file mode 100644
104index 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+
117diff --git a/mk/gcc.mk b/mk/gcc.mk
118index 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
130diff --git a/ta/mk/ta_dev_kit.mk b/ta/mk/ta_dev_kit.mk
131index 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
144diff --git a/ta/ta.mk b/ta/ta.mk
145index 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--
1572.17.1
158
diff --git a/recipes-security/optee-imx/optee-os_3.2.0.imx.bb b/recipes-security/optee-imx/optee-os_3.2.0.imx.bb
index aeaa9b32..d2c82940 100644
--- a/recipes-security/optee-imx/optee-os_3.2.0.imx.bb
+++ b/recipes-security/optee-imx/optee-os_3.2.0.imx.bb
@@ -14,7 +14,7 @@ OPTEE_OS_SRC ?= "git://source.codeaurora.org/external/imx/imx-optee-os.git;proto
14SRC_URI = "\ 14SRC_URI = "\
15 ${OPTEE_OS_SRC};branch=${SRCBRANCH} \ 15 ${OPTEE_OS_SRC};branch=${SRCBRANCH} \
16 file://0001-scripts-update-scripts-to-use-python3.patch \ 16 file://0001-scripts-update-scripts-to-use-python3.patch \
17 file://0001-arm64-Disable-outline-atomics-when-compiling.patch \ 17 file://0001-optee-os-fix-gcc10-compilation-issue-and-missing-cc-.patch \
18" 18"
19 19
20SRCREV = "6d99b525af752ecdaabdca6098b2564b2665f2b2" 20SRCREV = "6d99b525af752ecdaabdca6098b2564b2665f2b2"