|
5 | 5 | branches: [ gcc ] |
6 | 6 |
|
7 | 7 | env: |
8 | | - LIBC: gnu |
9 | | - LIBC_VERSION: "" |
| 8 | + CT_NG_SRC_DIR: /tmp/crosstool-ng |
| 9 | + ARTIFACT_DIR: /tmp/toolchain/artifacts |
| 10 | + OUTPUT_DIR: /tmp/toolchain/output |
| 11 | + WORK_DIR: /tmp/toolchain/work |
| 12 | + BUILD_GCC_SH: ./infra/gcc/build_gcc.sh |
| 13 | + SUDO: "sudo" |
| 14 | + |
10 | 15 | GCC_VERSION: 15 |
| 16 | + LIBC: gnu |
| 17 | + LIBC_VERSION: 2.34 |
11 | 18 | REBUILD_ID: 1 |
12 | 19 |
|
13 | 20 | jobs: |
14 | 21 | build: |
15 | 22 | runs-on: ubuntu-latest |
16 | | - timeout-minutes: 480 # 8 hours for toolchain build |
17 | | - permissions: |
18 | | - contents: write # Required for creating releases |
19 | | - attestations: write # Required for build provenance |
20 | | - id-token: write # Required for attestations |
21 | 23 | steps: |
22 | 24 | - name: Checkout repository |
23 | 25 | uses: actions/checkout@v5.0.0 |
24 | 26 |
|
25 | | - - name: Install Dependencies |
26 | | - run: | |
27 | | - sudo apt update |
28 | | - sudo DEBIAN_FRONTEND=noninteractive apt install -y \ |
29 | | - build-essential \ |
30 | | - autoconf \ |
31 | | - flex \ |
32 | | - bison \ |
33 | | - texinfo \ |
34 | | - help2man \ |
35 | | - file \ |
36 | | - gawk \ |
37 | | - libtool \ |
38 | | - libtool-bin \ |
39 | | - libncurses-dev \ |
40 | | - python3 \ |
41 | | - python3-dev \ |
42 | | - unzip \ |
43 | | - git \ |
44 | | - wget \ |
45 | | - curl |
46 | | - |
47 | | - - name: Build and Install crosstool-ng |
| 27 | + - name: Create Directories |
48 | 28 | run: | |
49 | | - git clone https://github.com/crosstool-ng/crosstool-ng /opt/crosstool-ng |
50 | | - cd /opt/crosstool-ng |
51 | | - ./bootstrap |
52 | | - ./configure |
53 | | - make |
54 | | - sudo make install |
| 29 | + mkdir -p $CT_NG_SRC_DIR |
| 30 | + mkdir -p $ARTIFACT_DIR |
| 31 | + mkdir -p $OUTPUT_DIR |
| 32 | + mkdir -p $WORK_DIR |
55 | 33 | |
56 | | - - name: Configure crosstool-ng |
57 | | - run: | |
58 | | - # Standard configs |
59 | | - mkdir -p /opt/crosstool-ng-workdir |
60 | | - cd /opt/crosstool-ng-workdir |
61 | | -
|
62 | | - echo 'CT_CONFIG_VERSION="4"' > defconfig |
63 | | - echo 'CT_ARCH_X86=y' >> defconfig |
64 | | - echo 'CT_OMIT_TARGET_VENDOR=y' >> defconfig |
65 | | - echo 'CT_ARCH_64=y' >> defconfig |
66 | | - echo 'CT_STATIC_TOOLCHAIN=y' >> defconfig |
67 | | - echo 'CT_KERNEL_LINUX=y' >> defconfig |
68 | | - echo 'CT_LOG_PROGRESS_BAR=n' >> defconfig |
69 | | - echo 'CT_PREFIX_DIR_RO=n' >> defconfig |
70 | | - echo 'CT_CC_LANG_CXX=y' >> defconfig |
71 | | - echo 'CT_DEBUG_GDB=y' >> defconfig |
72 | | - echo 'CT_PREFIX_DIR="/opt/crosstool-ng-output/"' >> defconfig |
73 | | - echo 'CT_CC_GCC_LNK_HASH_STYLE_BOTH=y' >> defconfig |
74 | | - |
75 | | - # GCC version configs |
76 | | - if [ "$GCC_VERSION" = "15" ]; then |
77 | | - echo 'CT_GCC_V_15=y' >> defconfig |
78 | | - elif [ "$GCC_VERSION" = "14" ]; then |
79 | | - echo 'CT_GCC_V_14=y' >> defconfig |
80 | | - echo 'CT_GMP_EXTRA_CFLAGS="-std=gnu17"' >> defconfig |
81 | | - echo 'CT_NCURSES_EXTRA_CFLAGS="-std=gnu17"' >> defconfig |
82 | | - elif [ "$GCC_VERSION" = "13" ]; then |
83 | | - echo 'CT_GCC_V_13=y' >> defconfig |
84 | | - echo 'CT_GMP_EXTRA_CFLAGS="-std=gnu17"' >> defconfig |
85 | | - echo 'CT_NCURSES_EXTRA_CFLAGS="-std=gnu17"' >> defconfig |
86 | | - elif [ "$GCC_VERSION" = "12" ]; then |
87 | | - echo 'CT_GCC_V_12=y' >> defconfig |
88 | | - echo 'CT_GMP_EXTRA_CFLAGS="-std=gnu17"' >> defconfig |
89 | | - echo 'CT_NCURSES_EXTRA_CFLAGS="-std=gnu17"' >> defconfig |
90 | | - else |
91 | | - echo "Error: Unsupported gcc_version: $GCC_VERSION" >&2 |
92 | | - echo "Supported versions: 15, 14, 13, 12" >&2 |
93 | | - exit 1 |
94 | | - fi |
95 | | - |
96 | | - # glibc configs |
97 | | - if [ "$LIBC" = "gnu" ]; then |
98 | | - echo 'CT_GLIBC_KERNEL_VERSION_NONE=y' >> defconfig |
99 | | - if [ -n "$LIBC_VERSION" ]; then |
100 | | - echo "CT_GLIBC_V_$(echo $LIBC_VERSION | sed 's/\./_/g')=y" >> defconfig |
101 | | - fi |
102 | | - fi |
103 | | - |
104 | | - # musl configs |
105 | | - if [ "$LIBC" = "musl" ]; then |
106 | | - echo 'CT_LIBC_MUSL=y' >> defconfig |
107 | | - if [ -n "$LIBC_VERSION" ]; then |
108 | | - echo "CT_MUSL_V_$(echo $LIBC_VERSION | sed 's/\./_/g')=y" >> defconfig |
109 | | - fi |
110 | | - fi |
| 34 | + - name: Install Dependencies |
| 35 | + run: $BUILD_GCC_SH install_dependencies |
111 | 36 |
|
112 | | - - name: Current defconfig |
113 | | - run: | |
114 | | - cd /opt/crosstool-ng-workdir |
115 | | - cat defconfig |
| 37 | + - name: Build crosstool-NG |
| 38 | + run: $BUILD_GCC_SH build_crosstool_ng |
116 | 39 |
|
117 | | - - name: Current .config |
118 | | - run: | |
119 | | - cd /opt/crosstool-ng-workdir |
120 | | - ct-ng defconfig |
121 | | - cat .config |
| 40 | + - name: Configure Toolchain |
| 41 | + run: $BUILD_GCC_SH configure_toolchain |
122 | 42 |
|
123 | 43 | - name: Build Toolchain |
124 | | - run: | |
125 | | - cd /opt/crosstool-ng-workdir |
126 | | - ct-ng build |
| 44 | + run: $BUILD_GCC_SH build_toolchain |
127 | 45 |
|
128 | 46 | - name: Package Toolchain |
129 | | - run: | |
130 | | - gcc_full_version=$(/opt/crosstool-ng-output//bin/x86_64-linux-${LIBC}-gcc --version | head -n1 | awk '{print $NF}') |
131 | | - cd /opt/crosstool-ng-output/ |
132 | | - |
133 | | - XZ_OPT=-e9 tar cJf /opt/crosstool-ng-output/gcc-${gcc_full_version}-x86_64-linux-${LIBC}-r${REBUILD_ID}.tar.xz \ |
134 | | - bin/ \ |
135 | | - libexec/ \ |
136 | | - x86_64-linux-${LIBC}/lib/ \ |
137 | | - x86_64-linux-${LIBC}/bin/ |
138 | | - |
139 | | - XZ_OPT=-e9 tar cJf /opt/crosstool-ng-output/libgcc-${gcc_full_version}-x86_64-linux-${LIBC}-r${REBUILD_ID}.tar.xz \ |
140 | | - lib/ |
141 | | - |
142 | | - XZ_OPT=-e9 tar cJf /opt/crosstool-ng-output/libstdcxx-${gcc_full_version}-x86_64-linux-${LIBC}-r${REBUILD_ID}.tar.xz \ |
143 | | - x86_64-linux-${LIBC}/include/ \ |
144 | | - x86_64-linux-${LIBC}/lib64/ |
145 | | - |
146 | | - XZ_OPT=-e9 tar cJf /opt/crosstool-ng-output/sysroot-x86_64-linux-${LIBC}-r${REBUILD_ID}.tar.xz \ |
147 | | - x86_64-linux-${LIBC}/sysroot/ |
| 47 | + run: $BUILD_GCC_SH package_toolchain |
148 | 48 |
|
149 | 49 | - name: Upload Toolchain Artifacts |
150 | 50 | uses: actions/upload-artifact@v4 |
151 | 51 | with: |
152 | 52 | name: gcc-toolchain-packages |
153 | 53 | path: | |
154 | | - /opt/crosstool-ng-output/gcc-*.tar.xz |
155 | | - /opt/crosstool-ng-output/libgcc-*.tar.xz |
156 | | - /opt/crosstool-ng-output/libstdcxx-*.tar.xz |
157 | | - /opt/crosstool-ng-output/sysroot-*.tar.xz |
158 | | - /opt/crosstool-ng-workdir/build.log |
| 54 | + $ARTIFACT_DIR/* |
| 55 | + $WORK_DIR/build.log |
159 | 56 | retention-days: 30 |
160 | | - |
161 | | - # - name: Set Release Variables |
162 | | - # id: release_vars |
163 | | - # run: | |
164 | | - # gcc_full_version=$(~/x-tools/x86_64-linux-${LIBC}/bin/x86_64-linux-${LIBC}-gcc --version | head -n1 | awk '{print $NF}') |
165 | | - # release_name="gcc-${gcc_full_version}-x86_64-linux-${LIBC}-r${REBUILD_ID}" |
166 | | - # echo "release_name=${release_name}" >> $GITHUB_OUTPUT |
167 | | - # echo "gcc_full_version=${gcc_full_version}" >> $GITHUB_OUTPUT |
168 | | - |
169 | | - # - name: Create Release |
170 | | - # id: create_release |
171 | | - # run: | |
172 | | - # gh release create ${{ steps.release_vars.outputs.release_name }} \ |
173 | | - # --title "${{ steps.release_vars.outputs.release_name }}" \ |
174 | | - # --notes "GCC Toolchain Release |
175 | | - |
176 | | - # **Details:** |
177 | | - # - GCC Version: ${{ steps.release_vars.outputs.gcc_full_version }} |
178 | | - # - Target: x86_64-linux-${{ env.LIBC }} |
179 | | - # - Rebuild ID: ${{ env.REBUILD_ID }} |
180 | | - # - Build Commit: 1b5a2410b266af3bc7aaae0550e7d44ea9dcf878 |
181 | | - |
182 | | - # **Packages:** |
183 | | - # - \`gcc-${{ steps.release_vars.outputs.gcc_full_version }}-x86_64-linux-${{ env.LIBC }}-r${{ env.REBUILD_ID }}.tar.xz\` - GCC compiler binaries |
184 | | - # - \`libgcc-${{ steps.release_vars.outputs.gcc_full_version }}-x86_64-linux-${{ env.LIBC }}-r${{ env.REBUILD_ID }}.tar.xz\` - GCC runtime libraries |
185 | | - # - \`libstdcxx-${{ steps.release_vars.outputs.gcc_full_version }}-x86_64-linux-${{ env.LIBC }}-r${{ env.REBUILD_ID }}.tar.xz\` - C++ standard library |
186 | | - # - \`sysroot-x86_64-linux-${{ env.LIBC }}-r${{ env.REBUILD_ID }}.tar.xz\` - System root files |
187 | | - # - \`build.log\` - Build log" \ |
188 | | - # --target 1b5a2410b266af3bc7aaae0550e7d44ea9dcf878 \ |
189 | | - # ~/gcc-${{ steps.release_vars.outputs.gcc_full_version }}-x86_64-linux-${{ env.LIBC }}-r${{ env.REBUILD_ID }}.tar.xz \ |
190 | | - # ~/libgcc-${{ steps.release_vars.outputs.gcc_full_version }}-x86_64-linux-${{ env.LIBC }}-r${{ env.REBUILD_ID }}.tar.xz \ |
191 | | - # ~/libstdcxx-${{ steps.release_vars.outputs.gcc_full_version }}-x86_64-linux-${{ env.LIBC }}-r${{ env.REBUILD_ID }}.tar.xz \ |
192 | | - # ~/sysroot-x86_64-linux-${{ env.LIBC }}-r${{ env.REBUILD_ID }}.tar.xz \ |
193 | | - # ~/build.log |
194 | | - # env: |
195 | | - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
196 | | - |
197 | | - # - name: Generate Build Provenance Attestation |
198 | | - # uses: actions/attest-build-provenance@v1 |
199 | | - # with: |
200 | | - # subject-path: | |
201 | | - # ~/gcc-${{ steps.release_vars.outputs.gcc_full_version }}-x86_64-linux-${{ env.LIBC }}-r${{ env.REBUILD_ID }}.tar.xz |
202 | | - # ~/libgcc-${{ steps.release_vars.outputs.gcc_full_version }}-x86_64-linux-${{ env.LIBC }}-r${{ env.REBUILD_ID }}.tar.xz |
203 | | - # ~/libstdcxx-${{ steps.release_vars.outputs.gcc_full_version }}-x86_64-linux-${{ env.LIBC }}-r${{ env.REBUILD_ID }}.tar.xz |
204 | | - # ~/sysroot-x86_64-linux-${{ env.LIBC }}-r${{ env.REBUILD_ID }}.tar.xz |
205 | | - |
0 commit comments