Skip to content

Commit 2df822c

Browse files
committed
[Java] Drop legacy glibc support in release builds
1 parent 890b172 commit 2df822c

File tree

2 files changed

+11
-63
lines changed

2 files changed

+11
-63
lines changed

.github/workflows/build.yml

+11-11
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,15 @@ jobs:
108108
runs-on: ubuntu-latest
109109
# Ubuntu's version of rustc uses its own LLVM instead of being a real native package.
110110
# This leaves us with an incompatible LLVM version when linking. Instead, use a real OS.
111-
container: debian:bullseye
111+
container: debian:bookworm
112112
strategy:
113113
fail-fast: false
114114
steps:
115115
- name: Install native Rust toolchain, Valgrind, and build utilitis
116116
run: |
117117
apt-get update
118118
apt-get -y dist-upgrade
119-
apt-get -y install cargo valgrind lld git g++ clang openjdk-11-jdk maven faketime zip unzip llvm curl
119+
apt-get -y install cargo valgrind lld git g++ clang openjdk-17-jdk maven faketime zip unzip llvm curl
120120
- name: Checkout source code
121121
uses: actions/checkout@v2
122122
with:
@@ -153,15 +153,15 @@ jobs:
153153
cd ldk-c-bindings
154154
./genbindings.sh ../rust-lightning true
155155
- name: Build Java Debug Bindings
156-
run: ./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-11-openjdk-amd64/include/ -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux/" true false
156+
run: ./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-17-openjdk-amd64/include/ -I/usr/lib/jvm/java-17-openjdk-amd64/include/linux/" true false
157157
- name: Run Java Tests against Debug Bindings
158158
run: |
159159
mv liblightningjni_debug_Linux-amd64.so liblightningjni.so
160160
export ASAN_OPTIONS=detect_leaks=0
161-
LD_PRELOAD=/usr/lib/llvm-11/lib/clang/11.0.1/lib/linux/libclang_rt.asan-x86_64.so LD_LIBRARY_PATH=. mvn test
161+
LD_PRELOAD=/usr/lib/llvm-14/lib/clang/14.0.6/lib/linux/libclang_rt.asan-x86_64.so LD_LIBRARY_PATH=. mvn test
162162
- name: Build Java Release Bindings
163163
run: |
164-
./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-11-openjdk-amd64/include/ -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux/" false false
164+
./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-17-openjdk-amd64/include/ -I/usr/lib/jvm/java-17-openjdk-amd64/include/linux/" false false
165165
- name: Check latest headers are in git
166166
run: |
167167
git checkout pom.xml
@@ -171,15 +171,15 @@ jobs:
171171
runs-on: ubuntu-latest
172172
# Ubuntu's version of rustc uses its own LLVM instead of being a real native package.
173173
# This leaves us with an incompatible LLVM version when linking. Instead, use a real OS.
174-
container: debian:bullseye
174+
container: debian:bookworm
175175
strategy:
176176
fail-fast: false
177177
steps:
178178
- name: Install native Rust toolchain, Valgrind, and build utilitis
179179
run: |
180180
apt-get update
181181
apt-get -y dist-upgrade
182-
apt-get -y install cargo valgrind lld git g++ clang openjdk-11-jdk maven faketime zip unzip llvm curl
182+
apt-get -y install cargo valgrind lld git g++ clang openjdk-17-jdk maven faketime zip unzip llvm curl
183183
- name: Checkout source code
184184
uses: actions/checkout@v2
185185
with:
@@ -238,7 +238,7 @@ jobs:
238238
- name: Build Leaktracking Java Release Bindings
239239
run: |
240240
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
241-
./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-11-openjdk-amd64/include/ -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux/" leaks false
241+
./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-17-openjdk-amd64/include/ -I/usr/lib/jvm/java-17-openjdk-amd64/include/linux/" leaks false
242242
- name: Build deterministic release jar
243243
run: |
244244
./build-release-jar.sh
@@ -251,7 +251,7 @@ jobs:
251251
- name: Build Java Release Bindings
252252
run: |
253253
export LDK_GARBAGECOLLECTED_GIT_OVERRIDE="$(git describe --tag HEAD)"
254-
./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-11-openjdk-amd64/include/ -I/usr/lib/jvm/java-11-openjdk-amd64/include/linux/" false false
254+
./genbindings.sh ./ldk-c-bindings/ "-I/usr/lib/jvm/java-17-openjdk-amd64/include/ -I/usr/lib/jvm/java-17-openjdk-amd64/include/linux/" false false
255255
- name: Build deterministic release jar
256256
run: ./build-release-jar.sh
257257
- name: Check latest library and jars are in bins repo
@@ -409,15 +409,15 @@ jobs:
409409
android:
410410
runs-on: ubuntu-latest
411411
# Frankly, I'm not really sure why debian and ubuntu differ in the results here, they really shouldn't
412-
container: debian:bullseye
412+
container: debian:bookworm
413413
strategy:
414414
fail-fast: false
415415
steps:
416416
- name: Install rust targets
417417
run: |
418418
apt-get update
419419
apt-get -y dist-upgrade
420-
apt-get -y install git g++ clang faketime zip unzip curl openjdk-11-jdk
420+
apt-get -y install git g++ clang faketime zip unzip curl openjdk-17-jdk
421421
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh
422422
chmod +x ./rustup.sh
423423
./rustup.sh -y

genbindings.sh

-52
Original file line numberDiff line numberDiff line change
@@ -280,62 +280,10 @@ else
280280
LDK_LIB="$1"/lightning-c-bindings/target/$LDK_TARGET/release/libldk.a
281281
if [ "$IS_MAC" = "false" -a "$4" = "false" ]; then
282282
LINK="$LINK -Wl,--version-script=libcode.version -fuse-ld=lld"
283-
# __cxa_thread_atexit_impl is used to more effeciently cleanup per-thread local storage by rust libstd.
284-
# However, it is not available on glibc versions 2.17 or earlier, and rust libstd has a null-check and
285-
# fallback in case it is missing.
286-
# Because it is weak-linked on the rust side, we should be able to simply define it
287-
# explicitly, forcing rust to use the fallback. However, for some reason involving ancient
288-
# dark magic and haunted code segments, overriding the weak symbol only impacts sites which
289-
# *call* the symbol in question, not sites which *compare with* the symbol in question.
290-
# This means that the NULL check in rust's libstd will always think the function is
291-
# callable while the function which is called ends up being NULL (leading to a jmp to the
292-
# zero page and a quick SEGFAULT).
293-
# This issue persists not only with directly providing a symbol, but also ld.lld's -wrap
294-
# and --defsym arguments.
295-
# In smaller programs, it appears to be possible to work around this with -Bsymbolic and
296-
# -nostdlib, however when applied the full-sized JNI library here it no longer works.
297-
# After exhausting nearly every flag documented in lld, the only reliable method appears
298-
# to be editing the LDK binary. Luckily, LLVM's tooling makes this rather easy as we can
299-
# disassemble it into very readable code, edit it, and then reassemble it.
300-
# Note that if we do so we don't have to bother overriding the actual call, LLVM should
301-
# optimize it away, which also provides a good check that there isn't anything actually
302-
# relying on it elsewhere.
303-
[ ! -f "$1"/lightning-c-bindings/target/$LDK_TARGET/release/libldk.a ] && exit 1
304-
if [ "$(ar t "$1"/lightning-c-bindings/target/$LDK_TARGET/release/libldk.a | grep -v "\.o$" || echo)" != "" ]; then
305-
echo "Archive contained non-object files!"
306-
exit 1
307-
fi
308-
if [ "$(ar t "$1"/lightning-c-bindings/target/$LDK_TARGET/release/libldk.a | grep ldk.*-cgu.*.rcgu.o | wc -l)" != "1" ]; then
309-
echo "Archive contained more than one LDK object file"
310-
exit 1
311-
fi
312-
mkdir -p tmp
313-
rm -f tmp/*
314-
ar x --output=tmp "$1"/lightning-c-bindings/target/$LDK_TARGET/release/libldk.a
315-
pushd tmp
316-
llvm-dis ldk*-cgu.*.rcgu.o
317-
sed -i 's/br i1 icmp eq (i8\* @__cxa_thread_atexit_impl, i8\* null)/br i1 icmp eq (i8* null, i8* null)/g' ldk*-cgu.*.rcgu.o.ll
318-
llvm-as ldk*-cgu.*.rcgu.o.ll -o ./libldk.bc
319-
ar q libldk.a *.o
320-
popd
321-
LDK_LIB="tmp/libldk.bc tmp/libldk.a"
322283
fi
323284
$COMPILE -o bindings.o -c -O3 -I"$1"/lightning-c-bindings/include/ $2 src/main/jni/bindings.c
324285
$COMPILE $LINK -o liblightningjni_release$LDK_TARGET_SUFFIX.so -O3 -I"$1"/lightning-c-bindings/include/ $2 bindings.o $LDK_LIB -lm
325286
[ "$IS_APPLE_CLANG" != "true" ] && llvm-strip liblightningjni_release$LDK_TARGET_SUFFIX.so
326-
if [ "$IS_MAC" = "false" -a "$4" = "false" ]; then
327-
GLIBC_SYMBS="$(objdump -T liblightningjni_release$LDK_TARGET_SUFFIX.so | grep GLIBC_ | grep -v "GLIBC_2\.2\." | grep -v "GLIBC_2\.3\(\.\| \)" | grep -v "GLIBC_2.\(14\|17\) " || echo)"
328-
if [ "$GLIBC_SYMBS" != "" ]; then
329-
echo "Unexpected glibc version dependency! Some users need glibc 2.17 support, symbols for newer glibcs cannot be included."
330-
echo "$GLIBC_SYMBS"
331-
exit 1
332-
fi
333-
REALLOC_ARRAY_SYMBS="$(objdump -T liblightningjni_release$LDK_TARGET_SUFFIX.so | grep reallocarray || echo)"
334-
if [ "$REALLOC_ARRAY_SYMBS" != "" ]; then
335-
echo "Unexpected reallocarray dependency!"
336-
exit 1
337-
fi
338-
fi
339287
if [ "$LDK_JAR_TARGET" = "true" ]; then
340288
# Copy to JNI native directory for inclusion in JARs
341289
mkdir -p src/main/resources/

0 commit comments

Comments
 (0)