Skip to content

Commit 5e8d916

Browse files
committed
Add Docker image for aarch64
1 parent ca52b20 commit 5e8d916

File tree

5 files changed

+42
-19
lines changed

5 files changed

+42
-19
lines changed

.github/workflows/build.yml

+14-9
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,25 +22,31 @@ jobs:
2322
- python3
2423
- sed
2524
include:
26-
- container: debian7
25+
- arch: x86_64
26+
runs-on: ubuntu-latest
27+
# TODO: add aarch64 when available
28+
runs-on: ${{matrix.runs-on}}
29+
name: ${{matrix.binary}} (${{matrix.arch}})
30+
env:
31+
ARCH: ${{matrix.arch}}
32+
BINARY: ${{matrix.binary}}
2733
steps:
2834
- uses: actions/checkout@v4
2935

3036
- name: Build Docker image
31-
run: docker build --tag ${{matrix.container}} .
32-
working-directory: debian7
37+
run: docker build --tag glibc-bootstrap --file "Dockerfile.$ARCH" .
3338

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

3742
- name: Build ${{matrix.binary}}
38-
run: docker exec ${{github.sha}} /bin/bash -c "/home/linuxbrew/glibc-bootstrap/build-${{matrix.binary}}.sh"
43+
run: docker exec "$GITHUB_SHA" /bin/bash -c "/home/linuxbrew/glibc-bootstrap/build-$BINARY.sh"
3944

4045
- name: Copy binaries from container
41-
run: docker cp ${{github.sha}}:/home/linuxbrew/bootstrap-binaries .
46+
run: docker cp "$GITHUB_SHA":/home/linuxbrew/bootstrap-binaries .
4247

4348
- name: Upload binaries to GitHub Actions
4449
uses: actions/upload-artifact@v4
4550
with:
46-
name: bootstrap-${{matrix.binary}}
51+
name: bootstrap-${{matrix.arch}}-${{matrix.binary}}
4752
path: bootstrap-binaries

Dockerfile.aarch64

+17
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

+9-9
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

+2-1
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)