-
-
Notifications
You must be signed in to change notification settings - Fork 2
211 lines (182 loc) · 7.95 KB
/
Copy pathinvoke_crosstool.yaml
File metadata and controls
211 lines (182 loc) · 7.95 KB
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
---
name: (internal) Invoke `crosstool-ng`
on:
workflow_call:
inputs:
crosstool_host_os: { type: string, required: true }
build_host: { type: string, required: true }
target_host: { type: string, required: true }
build_script: { type: string, required: true }
fetch_bootstrap: { type: boolean, required: false, default: true }
toolchain_suffix: { type: string, required: false, default: "" }
phase_number: { type: number, required: true }
script_args: { type: string, required: false, default: "+finish" }
restore_state: { type: boolean, required: false, default: true }
save_state: { type: boolean, required: false, default: true }
toolchain_tarball: { type: boolean, required: false, default: false }
env:
TC_WORKDIR: "/t"
EXECUTE_UNDER_DOCKER: true
GIT_DISCOVERY_ACROSS_FILESYSTEM: true
jobs:
invoke-crosstool:
name: ${{ inputs.phase_number }}. ct-ng ${{ inputs.script_args }}
runs-on: ubuntu-latest
steps:
- name: Fixup memory overcommit
run: |
set -x
cat /proc/sys/vm/overcommit_memory
sudo sysctl -w vm.overcommit_memory=2
cat /proc/sys/vm/overcommit_memory
- name: Maximize build space
uses: tzarc/maximize-build-space@btrfs-mods
with:
btrfs-compression: "true"
build-mount-path: /b
root-reserve-mb: 2048
swap-size-mb: 8192
remove-dotnet: "true"
remove-android: "true"
remove-haskell: "true"
remove-codeql: "true"
remove-docker-images: "true"
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y bc
- name: Clone toolchains repo
uses: actions/checkout@v7
- name: Setup workdir
run: |
set -x
# Shorten the path to `/t` because the normal path to the workspace is too long for some build configurations
sudo mkdir $TC_WORKDIR
sudo mount --bind $GITHUB_WORKSPACE $TC_WORKDIR
- name: Look at all this space for activities
run: |
set -x
sudo free -h
sudo swapon --show
sudo df -h
sudo mount | column -t
- name: Download source tarballs
uses: actions/download-artifact@v8
with:
name: tarballs
- name: Extract source tarballs
run: |
set -x
df -h .
tar axf tarballs.tar.zst
- name: Download bootstrap toolchain
if: inputs.fetch_bootstrap == true
uses: actions/download-artifact@v8
with:
name: toolchain-host_${{ inputs.crosstool_host_os }}-target_${{ inputs.crosstool_host_os }}_qmk_bootstrap
- name: Extract bootstrap toolchain
if: inputs.fetch_bootstrap == true
run: |
set -x
mkdir -p toolchains
tar avxf qmk_toolchain*host_${{ inputs.crosstool_host_os }}-target_${{ inputs.crosstool_host_os }}_qmk_bootstrap.tar.zst -C toolchains
rm qmk_toolchain*host_${{ inputs.crosstool_host_os }}-target_${{ inputs.crosstool_host_os }}_qmk_bootstrap.tar.zst
- name: Determine previous phase number
if: inputs.restore_state == true
run: |
echo LAST_PHASE_NUMBER=$((${{ inputs.phase_number }} - 1)) >> $GITHUB_ENV
- name: Download build state
if: inputs.restore_state == true
uses: actions/download-artifact@v8
with:
name: state-host_${{ inputs.build_host }}-target_${{ inputs.target_host }}${{ inputs.toolchain_suffix }}-phase${{ env.LAST_PHASE_NUMBER }}
- name: Extract build state
if: inputs.restore_state == true
run: |
set -x
cd $TC_WORKDIR
# Ensure tarballs are extracted before we restore state as we've deleted $CT_COMMON_SRC_DIR before saving the state tarball
./${{ inputs.build_script }} +companion_tools_for_build
# Extract the state tarball
tar axf state.tar.zst
- name: Look at all this space for activities (pre-build)
if: always() && !cancelled()
run: |
set -x
sudo free -h
sudo swapon --show
sudo df -h
sudo mount | column -t
- name: Build toolchain
run: |
(while true; do
echo "[$(date +%H:%M:%S)] Mem: $(free -h | grep Mem | awk '{print $3"/"$2}') Swap: $(free -h | grep Swap | awk '{print $3"/"$2}')"
# Check if we're in the critical linking phase
if pgrep -f "collect2.*cc1\|collect2.*lto1" > /dev/null; then
echo "[$(date +%H:%M:%S)] *** CRITICAL: cc1/lto1 linking in progress ***"
fi
sleep 10
done) &
MONITOR_PID=$!
set -x
cd $TC_WORKDIR
# Kick off the requested build phase (kill after 5h45m so logs can be gathered)
timeout 19800 ./${{ inputs.build_script }} ${{ inputs.script_args }}
kill $MONITOR_PID 2>/dev/null || true
- name: Look at all this space for activities (post-build)
if: always() && !cancelled()
run: |
set -x
sudo free -h
sudo swapon --show
sudo df -h
sudo mount | column -t
- name: Gather build logs
if: always() && !cancelled()
run: |
set -x
find . \( -name \*.log \) -print0 | xargs -0 tar acvf build_logs.tar.zst || true
- name: Upload build logs
uses: actions/upload-artifact@v7
if: always() && !cancelled()
with:
name: build.log-host_${{ inputs.build_host }}-target_${{ inputs.target_host }}${{ inputs.toolchain_suffix }}-phase${{ inputs.phase_number }}
path: |
build_logs.tar.zst
- name: Make build state
if: inputs.save_state == true
run: |
set -x
# We're saving state so we can resume at each step -- some of the internal build directories can be blown away as restarting from a step will recreate them.
latest_state=$(dirname $(find $(find build -mindepth 4 -maxdepth 5 -type d -name state) -mindepth 2 -maxdepth 2 -type f -name env.sh -print0 | xargs -0r stat -c '%w|%n' | sort | cut -d'|' -f2 | tail -n1))
tar acf state.tar $latest_state
zstdmt -T0 -19 --long --rm --force state.tar
- name: Upload build state
if: inputs.save_state == true
uses: actions/upload-artifact@v7
with:
name: state-host_${{ inputs.build_host }}-target_${{ inputs.target_host }}${{ inputs.toolchain_suffix }}-phase${{ inputs.phase_number }}
path: state.tar.zst
overwrite: true
- name: Make toolchain tarball
if: inputs.toolchain_tarball == true
run: |
set -x
if [[ "${{ inputs.build_host }}" == "windowsX64" ]] || [[ "${{ inputs.build_host }}" == "windowsARM64" ]]; then
export DEREF_SYMLINKS_ARGS="--dereference --hard-dereference"
fi
latest_state=$(dirname $(find $(find build -mindepth 4 -maxdepth 5 -type d -name state) -mindepth 2 -maxdepth 2 -type f -name env.sh -print0 | xargs -0r stat -c '%w|%n' | sort | cut -d'|' -f2 | tail -n1))
source "$latest_state/env.sh"
tar avcf qmk_toolchain-gcc${CT_GCC_VERSION}-host_${{ inputs.build_host }}-target_${{ inputs.target_host }}${{ inputs.toolchain_suffix }}.tar.zst -C toolchains host_${{ inputs.build_host }}-target_${{ inputs.target_host }}${{ inputs.toolchain_suffix }} ${DEREF_SYMLINKS_ARGS:-}
- name: Upload toolchain
if: inputs.toolchain_tarball == true
uses: actions/upload-artifact@v7
with:
name: toolchain-host_${{ inputs.build_host }}-target_${{ inputs.target_host }}${{ inputs.toolchain_suffix }}
path: |
qmk_toolchain-gcc*-host_${{ inputs.build_host }}-target_${{ inputs.target_host }}${{ inputs.toolchain_suffix }}.tar.zst
- name: Space, the final job step
run: |
set -x
sudo df -h
sudo mount | column -t