-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0094-esp-ci-Adds-Linux-build.patch
246 lines (228 loc) · 9.31 KB
/
0094-esp-ci-Adds-Linux-build.patch
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
From 0977b82d60497ac42f507b6512477ac8d722a5f1 Mon Sep 17 00:00:00 2001
From: Andrei Safronov <safronov@espressif.com>
Date: Wed, 5 Apr 2023 00:59:25 +0300
Subject: [PATCH 094/158] esp/ci: Adds Linux build
---
.gitlab-ci.yml | 145 ++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 114 insertions(+), 31 deletions(-)
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 94f59533db5a..2a7be284f5b8 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -4,19 +4,26 @@ stages:
- test
- public_deploy
-image: ${CI_DOCKER_REGISTRY}/llvm-build:3
+image: ${CI_DOCKER_REGISTRY}/llvm-build:4-e2c59838
variables:
- CONF_TARGET: "xtensa-esp32-elf"
- XTENSA_CLANG_TOOLCHAIN: "${CONF_TARGET}-clang"
+ # move all these to CI/CD settings
+ GCC_REL_NAME: "esp-2021r2-patch3"
+ GCC_REL_VER: "gcc8_4_0"
+ XTENSA_CLANG_TOOLCHAIN_REF: "build_newlib_and_toolchain"
+ NEWLIB_REPO: "newlib-cygwin"
+ NEWLIB_REF: "esp_based_on_3_3_0"
+ BINUTILS_REPO: "binutils-gdb"
+ BINUTILS_REF: "esp_based_on_binutils-2_35"
+ XTENSA_OVERLAYS_REPO: "xtensa-overlays"
+ XTENSA_OVERLAYS_REF: "master"
+ LLVM_GCC_TESTSUITE_REF: "feature/toolchain_build_script"
+
PLATFORM_NAME_LINUX: "linux-amd64"
PLATFORM_NAME_WIN: "win64"
PLATFORM_NAME_MACOS: "macos"
- XTENSA_CLANG_TOOLCHAIN_BRANCH: "esp-20220415-r14.0.0"
- GCC_REL_NAME: "gcc8_4_0-esp-2021r2-patch3"
-
ARCHIVE_TOOL_LINUX: "tar -cJf"
UNARCHIVE_TOOL_LINUX: "tar -xf"
ARCHIVE_EXT_LINUX: "tar.xz"
@@ -30,6 +37,15 @@ variables:
ARCHIVE_EXT_MACOS: "tar.xz"
DIST_DIR: "dist"
+ DOWNLOADS_DIR: "_downloads"
+
+###########################################################################
+#################### START OF TEMPORARY LEGACY CODE #######################
+# TODO: the code below is to be removed after migration to new build script
+ CONF_TARGET: "xtensa-esp32-elf"
+ XTENSA_CLANG_TOOLCHAIN: "${CONF_TARGET}-clang"
+##################### END OF TEMPORARY LEGACY CODE ########################
+###########################################################################
.use_ci_tools: &use_ci_tools |
curl -sSL ${CIT_LOADER_URL} -o cit_loader.sh && sh cit_loader.sh
@@ -47,36 +63,108 @@ before_script:
# using annotated tags
REL_NUM=$(git describe --abbrev=7)
REL_SFX="llvm14_0_0"
- REL_NAME=${CONF_TARGET}-${REL_SFX}-${REL_NUM}-${PLATFORM_NAME}
+ REL_NAME=${REL_SFX}-${REL_NUM}-${PLATFORM_NAME}
ARCHIVE_NAME=${REL_NAME}.${ARCHIVE_EXT}
- echo "CONF_TARGET: $CONF_TARGET"
echo "PLATFORM_NAME: $PLATFORM_NAME"
echo "REL_NUM: $REL_NUM"
echo "REL_NAME: $REL_NAME"
echo "ARCHIVE_NAME: $ARCHIVE_NAME"
-# Get an existing crosstool-ng build for esp32
+# Get an existing crosstool-ng builds for all chips
.get_gcc_toolchain: &get_gcc_toolchain |
- wget --no-verbose https://dl.espressif.com/github_assets/espressif/crosstool-NG/releases/download/esp-2021r2-patch3/${XTENSA_GCC_TOOLCHAIN}
- ${UNARCHIVE_TOOL} ${XTENSA_GCC_TOOLCHAIN}
- mv xtensa-esp32-elf ${XTENSA_CLANG_TOOLCHAIN}
+ declare -a XTENSA_CPUS=("esp32"
+ "esp32s2"
+ "esp32s3")
+ for ((i = 0; i < ${#XTENSA_CPUS[@]}; i++)); do
+ XTENSA_CPU=${XTENSA_CPUS[$i]}
+ GCC_TOOLCHAIN_ARCH=xtensa-${XTENSA_CPU}-elf-${GCC_REL_VER}-${GCC_REL_NAME}-linux-amd64.tar.gz
+ wget --no-verbose https://dl.espressif.com/github_assets/espressif/crosstool-NG/releases/download/${GCC_REL_NAME}/${GCC_TOOLCHAIN_ARCH}
+ ${UNARCHIVE_TOOL} ${GCC_TOOLCHAIN_ARCH}
+ done;
+ GCC_TOOLCHAIN_ARCH=riscv32-esp-elf-${GCC_REL_VER}-${GCC_REL_NAME}-linux-amd64.tar.gz
+ wget --no-verbose https://dl.espressif.com/github_assets/espressif/crosstool-NG/releases/download/${GCC_REL_NAME}/${GCC_TOOLCHAIN_ARCH}
+ ${UNARCHIVE_TOOL} ${GCC_TOOLCHAIN_ARCH}
.get_clang_toolchain_build_scripts: &get_clang_toolchain_build_scripts |
- git clone -b ${XTENSA_CLANG_TOOLCHAIN_BRANCH} ${GITLAB_SSH_SERVER}/${XTENSA_CLANG_TOOLCHAIN_REPO}
+ git clone -b ${XTENSA_CLANG_TOOLCHAIN_REF} ${GITLAB_SSH_SERVER}/${XTENSA_CLANG_TOOLCHAIN_REPO}
cp -r xtensa-clang-toolchain/* .
# LLVM Build System used the remote address to show detailed version info, we'll change it to the public repository
.fix_origin_remote_for_public: &fix_origin_remote_for_public |
git remote set-url origin "${GH_REPO_HTTPS}"
- # Pack the toolchain
+# Pack the toolchain
.package_toolchain: &package_toolchain |
+ ${ARCHIVE_TOOL} ${ARCHIVE_NAME} esp-elf-clang/
+ mkdir -p ${DISTRO_DIR}
+ mv ${ARCHIVE_NAME} ${DISTRO_DIR}/
+ echo "${ARCHIVE_NAME}" > ${DISTRO_DIR}/file_${PLATFORM_NAME}
+
+.build_template:
+ stage: build
+ tags: [ "amd64", "build" ]
+ artifacts:
+ paths:
+ - ${DIST_DIR}/
+ - _build_Release/tests.log
+ when: always
+ expire_in: 1 day
+ script:
+ - *get_release_name
+ - mkdir ${DOWNLOADS_DIR}
+ - pushd ${DOWNLOADS_DIR}
+ - export ESP_GCC_TOOLCHAIN_DIST_BASE=$PWD
+ - *get_gcc_toolchain
+ - git clone -b ${NEWLIB_REF} --single-branch ${GITLAB_SSH_SERVER}/idf/${NEWLIB_REPO}.git
+ - export NEWLIB_PATH=$PWD/${NEWLIB_REPO}
+ - git clone -b ${BINUTILS_REF} --single-branch ${GITLAB_SSH_SERVER}/idf/${BINUTILS_REPO}.git
+ - export BINUTILS_PATH=$PWD/${BINUTILS_REPO}
+ - git clone -b ${XTENSA_OVERLAYS_REF} --single-branch ${GITLAB_SSH_SERVER}/idf/${XTENSA_OVERLAYS_REPO}.git
+ - export XTENSA_OVERLAYS_PATH=$PWD/${XTENSA_OVERLAYS_REPO}
+ - popd
+ - *get_clang_toolchain_build_scripts
+ - *fix_origin_remote_for_public
+ - export ESP_GCC_TOOLCHAIN_REL_VER=${GCC_REL_NAME}
+ - export LLVM_PROJECT_PATH=$PWD
+ - export ESP_CLANG_BUILD_TYPE=Release
+ - export BUILD_PATH=$PWD/_build_$ESP_CLANG_BUILD_TYPE
+ - ./build_toolchain.sh 2>&1 > /dev/null
+ # Run tests as non-root user
+ # permission tests fail when run by root
+ - useradd -m test_runner
+ - chown -R test_runner $BUILD_PATH
+ - runuser -l test_runner -c 'cmake --build '$BUILD_PATH'/clang --target check-all 2>&1 > '$BUILD_PATH'/tests.log'
+ - export DISTRO_DIR=$PWD/$DIST_DIR
+ - pushd $BUILD_PATH
+ - *package_toolchain
+ - popd
+
+###########################################################################
+#################### START OF TEMPORARY LEGACY CODE #######################
+# TODO: the code below is to be removed after migration to new build script
+.get_release_name_old: &get_release_name_old |
+ # using annotated tags
+ REL_NUM=$(git describe --abbrev=7)
+ REL_SFX="llvm14_0_0"
+ REL_NAME=${CONF_TARGET}-${REL_SFX}-${REL_NUM}-${PLATFORM_NAME}
+ ARCHIVE_NAME=${REL_NAME}.${ARCHIVE_EXT}
+ echo "PLATFORM_NAME: $PLATFORM_NAME"
+ echo "REL_NUM: $REL_NUM"
+ echo "REL_NAME: $REL_NAME"
+ echo "ARCHIVE_NAME: $ARCHIVE_NAME"
+
+.get_gcc_toolchain_old: &get_gcc_toolchain_old |
+ wget --no-verbose https://dl.espressif.com/github_assets/espressif/crosstool-NG/releases/download/esp-2021r2-patch3/${XTENSA_GCC_TOOLCHAIN}
+ ${UNARCHIVE_TOOL} ${XTENSA_GCC_TOOLCHAIN}
+ mv xtensa-esp32-elf ${XTENSA_CLANG_TOOLCHAIN}
+
+.package_toolchain_old: &package_toolchain_old |
${ARCHIVE_TOOL} ${ARCHIVE_NAME} ${XTENSA_CLANG_TOOLCHAIN}/
mkdir -p ${DIST_DIR}
mv ${ARCHIVE_NAME} ${DIST_DIR}/
echo "${ARCHIVE_NAME}" > ${DIST_DIR}/file_${PLATFORM_NAME}_${CONF_TARGET}
-.build_template:
+.build_template_old:
stage: build
tags: [ "amd64", "build" ]
artifacts:
@@ -85,12 +173,14 @@ before_script:
when: always
expire_in: 10 day
script:
- - *get_release_name
- - *get_gcc_toolchain
+ - *get_release_name_old
+ - *get_gcc_toolchain_old
- *fix_origin_remote_for_public
- *get_clang_toolchain_build_scripts
- ${BUILD_TOOLCHAIN_CMD} "${XTENSA_CLANG_TOOLCHAIN}"
- - *package_toolchain
+ - *package_toolchain_old
+##################### END OF TEMPORARY LEGACY CODE ########################
+###########################################################################
linux_amd64_build:
extends: .build_template
@@ -99,12 +189,9 @@ linux_amd64_build:
ARCHIVE_TOOL: "${ARCHIVE_TOOL_LINUX}"
UNARCHIVE_TOOL: "${UNARCHIVE_TOOL_LINUX}"
ARCHIVE_EXT: "${ARCHIVE_EXT_LINUX}"
- # a filename was moved here from the global 'variables:' because of GCC_REL_NAME value couldn't be expanded and substituted there
- XTENSA_GCC_TOOLCHAIN: "xtensa-esp32-elf-${GCC_REL_NAME}-linux-amd64.tar.gz"
- BUILD_TOOLCHAIN_CMD: "./build-toolchain-linux.sh"
win64_build:
- extends: .build_template
+ extends: .build_template_old
variables:
PLATFORM_NAME: "${PLATFORM_NAME_WIN}"
ARCHIVE_TOOL: "${ARCHIVE_TOOL_WIN}"
@@ -114,7 +201,7 @@ win64_build:
BUILD_TOOLCHAIN_CMD: "./build-toolchain-win.sh"
macos_amd64_build:
- extends: .build_template
+ extends: .build_template_old
variables:
PLATFORM_NAME: "${PLATFORM_NAME_MACOS}"
ARCHIVE_TOOL: "${ARCHIVE_TOOL_MACOS}"
@@ -136,17 +223,13 @@ linux_amd64_testsuite:
script:
- *get_release_name
- ${UNARCHIVE_TOOL} ${DIST_DIR}/${ARCHIVE_NAME}
-
- # getting testsuit
- - git clone -b feature/ci_llvm_multitarget --depth 1 $GITLAB_SSH_SERVER/idf/llvm-xtensa-testsuite.git
-
- # preparing testsuit
- - export PATH=$PATH:${PWD}/${XTENSA_CLANG_TOOLCHAIN}/bin/
+ # getting testsuite
+ - git clone -b ${LLVM_GCC_TESTSUITE_REF} --depth 1 $GITLAB_SSH_SERVER/idf/llvm-xtensa-testsuite.git
+ # preparing testsuite
+ - export PATH=${PWD}/esp-elf-clang/bin:$PATH
- cd llvm-xtensa-testsuite
-
# qemu
- ./qemu_esp32_install.sh
-
# run testsuite for esp32
- ./run_esp32_tests.sh
--
2.40.1