Skip to content

Commit 29c5e48

Browse files
committed
Set up builds of gcc 13.2.0 for major targets that QMK Firmware compilation supports.
0 parents  commit 29c5e48

22 files changed

+1554
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
name: Create Toolchain
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
runner_labels_json: { type: string, required: true }
8+
crosstool_host_os: { type: string, required: true }
9+
build_host: { type: string, required: true }
10+
target_host: { type: string, required: true }
11+
build_script: { type: string, required: true }
12+
canadian_build: { type: boolean, required: false, default: false }
13+
fetch_bootstrap: { type: boolean, required: false, default: true }
14+
toolchain_suffix: { type: string, required: false, default: "" }
15+
16+
jobs:
17+
# Split up the build as compiling newlib/libstdc++ targeting ARM takes so damn long.
18+
phase1:
19+
name: Build toolchain (phase 1)
20+
uses: ./.github/workflows/invoke_crosstool.yaml
21+
with:
22+
runner_labels_json: ${{ inputs.runner_labels_json }}
23+
crosstool_host_os: ${{ inputs.crosstool_host_os }}
24+
build_host: ${{ inputs.build_host }}
25+
target_host: ${{ inputs.target_host }}
26+
build_script: ${{ inputs.build_script }}
27+
canadian_build: ${{ inputs.canadian_build }}
28+
fetch_bootstrap: ${{ inputs.fetch_bootstrap }}
29+
toolchain_suffix: ${{ inputs.toolchain_suffix }}
30+
crosstool_args: 'build STOP=cc_for_build'
31+
restore_state: false
32+
phase_number: 1
33+
34+
phase2:
35+
name: Build toolchain (phase 2)
36+
needs: [phase1]
37+
uses: ./.github/workflows/invoke_crosstool.yaml
38+
with:
39+
runner_labels_json: ${{ inputs.runner_labels_json }}
40+
crosstool_host_os: ${{ inputs.crosstool_host_os }}
41+
build_host: ${{ inputs.build_host }}
42+
target_host: ${{ inputs.target_host }}
43+
build_script: ${{ inputs.build_script }}
44+
canadian_build: ${{ inputs.canadian_build }}
45+
fetch_bootstrap: ${{ inputs.fetch_bootstrap }}
46+
toolchain_suffix: ${{ inputs.toolchain_suffix }}
47+
crosstool_args: 'build RESTART=cc_for_host STOP=libc_post_cc'
48+
phase_number: 2
49+
50+
phase3:
51+
name: Build toolchain (phase 3)
52+
needs: [phase2]
53+
uses: ./.github/workflows/invoke_crosstool.yaml
54+
with:
55+
runner_labels_json: ${{ inputs.runner_labels_json }}
56+
crosstool_host_os: ${{ inputs.crosstool_host_os }}
57+
build_host: ${{ inputs.build_host }}
58+
target_host: ${{ inputs.target_host }}
59+
build_script: ${{ inputs.build_script }}
60+
canadian_build: ${{ inputs.canadian_build }}
61+
fetch_bootstrap: ${{ inputs.fetch_bootstrap }}
62+
toolchain_suffix: ${{ inputs.toolchain_suffix }}
63+
crosstool_args: 'build RESTART=companion_libs_for_target STOP=companion_libs_for_target'
64+
phase_number: 3
65+
66+
phase4:
67+
name: Build toolchain (phase 4)
68+
needs: [phase3]
69+
uses: ./.github/workflows/invoke_crosstool.yaml
70+
with:
71+
runner_labels_json: ${{ inputs.runner_labels_json }}
72+
crosstool_host_os: ${{ inputs.crosstool_host_os }}
73+
build_host: ${{ inputs.build_host }}
74+
target_host: ${{ inputs.target_host }}
75+
build_script: ${{ inputs.build_script }}
76+
canadian_build: ${{ inputs.canadian_build }}
77+
fetch_bootstrap: ${{ inputs.fetch_bootstrap }}
78+
toolchain_suffix: ${{ inputs.toolchain_suffix }}
79+
crosstool_args: 'build RESTART=binutils_for_target'
80+
save_state: false
81+
toolchain_tarball: true
82+
phase_number: 4
83+
84+
phase5:
85+
name: Build toolchain (phase 5)
86+
needs: [phase4]
87+
runs-on: ubuntu-latest
88+
89+
steps:
90+
- name: Delete build state
91+
uses: geekyeggo/delete-artifact@v4
92+
with:
93+
name: state-host_${{ inputs.build_host }}-target_${{ inputs.target_host }}${{ inputs.toolchain_suffix }}.tar
Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
---
2+
name: Create Toolchains
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
10+
jobs:
11+
crosstool:
12+
name: "Build crosstool-ng"
13+
runs-on: ${{ fromJSON(matrix.host_labels) }}
14+
strategy:
15+
matrix:
16+
runner: [linuxX64, macosX64, macosARM64]
17+
include:
18+
- runner: linuxX64
19+
host_labels: '["ubuntu-22.04"]'
20+
- runner: macosX64
21+
host_labels: '["macos-12"]'
22+
- runner: macosARM64
23+
host_labels: '["macos-14"]' #'["self-hosted", "macOS", "ARM64"]'
24+
25+
steps:
26+
- name: "Clone crosstool-ng repo"
27+
uses: actions/checkout@v4
28+
with:
29+
repository: crosstool-ng/crosstool-ng
30+
ref: master
31+
32+
- name: "Host info"
33+
run: |
34+
uname -a
35+
36+
- name: "Prerequisites (Linux)"
37+
if: ${{ runner.os == 'Linux' }}
38+
run: |
39+
sudo apt-get install -y gperf help2man libtool-bin meson ninja-build
40+
41+
- name: "Prerequisites (macOS)"
42+
if: ${{ runner.os == 'macOS' }}
43+
run: |
44+
brew install autoconf automake bash binutils coreutils gawk gnu-sed help2man libtool make meson ncurses pkg-config python3 texinfo
45+
46+
- name: "Build crosstool-ng"
47+
run: |
48+
if [ "$RUNNER_OS" == "macOS" ]; then
49+
export PATH="$PATH:/usr/local/opt/binutils/bin:/usr/local/opt/coreutils/bin:/usr/local/opt/libtool/libexec/gnubin"
50+
export CPPFLAGS="-I/usr/local/opt/ncurses/include -I/usr/local/opt/gettext/include"
51+
export LDFLAGS="-L/usr/local/opt/ncurses/lib -L/usr/local/opt/gettext/lib"
52+
export PATH="$PATH:/opt/homebrew/opt/binutils/bin:/opt/homebrew/opt/coreutils/bin:/opt/homebrew/opt/libtool/libexec/gnubin"
53+
export CPPFLAGS="$CPPFLAGS -I/opt/homebrew/opt/ncurses/include -I/opt/homebrew/opt/gettext/include"
54+
export LDFLAGS="$LDFLAGS -L/opt/homebrew/opt/ncurses/lib -L/opt/homebrew/opt/gettext/lib"
55+
fi
56+
./bootstrap
57+
./configure --prefix=$PWD/.local/
58+
make
59+
make install
60+
tar cf ct-ng.tar .local/
61+
62+
- name: "Upload crosstool-ng"
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: crosstool.${{ matrix.runner }}
66+
path: ct-ng.tar
67+
68+
tarballs:
69+
name: "Download required tarballs"
70+
needs: [crosstool]
71+
runs-on: ubuntu-22.04
72+
73+
steps:
74+
- name: "Clone toolchains repo"
75+
uses: actions/checkout@v4
76+
77+
- name: "Download copy of crosstool-ng"
78+
uses: actions/download-artifact@v4
79+
with:
80+
name: crosstool.linuxX64
81+
82+
- name: "Extract copy of crosstool-ng"
83+
run: |
84+
tar xf ct-ng.tar
85+
86+
- name: "Prerequisites (Linux)"
87+
if: ${{ runner.os == 'Linux' }}
88+
run: |
89+
sudo apt-get install -y gperf help2man libtool-bin
90+
echo "$GITHUB_WORKSPACE/.local/bin" >> $GITHUB_PATH
91+
92+
- name: "Gather source tarballs"
93+
run: |
94+
for f in $(ls *.sh); do ./$f source; done
95+
tar cvf tarballs.tar tarballs
96+
97+
- name: "Upload source tarballs"
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: tarballs.tar
101+
path: tarballs.tar
102+
103+
# Build a copy of linux/X64 toolchain to bootstrap the rest so that the resulting compilers are compatible with the old glibc.
104+
bootstrap-linuxX64-toolchain:
105+
name: "Build bootstrap linuxX64 toolchain"
106+
needs: [tarballs]
107+
uses: ./.github/workflows/create_one_toolchain.yaml
108+
with:
109+
runner_labels_json: '["ubuntu-22.04"]'
110+
crosstool_host_os: linuxX64
111+
build_host: linuxX64
112+
target_host: linuxX64
113+
build_script: x64linux-native-bootstrap.sh
114+
fetch_bootstrap: false
115+
toolchain_suffix: "_qmk_bootstrap"
116+
117+
canadian-host-toolchains:
118+
name: "Build canadian host toolchains"
119+
needs: [bootstrap-linuxX64-toolchain]
120+
strategy:
121+
fail-fast: false
122+
matrix:
123+
target_host: [linuxARM64, windowsX64]
124+
include:
125+
- target_host: linuxARM64
126+
build_script: aarch64linux-native.sh
127+
- target_host: windowsX64
128+
build_script: win64-native.sh
129+
uses: ./.github/workflows/create_one_toolchain.yaml
130+
with:
131+
runner_labels_json: '["ubuntu-22.04"]'
132+
crosstool_host_os: linuxX64
133+
build_host: linuxX64
134+
target_host: ${{ matrix.target_host }}
135+
build_script: ${{ matrix.build_script }}
136+
137+
native-toolchains:
138+
name: "Build native toolchains"
139+
needs: [bootstrap-linuxX64-toolchain]
140+
strategy:
141+
fail-fast: false
142+
matrix:
143+
build_host: [linuxX64, macosX64, macosARM64]
144+
target_host: [baremetalARM, baremetalAVR, baremetalRV32]
145+
include:
146+
- build_host: linuxX64
147+
runner_labels_json: '["ubuntu-22.04"]'
148+
- build_host: macosX64
149+
runner_labels_json: '["macos-12"]'
150+
- build_host: macosARM64
151+
runner_labels_json: '["macos-14"]' #'["self-hosted", "macOS", "ARM64"]'
152+
- target_host: baremetalARM
153+
build_script: arm-native.sh
154+
- target_host: baremetalAVR
155+
build_script: avr-native.sh
156+
- target_host: baremetalRV32
157+
build_script: riscv32-native.sh
158+
uses: ./.github/workflows/create_one_toolchain.yaml
159+
with:
160+
runner_labels_json: ${{ matrix.runner_labels_json }}
161+
crosstool_host_os: ${{ matrix.build_host }}
162+
build_host: ${{ matrix.build_host }}
163+
target_host: ${{ matrix.target_host }}
164+
build_script: ${{ matrix.build_script }}
165+
166+
canadian-toolchains:
167+
name: "Build canadian toolchains"
168+
needs: [canadian-host-toolchains]
169+
strategy:
170+
fail-fast: false
171+
matrix:
172+
build_host: [linuxARM64, windowsX64]
173+
target_host: [baremetalARM, baremetalAVR, baremetalRV32]
174+
include:
175+
- build_host: linuxARM64
176+
script_suffix: "-aarch64linux-canadian.sh"
177+
- build_host: windowsX64
178+
script_suffix: "-win64-canadian.sh"
179+
- target_host: baremetalARM
180+
script_prefix: arm
181+
- target_host: baremetalAVR
182+
script_prefix: avr
183+
- target_host: baremetalRV32
184+
script_prefix: riscv32
185+
uses: ./.github/workflows/create_one_toolchain.yaml
186+
with:
187+
runner_labels_json: '["ubuntu-22.04"]'
188+
crosstool_host_os: linuxX64
189+
canadian_build: true
190+
build_host: ${{ matrix.build_host }}
191+
target_host: ${{ matrix.target_host }}
192+
build_script: ${{ matrix.script_prefix }}${{ matrix.script_suffix }}
193+
194+
native-linuxX64-toolchain:
195+
name: "Build native linuxX64 toolchain"
196+
needs: [bootstrap-linuxX64-toolchain]
197+
uses: ./.github/workflows/create_one_toolchain.yaml
198+
with:
199+
runner_labels_json: '["ubuntu-22.04"]'
200+
crosstool_host_os: linuxX64
201+
build_host: linuxX64
202+
target_host: linuxX64
203+
build_script: x64linux-native.sh
204+
205+
canadian-windowsX64-toolchain:
206+
name: "Build native windowsX64 toolchain"
207+
needs: [canadian-toolchains]
208+
uses: ./.github/workflows/create_one_toolchain.yaml
209+
with:
210+
runner_labels_json: '["ubuntu-22.04"]'
211+
crosstool_host_os: linuxX64
212+
canadian_build: true
213+
build_host: windowsX64
214+
target_host: windowsX64
215+
build_script: win64-win64-canadian.sh
216+
217+
canadian-linuxARM64-toolchain:
218+
name: "Build native linuxARM64 toolchain"
219+
needs: [canadian-toolchains]
220+
uses: ./.github/workflows/create_one_toolchain.yaml
221+
with:
222+
runner_labels_json: '["ubuntu-22.04"]'
223+
crosstool_host_os: linuxX64
224+
canadian_build: true
225+
build_host: linuxARM64
226+
target_host: linuxARM64
227+
build_script: aarch64linux-aarch64linux-canadian.sh
228+
229+
publish:
230+
name: Publish toolchains
231+
needs: [bootstrap-linuxX64-toolchain, native-toolchains, canadian-toolchains, native-linuxX64-toolchain, canadian-windowsX64-toolchain, canadian-linuxARM64-toolchain]
232+
if: always() && !cancelled()
233+
runs-on: ubuntu-latest
234+
235+
steps:
236+
- name: Download toolchains
237+
if: always() && !cancelled()
238+
uses: actions/download-artifact@v4
239+
with:
240+
pattern: toolchain-*
241+
path: .
242+
merge-multiple: true
243+
244+
- name: Generate pre-release... release
245+
uses: marvinpinto/action-automatic-releases@latest
246+
if: always() && !cancelled() && github.ref == 'refs/heads/main'
247+
with:
248+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
249+
automatic_release_tag: latest
250+
prerelease: true
251+
title: Development Build
252+
files: |
253+
qmk_toolchain*
254+
255+
- name: Generate release
256+
uses: marvinpinto/action-automatic-releases@latest
257+
if: always() && !cancelled() && startsWith(github.ref, 'refs/tags/v')
258+
with:
259+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
260+
prerelease: false
261+
files: |
262+
qmk_toolchain*

0 commit comments

Comments
 (0)