Skip to content

Commit 5eb5f30

Browse files
Lower GLIBC requirements by using chromium reversion script and patches
1 parent bb3661b commit 5eb5f30

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

.github/workflows/pushaction.yml

+54
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,60 @@ jobs:
9494
run: sudo apt-get -yq install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf
9595
- name: Install Linux arm64 compilers/libraries
9696
run: sudo apt-get -yq install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
97+
- name: Add patches to minimize needed GLIBC version
98+
run: |
99+
CURRENT_DIR="$(pwd)"
100+
sudo apt-get -yq install python3
101+
# download chromium reversion_glibc.py script from chromium source tree at pinned commit (incase they ever move or change it)
102+
wget https://raw.githubusercontent.com/chromium/chromium/01bc42d648c45439e1beef8fd25fde3aef9079bc/build/linux/sysroot_scripts/reversion_glibc.py -O /tmp/reversion_glibc.py
103+
# set targeted minimum GLIBC to 2.17
104+
sed -i 's/26]/17]/g' /tmp/reversion_glibc.py
105+
chmod +x /tmp/reversion_glibc.py
106+
107+
# download the host libc6 package from apt and patch the binaries in it
108+
# replacing the host libc6 at runtime causes crashs and hangs but apt is able to do it without issue
109+
sudo apt-get install --download-only --reinstall -y libc6
110+
sudo rm -rf /tmp/libc6
111+
sudo mkdir /tmp/libc6
112+
sudo cp /var/cache/apt/archives/libc6_2.31-*_amd64.deb /tmp/libc6
113+
cd /tmp/libc6
114+
deb_name="$(ls)"
115+
sudo ar x "$deb_name"
116+
sudo tar xf data.tar.xz
117+
sudo mkdir DEBIAN
118+
sudo tar xf control.tar.xz -C DEBIAN
119+
sudo rm -f control.tar.xz \
120+
data.tar.xz \
121+
debian-binary \
122+
DEBIAN/md5sums \
123+
DEBIAN/archives \
124+
DEBIAN/conffiles \
125+
"$deb_name"
126+
127+
# patch libc6 in host download deb and cross compilers using the reversion_glibc.py script
128+
files=(/tmp/libc6/lib/x86_64-linux-gnu/libc.so.6 /tmp/libc6/lib/x86_64-linux-gnu/libm.so.6
129+
/usr/aarch64-linux-gnu/lib/libc.so.6 /usr/aarch64-linux-gnu/lib/libm.so.6 \
130+
/usr/arm-linux-gnueabihf/lib/libc.so.6 /usr/arm-linux-gnueabihf/lib/libm.so.6 \
131+
/libx32/libc.so.6 /libx32/libm.so.6 \
132+
/lib32/libc.so.6 /lib32/libm.so.6)
133+
for file in "${files[@]}"; do
134+
sudo python3 /tmp/reversion_glibc.py "$file"
135+
done
136+
137+
# install patched libc6 deb
138+
sudo dpkg-deb -b . "$deb_name"
139+
sudo apt install --reinstall --allow-downgrades -y ./"$deb_name"
140+
cd "$CURRENT_DIR"
141+
142+
# __GLIBC_MINOR__ is used as a feature test macro. Replace it with the
143+
# earliest supported version of glibc 2.17
144+
sudo sed -i 's|\(#define\s\+__GLIBC_MINOR__\)|\1 17 //|' "/usr/include/features.h"
145+
sudo sed -i 's|\(#define\s\+__GLIBC_MINOR__\)|\1 17 //|' "/usr/aarch64-linux-gnu/include/features.h"
146+
sudo sed -i 's|\(#define\s\+__GLIBC_MINOR__\)|\1 17 //|' "/usr/arm-linux-gnueabihf/include/features.h"
147+
# fcntl64() was introduced in glibc 2.28. Make sure to use fcntl() instead.
148+
sudo sed -i '{N; s/#ifndef __USE_FILE_OFFSET64\(\nextern int fcntl\)/#if 1\1/}' "/usr/include/fcntl.h"
149+
sudo sed -i '{N; s/#ifndef __USE_FILE_OFFSET64\(\nextern int fcntl\)/#if 1\1/}' "/usr/aarch64-linux-gnu/include/fcntl.h"
150+
sudo sed -i '{N; s/#ifndef __USE_FILE_OFFSET64\(\nextern int fcntl\)/#if 1\1/}' "/usr/arm-linux-gnueabihf/include/fcntl.h"
97151
- name: Download macOS natives
98152
uses: actions/download-artifact@v3
99153
with:

.github/workflows/releaseaction.yml

+54
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,60 @@ jobs:
9393
run: sudo apt-get -yq install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf binutils-arm-linux-gnueabihf
9494
- name: Install Linux arm64 compilers/libraries
9595
run: sudo apt-get -yq install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu
96+
- name: Add patches to minimize needed GLIBC version
97+
run: |
98+
CURRENT_DIR="$(pwd)"
99+
sudo apt-get -yq install python3
100+
# download chromium reversion_glibc.py script from chromium source tree at pinned commit (incase they ever move or change it)
101+
wget https://raw.githubusercontent.com/chromium/chromium/01bc42d648c45439e1beef8fd25fde3aef9079bc/build/linux/sysroot_scripts/reversion_glibc.py -O /tmp/reversion_glibc.py
102+
# set targeted minimum GLIBC to 2.17
103+
sed -i 's/26]/17]/g' /tmp/reversion_glibc.py
104+
chmod +x /tmp/reversion_glibc.py
105+
106+
# download the host libc6 package from apt and patch the binaries in it
107+
# replacing the host libc6 at runtime causes crashs and hangs but apt is able to do it without issue
108+
sudo apt-get install --download-only --reinstall -y libc6
109+
sudo rm -rf /tmp/libc6
110+
sudo mkdir /tmp/libc6
111+
sudo cp /var/cache/apt/archives/libc6_2.31-*_amd64.deb /tmp/libc6
112+
cd /tmp/libc6
113+
deb_name="$(ls)"
114+
sudo ar x "$deb_name"
115+
sudo tar xf data.tar.xz
116+
sudo mkdir DEBIAN
117+
sudo tar xf control.tar.xz -C DEBIAN
118+
sudo rm -f control.tar.xz \
119+
data.tar.xz \
120+
debian-binary \
121+
DEBIAN/md5sums \
122+
DEBIAN/archives \
123+
DEBIAN/conffiles \
124+
"$deb_name"
125+
126+
# patch libc6 in host download deb and cross compilers using the reversion_glibc.py script
127+
files=(/tmp/libc6/lib/x86_64-linux-gnu/libc.so.6 /tmp/libc6/lib/x86_64-linux-gnu/libm.so.6
128+
/usr/aarch64-linux-gnu/lib/libc.so.6 /usr/aarch64-linux-gnu/lib/libm.so.6 \
129+
/usr/arm-linux-gnueabihf/lib/libc.so.6 /usr/arm-linux-gnueabihf/lib/libm.so.6 \
130+
/libx32/libc.so.6 /libx32/libm.so.6 \
131+
/lib32/libc.so.6 /lib32/libm.so.6)
132+
for file in "${files[@]}"; do
133+
sudo python3 /tmp/reversion_glibc.py "$file"
134+
done
135+
136+
# install patched libc6 deb
137+
sudo dpkg-deb -b . "$deb_name"
138+
sudo apt install --reinstall --allow-downgrades -y ./"$deb_name"
139+
cd "$CURRENT_DIR"
140+
141+
# __GLIBC_MINOR__ is used as a feature test macro. Replace it with the
142+
# earliest supported version of glibc 2.17
143+
sudo sed -i 's|\(#define\s\+__GLIBC_MINOR__\)|\1 17 //|' "/usr/include/features.h"
144+
sudo sed -i 's|\(#define\s\+__GLIBC_MINOR__\)|\1 17 //|' "/usr/aarch64-linux-gnu/include/features.h"
145+
sudo sed -i 's|\(#define\s\+__GLIBC_MINOR__\)|\1 17 //|' "/usr/arm-linux-gnueabihf/include/features.h"
146+
# fcntl64() was introduced in glibc 2.28. Make sure to use fcntl() instead.
147+
sudo sed -i '{N; s/#ifndef __USE_FILE_OFFSET64\(\nextern int fcntl\)/#if 1\1/}' "/usr/include/fcntl.h"
148+
sudo sed -i '{N; s/#ifndef __USE_FILE_OFFSET64\(\nextern int fcntl\)/#if 1\1/}' "/usr/aarch64-linux-gnu/include/fcntl.h"
149+
sudo sed -i '{N; s/#ifndef __USE_FILE_OFFSET64\(\nextern int fcntl\)/#if 1\1/}' "/usr/arm-linux-gnueabihf/include/fcntl.h"
96150
- name: Download macOS natives
97151
uses: actions/download-artifact@v3
98152
with:

0 commit comments

Comments
 (0)