Skip to content

Commit 8ae1268

Browse files
author
Jos Martin
committed
Add support for rpm-build as well
1 parent c625646 commit 8ae1268

20 files changed

+442
-56
lines changed

.github/workflows/build-glibc-and-release.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ on:
1515
required: false
1616
type: boolean
1717
default: false
18+
dockerfile:
19+
required: false
20+
type: string
21+
default: Dockerfile.debian
1822

1923
jobs:
2024
build:
@@ -27,7 +31,7 @@ jobs:
2731
- name: "Build"
2832
shell: bash
2933
run: |
30-
DOCKER_BUILDKIT=1 docker build --build-arg DIST_BASE=${{ inputs.dist-base }} --build-arg DIST_TAG=${{ inputs.dist-tag }} --output type=local,dest=. .
34+
DOCKER_BUILDKIT=1 docker build --build-arg DIST_BASE=${{ inputs.dist-base }} --build-arg DIST_TAG=${{ inputs.dist-tag }} -f ${{ inputs.dockerfile }} --output type=local,dest=. .
3135
3236
- name: "Download glibc license info"
3337
shell: bash

.github/workflows/release-specific.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,18 @@ on:
1717
type: string
1818

1919
jobs:
20-
build:
20+
build-ubuntu:
21+
if: github.event.inputs.dist-base == 'ubuntu' || github.event.inputs.dist-base == 'debian'
2122
uses: mathworks/build-glibc-bz-19329-patch/.github/workflows/build-glibc-and-release.yaml@main
2223
with:
2324
dist-base: ${{ github.event.inputs.dist-base }}
24-
dist-tag: ${{ github.event.inputs.dist-tag }}
25+
dist-tag: ${{ github.event.inputs.dist-tag }}
26+
dockerfile: Dockerfile.debian
27+
28+
build-rhel:
29+
if: github.event.inputs.dist-base == 'almalinux'
30+
uses: mathworks/build-glibc-bz-19329-patch/.github/workflows/build-glibc-and-release.yaml@main
31+
with:
32+
dist-base: ${{ github.event.inputs.dist-base }}
33+
dist-tag: ${{ github.event.inputs.dist-tag }}
34+
dockerfile: Dockerfile.rhel

Dockerfile

Lines changed: 0 additions & 49 deletions
This file was deleted.

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Dockerfile.debian

Dockerfile.debian

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright 2021 The MathWorks, Inc.
2+
ARG BUILD_ROOT=/opt/glibc/src/glibc/
3+
4+
# Default to building for glibc 2.31 in ubuntu:20.04 but by specifying
5+
# --build-arg RELEASE=18.04 in the docker build phase this will build for
6+
# glibc 2.27
7+
ARG ARCH=
8+
ARG DIST_BASE=ubuntu
9+
ARG DIST_TAG=20.04
10+
FROM ${ARCH}${DIST_BASE}:${DIST_TAG} AS build-stage
11+
12+
ARG DIST_BASE
13+
ARG DIST_TAG
14+
ARG OVERRIDE_DIST_RELEASE=false
15+
16+
ENV DEBIAN_FRONTEND="noninteractive" \
17+
TZ="Etc/UTC"
18+
19+
RUN apt-get update && apt-get install --no-install-recommends -y \
20+
quilt \
21+
nano \
22+
devscripts
23+
24+
ARG PKG_EXT
25+
ARG BUILD_ROOT
26+
WORKDIR ${BUILD_ROOT}
27+
28+
# Build glibc in 3 distinct stages
29+
# 1. Get the build envionment and source code
30+
# 2. Patch the source code
31+
# 3. Build the source code
32+
33+
COPY scripts/setup-glibc-build-env-vars.sh ${BUILD_ROOT}/
34+
COPY scripts/get-glibc-src.sh ${BUILD_ROOT}/
35+
RUN ./get-glibc-src.sh
36+
37+
COPY patches/debian/ ${BUILD_ROOT}/patches/
38+
COPY scripts/patch-glibc-src.sh ${BUILD_ROOT}/
39+
RUN ./patch-glibc-src.sh
40+
41+
COPY scripts/build-glibc-src.sh ${BUILD_ROOT}/
42+
RUN ./build-glibc-src.sh
43+
44+
RUN tar -czf all-packages.tar.gz *.deb
45+
46+
FROM scratch AS release-stage
47+
ARG BUILD_ROOT
48+
COPY --from=build-stage ${BUILD_ROOT}/*.deb /build/
49+
COPY --from=build-stage ${BUILD_ROOT}/all-packages.tar.gz /build/

Dockerfile.rhel

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2021 The MathWorks, Inc.
2+
ARG BUILD_ROOT=/root/
3+
ARG RPM_DIR=${BUILD_ROOT}/rpmbuild/RPMS/x86_64/
4+
5+
# Default to building for glibc 2.31 in ubuntu:20.04 but by specifying
6+
# --build-arg RELEASE=18.04 in the docker build phase this will build for
7+
# glibc 2.27
8+
ARG ARCH=
9+
ARG DIST_BASE=almalinux
10+
ARG DIST_TAG=8.5
11+
FROM ${DIST_BASE}:${DIST_TAG} AS build-stage
12+
13+
RUN dnf install -y --nodocs dnf-plugins-core && \
14+
dnf config-manager --enable powertools && \
15+
dnf install -y rpm-build
16+
17+
ARG BUILD_ROOT
18+
WORKDIR ${BUILD_ROOT}
19+
20+
RUN dnf download --source glibc && \
21+
dnf builddep -y --nodocs glibc-*.src.rpm && \
22+
rpm -ivh glibc-*.src.rpm
23+
24+
COPY scripts/update-specfile.sh ${BUILD_ROOT}
25+
COPY patches/rhel ${BUILD_ROOT}/patches
26+
27+
RUN cp patches/2.28/* rpmbuild/SOURCES && \
28+
./update-specfile.sh
29+
30+
RUN rpmbuild --nocheck -bb rpmbuild/SPECS/glibc.spec
31+
32+
ARG RPM_DIR
33+
WORKDIR ${RPM_DIR}
34+
35+
RUN tar -czf all-packages.tar.gz *.rpm
36+
37+
FROM scratch AS release-stage
38+
ARG RPM_DIR
39+
COPY --from=build-stage ${RPM_DIR}/*.rpm /build/
40+
COPY --from=build-stage ${RPM_DIR}/all-packages.tar.gz /build/

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This repository provides a method for working around the sporadic issue seen on
44

55
If you are running an ubuntu-based system and can upgrade to **version 21.10 (Impish Indri)** this is the safest and easiest way to alleviate the issue, since that version contains glibc v2.34 in which the underlying issue is completely fixed.
66

7-
If instead you want to work around this issue, you can use this repository. It provides a build procedure (in an isolated Docker® container) to produce patched versions of the glibc libraries for recent Ubuntu® and Debian® releases. These patched versions [incorporate an initial fix](https://patchwork.ozlabs.org/project/glibc/patch/[email protected]/) proposed on the [libc-alpha mailing list](https://sourceware.org/mailman/listinfo/libc-alpha) that mitigate the issue. In the release area of this repository you can find the debian package build artefacts produced by running the build on Ubuntu 18.04 & 20.04 as well as Debian 9, 10 & 11. You can install these artefacts on an appropriate debian-based machine, virtual machine or docker container, by using `dpkg -i`.
7+
If instead you want to work around this issue, you can use this repository. It provides a build procedure (in an isolated Docker® container) to produce patched versions of the glibc libraries for recent Almalinux, Ubuntu® and Debian® releases. These patched versions [incorporate an initial fix](https://patchwork.ozlabs.org/project/glibc/patch/[email protected]/) proposed on the [libc-alpha mailing list](https://sourceware.org/mailman/listinfo/libc-alpha) that mitigate the issue. In the release area of this repository you can find the debian package build artefacts produced by running the build on Ubuntu 18.04 & 20.04 as well as Debian 9, 10 & 11. You can install these artefacts on an appropriate debian-based machine, virtual machine or docker container, by using `dpkg -i`. For Almalinux you cand find the appropriate `rpm's` which should also work on UBI and CentOS containers.
88

99
## Bug Description
1010
The [assert failure at concurrent pthread_create and dlopen](https://sourceware.org/bugzilla/show_bug.cgi?id=19329) glibc bug was first reported in December 2015 and can affect any process on Linux that creates a thread at the same time as opening a dynamic shared object library. Initially the issue was only observable with reasonable frequency on very large scale machine systems such as high performance computing clusters or cloud scale deployment platforms and so did not receive significant attention. However, early on there were [proposed patches](https://sourceware.org/bugzilla/show_bug.cgi?id=19329) to the library. Large scale systems applied those patches in-house and saw significant benefit. More recently a [proposed complete fix for this](https://sourceware.org/pipermail/libc-alpha/2021-February/122626.html) and a set of related issues has been reviewed by the glibc team and accepted into version 2.34 of glibc (released in August 2021). The 2.34 version of glibc is available in [RHEL 9 beta](https://developers.redhat.com/articles/2021/11/03/red-hat-enterprise-linux-9-beta-here) and [Ubuntu 21.10 (Impish Indri)](https://launchpad.net/ubuntu/+source/glibc). However, there are no plans to backport the fix into previous glibc versions and it is expected that previous versions will be in production use for a significant number of years (e.g. the current end-of-life date for Ubuntu:20.04 is April 2030).
@@ -50,7 +50,7 @@ libc6:amd64 2.31-0ubuntu9.2
5050
```
5151

5252
## Build procedure
53-
To build a specific version of glibc on your own machine you will need a version of `docker` that supports `BUILDKIT` (this feature was added in version 18.09). This repository holds patches for all glibc versions from 2.24 to 2.33 inclusive. Running the build process takes between 10 and 60 mins based on the compute ability of your system.
53+
To build a specific version of glibc on your own machine you will need a version of `docker` that supports `BUILDKIT` (this feature was added in version 18.09). This repository holds patches for all glibc versions on debian derived systems from 2.24 to 2.33 inclusive, as well as a version for RHEL 8 with glibc 2.28. Running the build process takes between 10 and 60 mins based on the compute ability of your system.
5454

5555
### Pre-built artefacts
5656
This repository runs a number of github actions to build artefacts for specific Debian and Ubuntu versions and it is likely that these are all that is needed to patch your system. You can download the matching debian package for your system from the release area.
@@ -71,6 +71,8 @@ This repository runs a number of github actions to build artefacts for specific
7171
| `ubuntu:18.04` | `ubuntu:bionic` |
7272
| `ubuntu:20.04` | `ubuntu:focal` |
7373
| `ubuntu:21.04` | `ubuntu:hirsute` |
74+
| `almalinux:8.4` | |
75+
| `almalinux:8.5` | |
7476

7577
Here is an example build command (for `debian:9`):
7678
```
@@ -87,6 +89,13 @@ libc6_2.28-10.custom_amd64.deb
8789
libc6_2.31-13+deb11u2.custom_amd64.deb
8890
```
8991

92+
When building for Almalinux you must use the `Dockerfile.rhel` rather than the debian `Dockerfile` so the build command is
93+
```
94+
DOCKER_BUILDKIT=1 docker build --build-arg DIST_TAG=8.5 -f Dockerfile.rhel --output type=local,dest=. .
95+
```
96+
97+
If you have access to a RHEL subscription you should be able to adapt the `Dockerfile.rhel` trivially to include the correct repos to support building the sources directly in a `ubi8` container.
98+
9099
### Overriding package version string
91100
The package version extension defaults to `.DIST_BASE.DIST_TAG.custom`, where
92101
`${DIST_TAG}` defaults to the `VERSION_CODENAME` found in `/etc/os-release`. This version
@@ -106,6 +115,13 @@ dpkg -i libc6_2.24-11+deb9u4.custom_amd64.deb
106115
```
107116
For your system replace the debian package with the correct version that matches the glibc you already have (see for example the output from `dpkg-query --show libc6:amd64`)
108117

118+
Installing the rpms on a UBI / Almalinux system requires you to install several of the packages at once, for example
119+
```
120+
dnf install -y glibc-2.28-164.custom.el8.x86_64.rpm \
121+
glibc-common-2.28-164.custom.el8.x86_64.rpm \
122+
glibc-minimal-langpack-2.28-164.custom.el8.x86_64.rpm
123+
```
124+
109125
### Installing in a Docker container
110126
When building a docker container with a specific patch, assuming the patch is in the top level docker context folder you would have a `Dockerfile` like
111127
``` docker
File renamed without changes.

0 commit comments

Comments
 (0)