Skip to content

Commit e10ef0d

Browse files
committed
feat: use zig cc to target glibc 2.17
1 parent 087de72 commit e10ef0d

File tree

2 files changed

+66
-52
lines changed

2 files changed

+66
-52
lines changed

.github/workflows/release.yml

Lines changed: 65 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -13,93 +13,94 @@ on:
1313
- v[0-9]+.[0-9]+.[0-9]+
1414

1515
env:
16+
ZIG_VERSION: 0.13.0
17+
GLIBC_VERSION: 2.17
1618
BIN_DIR: ${{ github.workspace }}/bin
17-
MINIMUM_CMAKE_VERSION: '3.28'
1819

19-
# Build on the oldest supported images, so we have broader compatibility
20-
# Build with gcc-10 to prevent triggering #14150 (default is still gcc-9 on 20.04)
20+
# Build with zig cc so we can target glibc 2.17, so we have broader compatibility
2121
jobs:
2222
linux:
23-
runs-on: ubuntu-20.04
24-
env:
25-
CC: gcc-10
23+
runs-on: ubuntu-latest
2624
outputs:
2725
version: ${{ steps.build.outputs.version }}
28-
container:
29-
image: ubuntu:18.04
30-
options: --privileged # Privileged mode is needed to load fuse module.
3126
steps:
32-
- name: Prepare container
27+
- name: Install deps from apt
3328
run: |
34-
apt-get update
35-
apt-get install -y software-properties-common
36-
add-apt-repository -y ppa:ubuntu-toolchain-r/test # For gcc-10.
37-
add-apt-repository -y ppa:git-core/ppa # For git>=2.18.
38-
apt-get update
39-
apt-get install -y git gcc-10
40-
apt-get install -y fuse libfuse2 # For linuxdeploy.
29+
sudo apt-get update
30+
sudo apt-get install -y fuse libfuse2 # For linuxdeploy.
31+
sudo apt-get install -y build-essential curl gettext ninja-build unzip cmake
32+
sudo apt-get install -y xz-utils # To extract zig
4133
# Workaround for https://github.com/actions/checkout/issues/766.
4234
git config --global --add safe.directory "$GITHUB_WORKSPACE"
35+
4336
- if: github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name != 'nightly'
4437
uses: actions/checkout@v3
4538
with:
4639
repository: 'neovim/neovim'
4740
ref: ${{ github.event.inputs.tag_name }}
4841
fetch-depth: 0
42+
4943
- if: github.event_name == 'schedule' || github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name == 'nightly')
5044
uses: actions/checkout@v3
5145
with:
5246
repository: 'neovim/neovim'
5347
fetch-depth: 0
54-
- run: |
55-
apt-get update
56-
apt-get install -y build-essential curl gettext ninja-build unzip
48+
49+
# zig cc with -02 implicitly adds -DNDEBUG so remove this from the generator flags
50+
# Not needed for 0.10.1+ : https://github.com/neovim/neovim/pull/29599
51+
- name: Patch Neovim
52+
run: sed -i '/APPEND gen_cflags -O2/d' src/nvim/CMakeLists.txt || true
5753

5854
- name: Add "$BIN_DIR" to path
59-
run: echo "$BIN_DIR" >> $GITHUB_PATH
55+
run: |
56+
mkdir -p "$BIN_DIR"
57+
echo "$BIN_DIR" >> $GITHUB_PATH
6058
61-
# TODO(dundargoc): this is very hacky. We only need to install cmake version
62-
# that is at least the minimum cmake version, but for some reason the
63-
# cmake releases didn't work as described.
64-
- name: Install cmake
59+
- name: Install Zig
6560
run: |
66-
apt-get install -y cmake # Install cmake only for cpack, the cmake version itself is too old
67-
curl --retry 5 --silent --show-error --fail -o /tmp/cmake-installer.sh "https://cmake.org/files/v${MINIMUM_CMAKE_VERSION}/cmake-${MINIMUM_CMAKE_VERSION}.0-linux-x86_64.sh"
68-
mkdir -p "$BIN_DIR" /opt/cmake-custom
69-
chmod a+x /tmp/cmake-installer.sh
70-
/tmp/cmake-installer.sh --prefix=/opt/cmake-custom --skip-license
71-
ln -sfn /opt/cmake-custom/bin/cmake "$BIN_DIR/cmake"
72-
cmake_version="$(cmake --version | head -1)"
73-
echo "$cmake_version" | grep -qF "cmake version $MINIMUM_CMAKE_VERSION.0" || {
74-
echo "Unexpected CMake version: $cmake_version"
75-
exit 1
76-
}
61+
curl -O https://ziglang.org/builds/zig-linux-$(arch)-$ZIG_VERSION.tar.xz
62+
tar -xf zig-linux-$(arch)-$ZIG_VERSION.tar.xz
63+
rm -rf zig-linux-$(arch)-$ZIG_VERSION.tar.xz
64+
ln -s $(pwd)/zig-linux-$(arch)-$ZIG_VERSION/zig $BIN_DIR/zig
65+
66+
# Include -lunwind so luajit can be linked
67+
# Include -g0 to strip debug info by default.
68+
# Note: Cmake should override this for debug builds by appending -g
69+
echo 'exec zig cc -target $(arch)-linux-gnu.${GLIBC_VERSION} -lunwind -g0 "$@"' > $BIN_DIR/zigcc
70+
chmod +x $BIN_DIR/zigcc
7771
7872
- if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name != 'nightly')
7973
run: |
8074
echo 'CMAKE_BUILD_TYPE=Release' >> $GITHUB_ENV
8175
echo 'APPIMAGE_TAG=latest' >> $GITHUB_ENV
76+
8277
- if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && github.event.inputs.tag_name == 'nightly')
8378
run: |
8479
echo 'CMAKE_BUILD_TYPE=RelWithDebInfo' >> $GITHUB_ENV
8580
echo 'APPIMAGE_TAG=nightly' >> $GITHUB_ENV
81+
8682
- name: appimage
83+
env:
84+
CC: zigcc
8785
run: ./scripts/genappimage.sh ${APPIMAGE_TAG}
8886
- run: cpack --config build/CPackConfig.cmake
87+
8988
- uses: actions/upload-artifact@v3
9089
with:
9190
name: appimage
9291
path: |
9392
build/bin/nvim.appimage
9493
build/bin/nvim.appimage.zsync
9594
retention-days: 1
95+
9696
- uses: actions/upload-artifact@v3
9797
with:
9898
name: nvim-linux64
9999
path: |
100100
build/nvim-linux64.tar.gz
101101
build/nvim-linux64.deb
102102
retention-days: 1
103+
103104
- name: Export version
104105
id: build
105106
run: |
@@ -127,31 +128,44 @@ jobs:
127128

128129
- if: github.event_name == 'workflow_dispatch'
129130
run: echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV
131+
130132
- if: github.event_name == 'schedule'
131133
run: echo 'TAG_NAME=nightly' >> $GITHUB_ENV
134+
132135
- if: github.event_name == 'push'
133136
run: |
134137
TAG_NAME=${{ github.ref }}
135138
echo "TAG_NAME=${TAG_NAME#refs/tags/}" >> $GITHUB_ENV
136-
- if: env.TAG_NAME == 'nightly'
137-
run: |
138-
(echo 'SUBJECT=Nvim development (prerelease) build';
139-
echo 'PRERELEASE=--prerelease') >> $GITHUB_ENV
140-
gh release delete nightly --yes || true
141-
git push origin :nightly || true
142-
- if: env.TAG_NAME != 'nightly'
143-
run: |
144-
(echo 'SUBJECT=Nvim release build';
145-
echo 'PRERELEASE=') >> $GITHUB_ENV
146-
gh release delete stable --yes || true
147-
git push origin :stable || true
139+
148140
- name: Publish release
149141
env:
150142
NVIM_VERSION: ${{ needs.linux.outputs.version }}
151143
DEBUG: api
152144
run: |
145+
if [ "$TAG_NAME" == "nightly" ]; then
146+
SUBJECT='Nvim development (prerelease) build'
147+
PRERELEASE='--prerelease'
148+
else
149+
SUBJECT='Nvim release build'
150+
PRERELEASE=
151+
fi
153152
envsubst < "$GITHUB_WORKSPACE/.github/workflows/notes.md" > "$RUNNER_TEMP/notes.md"
154-
if [ "$TAG_NAME" != "nightly" ]; then
155-
gh release create stable $PRERELEASE --notes-file "$RUNNER_TEMP/notes.md" --title "$SUBJECT" --target $GITHUB_SHA nvim-linux64/* appimage/*
153+
154+
if [ "$TAG_NAME" == "nightly" ]; then
155+
git push origin :nightly || true
156+
else
157+
gh release delete stable --yes || true
158+
git push origin :stable || true
159+
gh release create stable \
160+
--notes-file "$RUNNER_TEMP/notes.md" \
161+
--title "$SUBJECT" \
162+
--target $GITHUB_SHA \
163+
nvim-linux64/* appimage/*
156164
fi
157-
gh release create $TAG_NAME $PRERELEASE --notes-file "$RUNNER_TEMP/notes.md" --title "$SUBJECT" --target $GITHUB_SHA nvim-linux64/* appimage/*
165+
166+
gh release delete $TAG_NAME --yes || true
167+
gh release create $TAG_NAME $PRERELEASE \
168+
--notes-file "$RUNNER_TEMP/notes.md" \
169+
--title "$SUBJECT" \
170+
--target $GITHUB_SHA \
171+
nvim-linux64/* appimage/*

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This repo provides best-effort, [unsupported builds](https://github.com/neovim/n
66
(as opposed to the [supported builds](https://github.com/neovim/neovim/releases)) of Nvim for some legacy
77
systems or other quirky scenarios:
88

9-
- Linux (built with glibc 2.27, unlike the [supported builds](https://github.com/neovim/neovim/releases)
9+
- Linux (built with glibc 2.17, unlike the [supported builds](https://github.com/neovim/neovim/releases)
1010
which use a newer glibc)
1111
- Appimage
1212
- tar.gz

0 commit comments

Comments
 (0)