Skip to content

Commit 6bf1004

Browse files
authored
add arm64 support
1 parent 903e813 commit 6bf1004

File tree

4 files changed

+80
-6
lines changed

4 files changed

+80
-6
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,38 @@
11
# toolchains_gcc_packages
22
Bazel toolchains for GNU GCC
3+
4+
## Overview
5+
This repository builds GCC toolchains for use with Bazel build system using crosstool-ng.
6+
7+
## Supported Architectures
8+
- x86_64 (AMD64)
9+
- aarch64 (ARM64)
10+
11+
## Building
12+
13+
### Using Docker (recommended)
14+
```bash
15+
# Build for x86_64 (default)
16+
./docker_build_and_run.sh
17+
18+
# Build for ARM64
19+
./docker_build_and_run.sh arm64
20+
21+
# Build for specific architecture and GCC version
22+
./docker_build_and_run.sh arm64 12
23+
```
24+
25+
### Manual Build
26+
```bash
27+
# Set required environment variables
28+
export GCC=12 # GCC major version
29+
export ARCH=x86_64 # or arm64/aarch64
30+
31+
# Run the build
32+
./build.sh
33+
```
34+
35+
## Output
36+
The build will create a tarball in the `output/` directory:
37+
- For x86_64: `x86_64-unknown-linux-gnu_gcc12.tar.gz`
38+
- For ARM64: `aarch64-unknown-linux-gnu_gcc12.tar.gz`

build.sh

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,33 @@
1414
# *******************************************************************************
1515

1616
export GCC=${GCC:?Please set GCC variable to desired gcc major version}
17+
export ARCH=${ARCH:-x86_64}
18+
19+
# Map architecture to target triplet
20+
case $ARCH in
21+
x86_64)
22+
TARGET_TRIPLET="x86_64-unknown-linux-gnu"
23+
;;
24+
arm64|aarch64)
25+
TARGET_TRIPLET="aarch64-unknown-linux-gnu"
26+
;;
27+
*)
28+
echo "Unsupported architecture: $ARCH"
29+
echo "Supported architectures: x86_64, arm64/aarch64"
30+
exit 1
31+
;;
32+
esac
1733

1834
mkdir -p ${PWD}/output/downloads
19-
mkdir -p ${PWD}/output/gcc${GCC}
35+
mkdir -p ${PWD}/output/${TARGET_TRIPLET}_gcc${GCC}
2036

2137
###############################################################################
2238
#
2339
# Build
2440
#
2541
###############################################################################
26-
export CT_PREFIX="${PWD}/output/gcc${GCC}"
27-
DEFCONFIG=configs/x86_64-unknown-linux-gnu_gcc${GCC} ct-ng defconfig
42+
export CT_PREFIX="${PWD}/output/${TARGET_TRIPLET}_gcc${GCC}"
43+
DEFCONFIG=configs/${TARGET_TRIPLET}_gcc${GCC} ct-ng defconfig
2844
ct-ng -j$(nproc) build
2945

3046
###############################################################################
@@ -46,5 +62,5 @@ tar -c \
4662
--owner=0 \
4763
--group=0 \
4864
--numeric-owner \
49-
-C "output/gcc${GCC}" . \
50-
| gzip -n > "output/x86_64-unknown-linux-gnu_gcc${GCC}.tar.gz"
65+
-C "output/${TARGET_TRIPLET}_gcc${GCC}" . \
66+
| gzip -n > "output/${TARGET_TRIPLET}_gcc${GCC}.tar.gz"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CT_CONFIG_VERSION="4"
2+
CT_LOCAL_TARBALLS_DIR="${CT_PREFIX}/../downloads"
3+
CT_ARCH_ARM=y
4+
CT_ARCH_64=y
5+
CT_ARCH_ARM_MODE_ARM=y
6+
CT_ARCH_ARM_V8=y
7+
CT_STATIC_TOOLCHAIN=y
8+
CT_KERNEL_LINUX=y
9+
CT_LINUX_V_5_15=y
10+
CT_BINUTILS_V_2_34=y
11+
CT_GLIBC_V_2_31=y
12+
CT_GLIBC_KERNEL_VERSION_NONE=y
13+
CT_GCC_V_12=y
14+
CT_CC_GCC_LNK_HASH_STYLE_BOTH=y
15+
CT_CC_LANG_CXX=y
16+
CT_COMP_LIBS_EXPAT=y

docker_build_and_run.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,11 @@ else
3333
exit 1
3434
fi
3535

36+
# Parse command line arguments
37+
ARCH=${1:-x86_64}
38+
GCC_VERSION=${2:-12}
39+
40+
echo "Building toolchain for architecture: $ARCH with GCC version: $GCC_VERSION"
41+
3642
# Execute the build of the selected toolchain
37-
docker run --rm -it --user "$(id -u):$(id -g)" -v ${PWD}:/workspace $FULL_IMAGE_NAME /bin/bash -c "cd /workspace && GCC=12 ./build.sh"
43+
docker run --rm -it --user "$(id -u):$(id -g)" -v ${PWD}:/workspace $FULL_IMAGE_NAME /bin/bash -c "cd /workspace && GCC=$GCC_VERSION ARCH=$ARCH ./build.sh"

0 commit comments

Comments
 (0)