Skip to content

Commit 77a3769

Browse files
committed
Add Docker image for AArch64
1 parent c8c5a0a commit 77a3769

File tree

5 files changed

+43
-19
lines changed

5 files changed

+43
-19
lines changed

.github/workflows/build.yml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ on:
55
paths:
66
- .github/workflows/build.yml
77
- "build-*.sh"
8-
- debian7/Dockerfile
8+
- Dockerfile*
99
workflow_call:
1010

1111
jobs:
1212
build:
13-
runs-on: ubuntu-latest
1413
strategy:
1514
fail-fast: false
1615
matrix:
@@ -23,27 +22,34 @@ jobs:
2322
- python3
2423
- sed
2524
include:
26-
- container: debian7
25+
- arch: x86_64
26+
runs-on: ubuntu-latest
27+
- arch: aarch64
28+
runs-on: ubuntu-24.04-arm
29+
runs-on: ${{matrix.runs-on}}
30+
name: ${{matrix.binary}} (${{matrix.arch}})
31+
env:
32+
ARCH: ${{matrix.arch}}
33+
BINARY: ${{matrix.binary}}
2734
steps:
2835
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
2936
with:
3037
persist-credentials: false
3138

3239
- name: Build Docker image
33-
run: docker build --tag ${{matrix.container}} .
34-
working-directory: debian7
40+
run: docker build --tag glibc-bootstrap --file "Dockerfile.$ARCH" .
3541

3642
- name: Run Docker container
37-
run: docker run --rm --detach --user linuxbrew --name ${{github.sha}} --workdir /home/linuxbrew --volume "$(pwd):/home/linuxbrew/glibc-bootstrap" ${{matrix.container}} sleep inf
43+
run: docker run --rm --detach --user linuxbrew --name "$GITHUB_SHA" --workdir /home/linuxbrew --volume "$(pwd):/home/linuxbrew/glibc-bootstrap" glibc-bootstrap sleep inf
3844

3945
- name: Build ${{matrix.binary}}
40-
run: docker exec ${{github.sha}} /bin/bash -c "/home/linuxbrew/glibc-bootstrap/build-${{matrix.binary}}.sh"
46+
run: docker exec "$GITHUB_SHA" /bin/bash -c "/home/linuxbrew/glibc-bootstrap/build-$BINARY.sh"
4147

4248
- name: Copy binaries from container
43-
run: docker cp ${{github.sha}}:/home/linuxbrew/bootstrap-binaries .
49+
run: docker cp "$GITHUB_SHA":/home/linuxbrew/bootstrap-binaries .
4450

4551
- name: Upload binaries to GitHub Actions
4652
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
4753
with:
48-
name: bootstrap-${{matrix.binary}}
54+
name: bootstrap-${{matrix.arch}}-${{matrix.binary}}
4955
path: bootstrap-binaries

Dockerfile.aarch64

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM centos:7
2+
3+
RUN sed -e 's/mirror\.centos\.org/vault\.centos\.org/g' \
4+
-e 's/^mirrorlist=/#mirrorlist=/g' \
5+
-e 's/^#\s*baseurl=/baseurl=/g' \
6+
-i /etc/yum.repos.d/CentOS-*.repo \
7+
&& yum install -y @development bzip2 ca-certificates texinfo wget zlib-devel \
8+
&& yum clean all
9+
10+
RUN useradd --create-home --shell /bin/bash linuxbrew
11+
12+
ENV CFLAGS="-march=armv8-a -O2"
13+
ENV CXXFLAGS="-march=armv8-a -O2"
14+
ENV PREFIX=/tmp/homebrew
15+
RUN su - linuxbrew --command 'mkdir --parents /tmp/homebrew'
16+
ENV PKGDIR=/home/linuxbrew/bootstrap-binaries
17+
RUN su - linuxbrew --command 'mkdir --parents /home/linuxbrew/bootstrap-binaries'
File renamed without changes.

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Bootstrap binaries for compiling `glibc` from source.
66

77
To run the binaries built by this workflow:
88

9-
Linux with `glibc` 2.13 or newer.
9+
For x86-64 Linux: `glibc` 2.13 or newer, and x86-64 CPU architecture with support for `-march=core2` (defined [here](https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html)).
1010

11-
x86-64 CPU architecture with support for `-march=core2` (defined [here](https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html)).
11+
For AArch64 (ARM64) Linux: `glibc` 2.17 or newer.
1212

1313
To build the binaries:
1414

15-
A host machine capable of running building and running Linux x86-64 Docker images.
15+
A host machine capable of building and running Linux x86-64 or AArch64 Docker images.
1616

1717
## Installation
1818

@@ -27,23 +27,23 @@ git clone https://github.com/Homebrew/glibc-bootstrap
2727
cd glibc-bootstrap
2828
2929
# Build the Docker image.
30-
docker build --tag debian7 debian7
30+
docker build --tag glibc-bootstrap --file "Dockerfile.$(uname -m)" .
3131
3232
# Start the Docker image and leave it running the background so the binaries
3333
# can easily be copied out after they are built.
34-
docker run --rm --detach --user linuxbrew --name debian7 \
35-
--workdir /home/linuxbrew --volume $(pwd):/home/linuxbrew/glibc-bootstrap debian7 sleep inf
34+
docker run --rm --detach --user linuxbrew --name glibc-bootstrap \
35+
--workdir /home/linuxbrew --volume $(pwd):/home/linuxbrew/glibc-bootstrap glibc-bootstrap sleep inf
3636
3737
# Call a build-*.sh script to build a specific binary. We use build-make.sh as an example.
38-
docker exec debian7 /bin/bash -c "/home/linuxbrew/glibc-bootstrap/build-make.sh"
38+
docker exec glibc-bootstrap /bin/bash -c "/home/linuxbrew/glibc-bootstrap/build-make.sh"
3939
4040
# Copy the binaries out of the container after they have been compiled.
41-
docker cp debian7:/home/linuxbrew/bootstrap-binaries .
41+
docker cp glibc-bootstrap:/home/linuxbrew/bootstrap-binaries .
4242
```
4343

4444
## Motivation
4545

46-
The `glibc` bottle is not relocatable and must be built from source if the user is in a non-default prefix. While `glibc` has no runtime dependencies, it does have build dependencies which may be too new or unavailable to users without root access. Rather than requiring the user to build these dependencies from source, we build them with GitHub Actions in this repository using a Linux image with an older version of `glibc` and a prefix of `/tmp/homebrew`. Assuming the user has write access to `/tmp`, this approach guarantees that all users on actively maintained versions of `glibc` (2.17 or newer) can install and run these binaries. The build dependency binaries are installed as resources to `/tmp/homebrew` and used to build `glibc` instead of the host toolchain.
46+
The `glibc` bottle is not relocatable and must be built from source if the user is in a non-default prefix. While `glibc` has no runtime dependencies, it does have build dependencies which may be too new or unavailable to users without root access. Rather than requiring the user to build these dependencies from source, we build them with GitHub Actions in this repository using a Linux image with an older version of `glibc` and a prefix of `/tmp/homebrew`. Assuming the user has write access to `/tmp`, this approach guarantees that all users on actively maintained versions of `glibc` can install and run these binaries. The build dependency binaries are installed as resources to `/tmp/homebrew` and used to build `glibc` instead of the host toolchain.
4747

4848
## Copyright
4949
Copyright (c) Homebrew maintainers. See LICENSE.txt for details.

utils.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ verify_checksum() {
1616
package() {
1717
PKGNAME="$1"
1818
VERSION="$2"
19+
ARCH="$(uname -m)"
1920

2021
tar --directory "$PREFIX" \
2122
--create --gzip --verbose \
22-
--file "$PKGDIR/bootstrap-$PKGNAME-$VERSION.tar.gz" .
23+
--file "$PKGDIR/bootstrap-$ARCH-$PKGNAME-$VERSION.tar.gz" .
2324
find "$PREFIX" -mindepth 1 -delete
2425
}

0 commit comments

Comments
 (0)