Skip to content

Commit bc35080

Browse files
committed
backup gcc
1 parent 1b5a241 commit bc35080

30 files changed

+1328
-2
lines changed

.gitartifacts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
tools/ export-ignore
2+
.github/ export-ignore
3+
bazel export-ignore
4+
bazel.bat export-ignore

.github/renovate.json5

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
extends: [
3+
'config:recommended',
4+
],
5+
separateMajorMinor: false,
6+
dependencyDashboard: true,
7+
automerge: true,
8+
semanticCommits: "enabled",
9+
}

.github/workflows/build_gcc.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Build gcc
2+
3+
on:
4+
push:
5+
branches: [ gcc ]
6+
7+
permissions:
8+
# Required for uploading GitHub releases
9+
contents: write
10+
# Required for build provenance attestation
11+
actions: read
12+
id-token: write
13+
attestations: write
14+
15+
env:
16+
CT_NG_SRC_DIR: /tmp/crosstool-ng
17+
ARTIFACT_DIR: /tmp/toolchain/artifacts
18+
OUTPUT_DIR: /tmp/toolchain/output
19+
WORK_DIR: /tmp/toolchain/work
20+
SCRIPTS_DIR: ${{ github.workspace }}/.github/workflows/build_gcc
21+
22+
GCC_VERSION: 15
23+
LIBC: gnu
24+
LIBC_VERSION: 2.34
25+
REBUILD_ID: 1
26+
27+
jobs:
28+
build:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/[email protected]
33+
34+
- name: Create Directories
35+
run: |
36+
mkdir -p $CT_NG_SRC_DIR
37+
mkdir -p $ARTIFACT_DIR
38+
mkdir -p $OUTPUT_DIR
39+
mkdir -p $WORK_DIR
40+
41+
- name: Install Dependencies
42+
run: $SCRIPTS_DIR/step-1_install_dependencies
43+
44+
- name: Build crosstool-NG
45+
run: $SCRIPTS_DIR/step-2_build_crosstool_ng
46+
47+
- name: Configure Toolchain
48+
run: $SCRIPTS_DIR/step-3_configure_toolchain
49+
50+
- name: Build Toolchain
51+
run: $SCRIPTS_DIR/step-4_build_toolchain
52+
53+
- name: Package Toolchain
54+
run: $SCRIPTS_DIR/step-5_package_toolchain
55+
56+
- name: Attest Build Provenance
57+
uses: actions/[email protected]
58+
with:
59+
subject-path: |
60+
${{ env.ARTIFACT_DIR }}/*.tar.xz
61+
${{ env.WORK_DIR }}/build.log
62+
63+
- name: Upload Release
64+
env:
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
run: $SCRIPTS_DIR/step-6_upload_release
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
FROM ubuntu:latest
2+
3+
# This docker file allows for testing the build_gcc.yml actions workload locally.
4+
# args:
5+
# * GCC_VERSION: version of gcc to use. ct-ng only supports building the latest minor revision of the specific major revision.
6+
# the supported values will differ between different commits of ct-ng.
7+
# * LIBC: build a glibc or musl based toolchain
8+
# * LIBC_VERSION: version of the specified libc to use. based on the supported versions ct-ng enables building.
9+
# * REBUILD_ID: used to differentiate newer builds of an already supported toolchain for toolchains_cc releases.
10+
# * GITHUB_TOKEN: the token used to upload artifacts to the release. will skip the upload if not provided
11+
12+
# =================
13+
# || Create User ||
14+
# =================
15+
# ct-ng cant build as root; it needs to run as a user.
16+
# as well, github actions need sudo to install ct-ng after building and to do apt install
17+
RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y sudo gh
18+
19+
RUN useradd -m -s /bin/bash builder && \
20+
usermod -aG sudo builder
21+
RUN echo "builder ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
22+
USER builder
23+
WORKDIR /home/builder
24+
25+
# =======================
26+
# || Environment Setup ||
27+
# =======================
28+
ENV CT_NG_SRC_DIR="/tmp/crosstool-ng"
29+
ENV ARTIFACT_DIR="/tmp/toolchain/artifacts"
30+
ENV OUTPUT_DIR="/tmp/toolchain/output"
31+
ENV WORK_DIR="/tmp/toolchain/work"
32+
ENV SCRIPTS_DIR="/tmp/scripts"
33+
34+
RUN mkdir -p $CT_NG_SRC_DIR
35+
RUN mkdir -p $ARTIFACT_DIR
36+
RUN mkdir -p $OUTPUT_DIR
37+
RUN mkdir -p $WORK_DIR
38+
RUN mkdir -p $SCRIPTS_DIR
39+
40+
ARG GCC_VERSION=15
41+
ARG LIBC=gnu
42+
ARG LIBC_VERSION=2.34
43+
ARG REBUILD_ID=1
44+
45+
# =====================
46+
# || Build Toolchain ||
47+
# =====================
48+
COPY step-1_install_dependencies $SCRIPTS_DIR/step-1_install_dependencies
49+
RUN $SCRIPTS_DIR/step-1_install_dependencies
50+
51+
COPY step-2_build_crosstool_ng $SCRIPTS_DIR/step-2_build_crosstool_ng
52+
RUN $SCRIPTS_DIR/step-2_build_crosstool_ng
53+
54+
COPY step-3_configure_toolchain $SCRIPTS_DIR/step-3_configure_toolchain
55+
RUN $SCRIPTS_DIR/step-3_configure_toolchain
56+
57+
COPY step-4_build_toolchain $SCRIPTS_DIR/step-4_build_toolchain
58+
RUN $SCRIPTS_DIR/step-4_build_toolchain
59+
60+
COPY step-5_package_toolchain $SCRIPTS_DIR/step-5_package_toolchain
61+
RUN $SCRIPTS_DIR/step-5_package_toolchain
62+
63+
ARG GITHUB_TOKEN
64+
COPY step-6_upload_release $SCRIPTS_DIR/step-6_upload_release
65+
RUN $SCRIPTS_DIR/step-6_upload_release
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
set -euox pipefail
3+
4+
sudo apt update
5+
DEBIAN_FRONTEND=noninteractive sudo apt install -y \
6+
build-essential \
7+
autoconf \
8+
flex \
9+
bison \
10+
texinfo \
11+
help2man \
12+
file \
13+
gawk \
14+
libtool \
15+
libtool-bin \
16+
libncurses-dev \
17+
python3 \
18+
python3-dev \
19+
unzip \
20+
git \
21+
wget \
22+
curl
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -euox pipefail
3+
4+
git clone https://github.com/crosstool-ng/crosstool-ng "$CT_NG_SRC_DIR"
5+
pushd "$CT_NG_SRC_DIR"
6+
./bootstrap
7+
./configure
8+
make
9+
sudo make install
10+
popd
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
set -euox pipefail
3+
4+
pushd "${WORK_DIR}"
5+
6+
# Standard configs
7+
echo 'CT_CONFIG_VERSION="4"' > defconfig && \
8+
echo 'CT_ARCH_X86=y' >> defconfig && \
9+
echo 'CT_OMIT_TARGET_VENDOR=y' >> defconfig && \
10+
echo 'CT_ARCH_64=y' >> defconfig && \
11+
echo 'CT_STATIC_TOOLCHAIN=y' >> defconfig && \
12+
echo 'CT_KERNEL_LINUX=y' >> defconfig && \
13+
echo 'CT_LOG_PROGRESS_BAR=n' >> defconfig && \
14+
echo 'CT_PREFIX_DIR_RO=n' >> defconfig && \
15+
echo 'CT_CC_LANG_CXX=y' >> defconfig && \
16+
echo "CT_PREFIX_DIR=\"${OUTPUT_DIR}/\"" >> defconfig && \
17+
echo 'CT_DEBUG_GDB=y' >> defconfig && \
18+
echo 'CT_CC_GCC_LNK_HASH_STYLE_BOTH=y' >> defconfig
19+
20+
# GCC version configs
21+
case "$GCC_VERSION" in
22+
15)
23+
echo 'CT_GCC_V_15=y' >> defconfig
24+
;;
25+
14)
26+
echo 'CT_GCC_V_14=y' >> defconfig
27+
echo 'CT_GMP_EXTRA_CFLAGS="-std=gnu17"' >> defconfig
28+
echo 'CT_NCURSES_EXTRA_CFLAGS="-std=gnu17"' >> defconfig
29+
;;
30+
13)
31+
echo 'CT_GCC_V_13=y' >> defconfig
32+
echo 'CT_GMP_EXTRA_CFLAGS="-std=gnu17"' >> defconfig
33+
echo 'CT_NCURSES_EXTRA_CFLAGS="-std=gnu17"' >> defconfig
34+
;;
35+
12)
36+
echo 'CT_GCC_V_12=y' >> defconfig
37+
echo 'CT_GMP_EXTRA_CFLAGS="-std=gnu17"' >> defconfig
38+
echo 'CT_NCURSES_EXTRA_CFLAGS="-std=gnu17"' >> defconfig
39+
;;
40+
*)
41+
echo "Error: Unsupported gcc_version: $GCC_VERSION" >&2
42+
echo "Supported versions: 15, 14, 13, 12" >&2
43+
exit 1
44+
;;
45+
esac
46+
47+
# glibc configs
48+
if [ "$LIBC" = "gnu" ]; then
49+
echo 'CT_GLIBC_KERNEL_VERSION_NONE=y' >> defconfig
50+
echo "CT_GLIBC_V_$(echo "$LIBC_VERSION" | sed 's/\./_/g')=y" >> defconfig
51+
fi
52+
53+
# musl configs
54+
if [ "$LIBC" = "musl" ]; then
55+
echo 'CT_LIBC_MUSL=y' >> defconfig
56+
echo "CT_MUSL_V_$(echo "$LIBC_VERSION" | sed 's/\./_/g')=y" >> defconfig
57+
fi
58+
59+
popd
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -euox pipefail
3+
4+
pushd "${WORK_DIR}"
5+
ct-ng defconfig
6+
ct-ng build
7+
popd
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
set -euox pipefail
3+
4+
pushd "${OUTPUT_DIR}"
5+
GCC_FULL_VERSION=$("bin/x86_64-linux-${LIBC}-gcc" --version | head -n1 | awk '{print $NF}')
6+
7+
XZ_OPT=-e9 tar cJf "${ARTIFACT_DIR}/gcc-${GCC_FULL_VERSION}-x86_64-linux-${LIBC}-${LIBC_VERSION}-r${REBUILD_ID}.tar.xz" \
8+
bin/ \
9+
libexec/ \
10+
"x86_64-linux-${LIBC}/lib/" \
11+
"x86_64-linux-${LIBC}/bin/"
12+
13+
XZ_OPT=-e9 tar cJf "${ARTIFACT_DIR}/libgcc-${GCC_FULL_VERSION}-x86_64-linux-${LIBC}-${LIBC_VERSION}-r${REBUILD_ID}.tar.xz" \
14+
lib/
15+
16+
XZ_OPT=-e9 tar cJf "${ARTIFACT_DIR}/libstdcxx-${GCC_FULL_VERSION}-x86_64-linux-${LIBC}-${LIBC_VERSION}-r${REBUILD_ID}.tar.xz" \
17+
"x86_64-linux-${LIBC}/include/" \
18+
"x86_64-linux-${LIBC}/lib64/"
19+
20+
XZ_OPT=-e9 tar cJf "${ARTIFACT_DIR}/sysroot-x86_64-linux-${LIBC}-${LIBC_VERSION}-r${REBUILD_ID}.tar.xz" \
21+
"x86_64-linux-${LIBC}/sysroot/"
22+
23+
popd
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
set -euox pipefail
3+
4+
if [[ -z "${GITHUB_TOKEN:-}" ]]; then
5+
echo "GITHUB_TOKEN is not set, exiting"
6+
exit 0
7+
fi
8+
9+
GCC_FULL_VERSION=$("${OUTPUT_DIR}/bin/x86_64-linux-${LIBC}-gcc" --version | head -n1 | awk '{print $NF}')
10+
11+
# Create release name based on the specified format
12+
RELEASE_NAME="gcc-${GCC_FULL_VERSION}-x86_64-linux-${LIBC}-${LIBC_VERSION}-r${REBUILD_ID}"
13+
COMMIT_SHA="1b5a2410b266af3bc7aaae0550e7d44ea9dcf878"
14+
15+
# Create the release
16+
gh release create "${RELEASE_NAME}" \
17+
${ARTIFACT_DIR}/*.tar.xz \
18+
${WORK_DIR}/build.log \
19+
--repo https://github.com/reutermj/toolchains_cc \
20+
--target "${COMMIT_SHA}" \
21+
--latest=false \
22+
--title "${RELEASE_NAME}" \
23+
--notes "GCC ${GCC_FULL_VERSION} toolchain for x86_64 Linux with ${LIBC} ${LIBC_VERSION} (rebuild ${REBUILD_ID})"

0 commit comments

Comments
 (0)