Skip to content

Commit a1bc88e

Browse files
CI: rework patches to lower GLIBC requirements
Also remove go version specification as the default version is now high enough ( see desktop#354 (comment) )
1 parent b7926ba commit a1bc88e

File tree

2 files changed

+66
-15
lines changed

2 files changed

+66
-15
lines changed

.github/workflows/ci.yml

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ jobs:
2727
matrix:
2828
os: [macos-11, windows-2019, ubuntu-20.04]
2929
arch: [x86, x64]
30-
go: [1.16.3]
3130
include:
3231
- os: macos-11
3332
friendlyName: macOS
@@ -36,7 +35,6 @@ jobs:
3635
friendlyName: macOS
3736
targetPlatform: macOS
3837
arch: arm64
39-
go: 1.16.3
4038
- os: windows-2019
4139
friendlyName: Windows
4240
targetPlatform: win32
@@ -69,10 +67,9 @@ jobs:
6967
submodules: recursive
7068
# Needed for script/package.sh to work
7169
fetch-depth: 0
72-
- name: Use go ${{ matrix.go }}
70+
- name: Install go
71+
if: matrix.targetPlatform == 'macOS'
7372
uses: actions/setup-go@v2
74-
with:
75-
go-version: ${{ matrix.go }}
7673
- name: Install dependencies
7774
run: npm install
7875
- name: Check formatting
@@ -108,6 +105,70 @@ jobs:
108105
sudo dpkg --add-architecture armhf
109106
sudo apt-get update
110107
sudo apt-get install gcc-arm-linux-gnueabihf binutils-arm-linux-gnueabihf libcurl4-gnutls-dev:armhf zlib1g-dev:armhf gettext
108+
- name: Add patches to minimize needed GLIBC version
109+
if: matrix.targetPlatform == 'ubuntu'
110+
run: |
111+
CURRENT_DIR="$(pwd)"
112+
sudo apt-get -yq install python3
113+
# download chromium reversion_glibc.py script from chromium source tree at pinned commit (incase they ever move or change it)
114+
wget https://raw.githubusercontent.com/chromium/chromium/01bc42d648c45439e1beef8fd25fde3aef9079bc/build/linux/sysroot_scripts/reversion_glibc.py -O /tmp/reversion_glibc.py
115+
# set targeted minimum GLIBC to 2.17
116+
sed -i 's/26]/17]/g' /tmp/reversion_glibc.py
117+
chmod +x /tmp/reversion_glibc.py
118+
# download the host libc6 package from apt and patch the binaries in it
119+
# replacing the host libc6 at runtime causes crashs and hangs but apt is able to do it without issue
120+
sudo apt-get install --download-only --reinstall -y libc6
121+
sudo rm -rf /tmp/libc6
122+
sudo mkdir /tmp/libc6
123+
sudo cp /var/cache/apt/archives/libc6_2.31-*_amd64.deb /tmp/libc6
124+
cd /tmp/libc6
125+
deb_name="$(ls)"
126+
sudo ar x "$deb_name"
127+
sudo tar xf data.tar.xz
128+
sudo mkdir DEBIAN
129+
sudo tar xf control.tar.xz -C DEBIAN
130+
sudo rm -f control.tar.xz \
131+
data.tar.xz \
132+
debian-binary \
133+
DEBIAN/md5sums \
134+
DEBIAN/archives \
135+
DEBIAN/conffiles \
136+
"$deb_name"
137+
138+
# patch libc6 in host download deb and cross compilers using the reversion_glibc.py script
139+
files=(/tmp/libc6/lib/x86_64-linux-gnu/libc.so.6 /tmp/libc6/lib/x86_64-linux-gnu/libm.so.6 \
140+
/usr/aarch64-linux-gnu/lib/libc.so.6 /usr/aarch64-linux-gnu/lib/libm.so.6 \
141+
/usr/arm-linux-gnueabihf/lib/libc.so.6 /usr/arm-linux-gnueabihf/lib/libm.so.6 \
142+
/libx32/libc.so.6 /libx32/libm.so.6 \
143+
/lib32/libc.so.6 /lib32/libm.so.6 \
144+
/usr/i686-linux-gnu/lib/libc.so.6 /usr/i686-linux-gnu/lib/libm.so.6)
145+
for file in "${files[@]}"; do
146+
[ -f $file ] && sudo python3 /tmp/reversion_glibc.py "$file"
147+
done
148+
149+
# install patched libc6 deb
150+
sudo dpkg-deb -b . "$deb_name"
151+
sudo apt install --reinstall --allow-downgrades -y ./"$deb_name"
152+
cd "$CURRENT_DIR"
153+
# __GLIBC_MINOR__ is used as a feature test macro. Replace it with the
154+
# earliest supported version of glibc 2.17
155+
files=(/usr/include/features.h \
156+
/usr/aarch64-linux-gnu/include/features.h \
157+
/usr/arm-linux-gnueabihf/include/features.h \
158+
/usr/i686-linux-gnu/include/features.h)
159+
for file in "${files[@]}"; do
160+
[ -f $file ] && sudo sed -i 's|\(#define\s\+__GLIBC_MINOR__\)|\1 17 //|' "$file"
161+
done
162+
163+
# fcntl64() was introduced in glibc 2.28. Make sure to use fcntl() instead.
164+
files=(/usr/include/fcntl.h \
165+
/usr/aarch64-linux-gnu/include/fcntl.h \
166+
/usr/arm-linux-gnueabihf/include/fcntl.h \
167+
/usr/i686-linux-gnu/include/fcntl.h)
168+
for file in "${files[@]}"; do
169+
[ -f $file ] && sudo sed -i '{N; s/#ifndef __USE_FILE_OFFSET64\(\nextern int fcntl\)/#if 1\1/}' "$file"
170+
done
171+
true
111172
- name: Build (except macOS arm64)
112173
if: matrix.targetPlatform != 'macOS' || matrix.arch != 'arm64'
113174
shell: bash

script/build-ubuntu.sh

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ fi
2222

2323
case "$TARGET_ARCH" in
2424
"x64")
25-
# __GLIBC_MINOR__ is used as a feature test macro. Replace it with the
26-
# earliest supported version of glibc 2.17 as was previously the case when building on ubuntu-18.04
27-
sudo sed -i 's|\(#define\s\+__GLIBC_MINOR__\)|\1 17 //|' "/usr/include/features.h"
28-
# fcntl64() was introduced in glibc 2.28. Make sure to use fcntl() instead.
29-
sudo sed -i '{N; s/#ifndef __USE_FILE_OFFSET64\(\nextern int fcntl\)/#if 1\1/}' "/usr/include/fcntl.h"
3025
DEPENDENCY_ARCH="amd64"
3126
export CC="gcc"
3227
STRIP="strip"
@@ -39,11 +34,6 @@ case "$TARGET_ARCH" in
3934
HOST="--host=i686-linux-gnu"
4035
TARGET="--target=i686-linux-gnu" ;;
4136
"arm64")
42-
# __GLIBC_MINOR__ is used as a feature test macro. Replace it with the
43-
# earliest supported version of glibc 2.17 as was previously the case when building on ubuntu-18.04
44-
sudo sed -i 's|\(#define\s\+__GLIBC_MINOR__\)|\1 17 //|' "/usr/aarch64-linux-gnu/include/features.h"
45-
# fcntl64() was introduced in glibc 2.28. Make sure to use fcntl() instead.
46-
sudo sed -i '{N; s/#ifndef __USE_FILE_OFFSET64\(\nextern int fcntl\)/#if 1\1/}' "/usr/aarch64-linux-gnu/include/fcntl.h"
4737
DEPENDENCY_ARCH="arm64"
4838
export CC="aarch64-linux-gnu-gcc"
4939
STRIP="aarch64-linux-gnu-strip"

0 commit comments

Comments
 (0)