Skip to content

Commit 0fca43e

Browse files
committed
CI: use evergreen runners; update actions.
GitHub will continue to merrily deprecate and remove old runner environments, as is their prerogative. However, the simplest way to produce a library with a low minimum glibc version requirement is to build in an environment having an old glibc. Not only does Ubuntu 18.04 have a fairly old glibc (v2.27), but the symbol versions our library links against require only glibc v2.7 (on x86_64; somewhat higher for some of the other architectures). Having previously fixed cross-compilation compatibility with GCC 8, we are no longer able to build with GCC 7-based compilers. Thankfully, Ubuntu did package GCC 8 on 18.04; it's just not the default.
1 parent 3310fcf commit 0fca43e

File tree

2 files changed

+64
-41
lines changed

2 files changed

+64
-41
lines changed

.github/workflows/build.yml

+39-25
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,32 @@ on:
66
jobs:
77
natives-linux-windows:
88
name: Linux (x86/ARM/PPC) and Windows native library compilation
9-
runs-on: ubuntu-18.04
9+
runs-on: ubuntu-latest
10+
container:
11+
image: ubuntu:18.04
12+
env:
13+
GCC: gcc-8
1014

1115
defaults:
1216
run:
1317
working-directory: src/main/c
1418

1519
steps:
1620
- name: Checkout the target branch
17-
uses: actions/checkout@v2
21+
uses: actions/checkout@v3
1822
- name: Setup Java
19-
uses: actions/setup-java@v1
23+
uses: actions/setup-java@v3
2024
with:
25+
distribution: temurin
2126
java-version: 8
27+
# Don't need the dependency cache here (or in any of the other native
28+
# library compilation steps), because we're not invoking the Java
29+
# compiler in this step. We only need the JDK for its headers.
2230
- name: Install build prerequisites
2331
run: |
24-
sudo apt update
25-
sudo make crosstools
32+
apt-get update
33+
apt-get --assume-yes install make $GCC
34+
make crosstools
2635
2736
- name: Build the Linux and Windows native libraries
2837
run: |
@@ -33,36 +42,37 @@ jobs:
3342
# exactly to the directories inside `src/main/c/resources/native`. That
3443
# way, the Java build job can pull down all artifacts and unpack them
3544
# into that directory to overwrite the versions in-repo. This is sadly
36-
# necessary because the actions/download-artifact@v2 action flattens
45+
# necessary because the actions/download-artifact@v3 action flattens
3746
# paths inside artifacts. If it retained full relative paths, we could
3847
# put Linux and Windows natives inside the same artifact, and we could be
3948
# flexible with the artifact names. But it doesn't, so we can't, and we
4049
# can't.
4150
- name: Upload Linux native libraries
42-
uses: actions/upload-artifact@v2
51+
uses: actions/upload-artifact@v3
4352
with:
4453
name: linux
4554
path: src/main/c/resources/native/linux
4655
- name: Upload Windows native libraries
47-
uses: actions/upload-artifact@v2
56+
uses: actions/upload-artifact@v3
4857
with:
4958
name: windows
5059
path: src/main/c/resources/native/windows
5160

5261
natives-macos:
5362
name: macOS native library compilation
54-
runs-on: macos-10.15
63+
runs-on: macos-latest
5564

5665
defaults:
5766
run:
5867
working-directory: src/main/c
5968

6069
steps:
6170
- name: Checkout the target branch
62-
uses: actions/checkout@v2
71+
uses: actions/checkout@v3
6372
- name: Setup Java
64-
uses: actions/setup-java@v1
73+
uses: actions/setup-java@v3
6574
with:
75+
distribution: temurin
6676
java-version: 8
6777

6878
- name: Build the macOS native libraries
@@ -71,32 +81,34 @@ jobs:
7181
make osx
7282
7383
- name: Upload macOS native libraries
74-
uses: actions/upload-artifact@v2
84+
uses: actions/upload-artifact@v3
7585
with:
7686
name: osx
7787
path: src/main/c/resources/native/osx/libNRJavaSerial.jnilib
7888

7989
natives-freebsd:
8090
name: FreeBSD native library compilation
81-
runs-on: ubuntu-18.04
91+
runs-on: ubuntu-latest
8292
container:
8393
image: empterdose/freebsd-cross-build:9.3
84-
env:
85-
JAVA_HOME: /usr/lib/jvm/default-jvm
8694

8795
defaults:
8896
run:
8997
working-directory: src/main/c
9098

9199
steps:
92100
- name: Checkout the target branch
93-
uses: actions/checkout@v2
101+
uses: actions/checkout@v3
94102
- name: Setup Java
103+
uses: actions/setup-java@v3
104+
with:
105+
distribution: temurin
106+
java-version: 8
107+
- name: Fake the FreeBSD Java headers
95108
# This feels extremely dirty, but the only native header we care about
96109
# is `jni_md.h`, and it is exactly identical between Linux and FreeBSD
97110
# (at least in OpenJDK 8).
98111
run: |
99-
apk add openjdk8
100112
ln -s $JAVA_HOME/include/linux $JAVA_HOME/include/freebsd
101113
102114
- name: Build the FreeBSD native libraries
@@ -106,14 +118,14 @@ jobs:
106118
settarget x86_64-freebsd9 make freebsd64
107119
108120
- name: Upload FreeBSD native libraries
109-
uses: actions/upload-artifact@v2
121+
uses: actions/upload-artifact@v3
110122
with:
111123
name: freebsd
112124
path: src/main/c/resources/native/freebsd
113125

114126
java:
115127
name: Java compilation
116-
runs-on: ubuntu-18.04
128+
runs-on: ubuntu-latest
117129

118130
needs:
119131
- natives-linux-windows
@@ -126,18 +138,20 @@ jobs:
126138
# don't regress formatting when compared with the master branch, we need
127139
# to have a local copy of the master branch for comparison.
128140
- name: Checkout the master branch
129-
uses: actions/checkout@v2
141+
uses: actions/checkout@v3
130142
with:
131143
ref: master
132144
- name: Checkout the target branch
133-
uses: actions/checkout@v2
145+
uses: actions/checkout@v3
134146
- name: Setup Java
135-
uses: actions/setup-java@v1
147+
uses: actions/setup-java@v3
136148
with:
149+
distribution: temurin
137150
java-version: 8
151+
cache: gradle
138152

139153
- name: Download native libraries
140-
uses: actions/download-artifact@v2
154+
uses: actions/download-artifact@v3
141155
with:
142156
path: src/main/c/resources/native
143157

@@ -146,9 +160,9 @@ jobs:
146160

147161
- name: Determine commit hash for artifact filename
148162
id: vars
149-
run: echo "::set-output name=short-rev::$(git rev-parse --short HEAD)"
163+
run: echo "short-rev=$(git rev-parse --short HEAD)" >>$GITHUB_OUTPUT
150164
- name: Upload build artifacts
151-
uses: actions/upload-artifact@v2
165+
uses: actions/upload-artifact@v3
152166
with:
153167
name: nrjavaserial-${{steps.vars.outputs.short-rev}}
154168
path: build/libs/*.jar

src/main/c/Makefile

+25-16
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ include JAVA_HOME.mk
5858

5959
include platform.mk
6060

61+
# Most of the time, GCC is called `gcc` and is installed from a `gcc` package.
62+
# However, sometimes a distribution packages multiple versions of GCC. In this
63+
# case, both the binary and package names of non-default versions are suffixed
64+
# (e.g., `gcc-8`). We can't use the standard CC variable to adapt to this,
65+
# because each target already overrides that variable with the name of the
66+
# appropriate cross compiler.
67+
GCC ?= gcc
68+
6169
# In all cases, we want to include the system JNI headers, our own headers,
6270
# crank the optimization level, and compile position-independent code so that
6371
# it will work as a library (dlopen(3) et al. can load it into any memory).
@@ -87,13 +95,13 @@ all:
8795
$(error $(NO_TARGET_PLATFORM_SPECIFIED))
8896

8997
crosstools:
90-
apt install --install-recommends \
91-
gcc-i686-linux-gnu \
92-
gcc-arm-linux-gnueabi \
93-
gcc-arm-linux-gnueabihf \
94-
gcc-aarch64-linux-gnu \
98+
apt-get --assume-yes install \
99+
$(GCC)-i686-linux-gnu \
100+
$(GCC)-arm-linux-gnueabi \
101+
$(GCC)-arm-linux-gnueabihf \
102+
$(GCC)-aarch64-linux-gnu \
95103
gcc-mingw-w64 \
96-
gcc-powerpc-linux-gnu
104+
$(GCC)-powerpc-linux-gnu
97105

98106
# Does not include Android, because Android toolchains are large, not commonly
99107
# available, and the resulting library is not typically desired.
@@ -108,14 +116,15 @@ LINUX_CFLAGS += -U_FORTIFY_SOURCE
108116
endif
109117

110118
# Requires gcc-i686-linux-gnu.
111-
linux32: export CC := i686-linux-gnu-gcc
119+
linux32: export CC := i686-linux-gnu-$(GCC)
112120
linux32: export CFLAGS += $(LINUX_CFLAGS) -m32
113121
linux32: export LDFLAGS += -m32
114122
linux32: export platform := linux/x86_32
115123
linux32:
116124
$(MAKE) -f natives.mk
117125

118126
# Requires gcc.
127+
linux64: export CC := $(GCC)
119128
linux64: export CFLAGS += $(LINUX_CFLAGS) -m64
120129
linux64: export platform := linux/x86_64
121130
linux64:
@@ -127,7 +136,7 @@ arm: arm32v5 \
127136
arm32v8 arm32v8HF arm64v8
128137

129138
# Requires gcc-arm-linux-gnueabi.
130-
arm32v5: export CC := arm-linux-gnueabi-gcc
139+
arm32v5: export CC := arm-linux-gnueabi-$(GCC)
131140
arm32v5: export CFLAGS += $(LINUX_CFLAGS) -march=armv5t
132141
arm32v5: export LDFLAGS += -march=armv5t
133142
arm32v5: export platform := linux/ARM_32
@@ -136,7 +145,7 @@ arm32v5:
136145
$(MAKE) -f natives.mk
137146

138147
# Requires gcc-arm-linux-gnueabi.
139-
arm32v6: export CC := arm-linux-gnueabi-gcc
148+
arm32v6: export CC := arm-linux-gnueabi-$(GCC)
140149
arm32v6: export CFLAGS += $(LINUX_CFLAGS) -march=armv6
141150
arm32v6: export LDFLAGS += -march=armv6
142151
arm32v6: export platform := linux/ARM_32
@@ -145,7 +154,7 @@ arm32v6:
145154
$(MAKE) -f natives.mk
146155

147156
# Requires gcc-arm-linux-gnueabihf.
148-
arm32v6HF: export CC := arm-linux-gnueabihf-gcc
157+
arm32v6HF: export CC := arm-linux-gnueabihf-$(GCC)
149158
arm32v6HF: export CFLAGS += $(LINUX_CFLAGS) -march=armv6+fp -marm
150159
arm32v6HF: export LDFLAGS += -march=armv6+fp -marm
151160
arm32v6HF: export platform := linux/ARM_32
@@ -154,7 +163,7 @@ arm32v6HF:
154163
$(MAKE) -f natives.mk
155164

156165
# Requires gcc-arm-linux-gnueabi.
157-
arm32v7: export CC := arm-linux-gnueabi-gcc
166+
arm32v7: export CC := arm-linux-gnueabi-$(GCC)
158167
arm32v7: export CFLAGS += $(LINUX_CFLAGS) -march=armv7-a
159168
arm32v7: export LDFLAGS += -march=armv7-a
160169
arm32v7: export platform := linux/ARM_32
@@ -163,7 +172,7 @@ arm32v7:
163172
$(MAKE) -f natives.mk
164173

165174
# Requires gcc-arm-linux-gnueabihf.
166-
arm32v7HF: export CC := arm-linux-gnueabihf-gcc
175+
arm32v7HF: export CC := arm-linux-gnueabihf-$(GCC)
167176
arm32v7HF: export CFLAGS += $(LINUX_CFLAGS) -march=armv7-a+fp
168177
arm32v7HF: export LDFLAGS += -march=armv7-a+fp
169178
arm32v7HF: export platform := linux/ARM_32
@@ -172,7 +181,7 @@ arm32v7HF:
172181
$(MAKE) -f natives.mk
173182

174183
# Requires gcc-arm-linux-gnueabi.
175-
arm32v8: export CC := arm-linux-gnueabi-gcc
184+
arm32v8: export CC := arm-linux-gnueabi-$(GCC)
176185
arm32v8: export CFLAGS += $(LINUX_CFLAGS) -march=armv8-a
177186
arm32v8: export LDFLAGS += -march=armv8-a
178187
arm32v8: export platform := linux/ARM_32
@@ -181,7 +190,7 @@ arm32v8:
181190
$(MAKE) -f natives.mk
182191

183192
# Requires gcc-arm-linux-gnueabihf.
184-
arm32v8HF: export CC := arm-linux-gnueabihf-gcc
193+
arm32v8HF: export CC := arm-linux-gnueabihf-$(GCC)
185194
arm32v8HF: export CFLAGS += $(LINUX_CFLAGS) -march=armv8-a -mfpu=neon-fp-armv8
186195
arm32v8HF: export LDFLAGS += -march=armv8-a -mfpu=neon-fp-armv8
187196
arm32v8HF: export platform := linux/ARM_32
@@ -190,7 +199,7 @@ arm32v8HF:
190199
$(MAKE) -f natives.mk
191200

192201
# Requires gcc-aarch64-linux-gnu.
193-
arm64v8: export CC := aarch64-linux-gnu-gcc
202+
arm64v8: export CC := aarch64-linux-gnu-$(GCC)
194203
arm64v8: export CFLAGS += $(LINUX_CFLAGS) -march=armv8-a+fp
195204
arm64v8: export LDFLAGS += -march=armv8-a+fp
196205
arm64v8: export platform := linux/ARM_64
@@ -208,7 +217,7 @@ android:
208217
$(MAKE) -f natives.mk
209218

210219
# Requires gcc-powerpc-linux-gnu.
211-
ppc: export CC := powerpc-linux-gnu-gcc
220+
ppc: export CC := powerpc-linux-gnu-$(GCC)
212221
ppc: export CFLAGS += $(LINUX_CFLAGS)
213222
ppc: export platform := linux/PPC
214223
ppc:

0 commit comments

Comments
 (0)