Skip to content

Commit 87fb442

Browse files
committed
testsuite: Check in optional patch that offers to build everything against a custom glibc sysroot
This was developed because it seemed like glibc 2.33 was causing NSS-style functions that rely on libgotcha's _dl_open() interception to fail. However, the culprit appears to instead by global variable interception. Producing the necessary artifacts to support this requires additional libtestinger build steps (also implemented in the patch) to avoid creating a shared object with too new a glibc version dependency. One must also avoid dynamically linking against libstd because that too can have such a dependency; unfortunately, Cargo makes this harder by *prepending* command-line rustc arguments to the rustflags from the config TOML, so we have to use RUSTFLAGS instead as a workaround. And all this while still steering clear of the issue we worked around in 76ffca6.
1 parent 63a4fd5 commit 87fb442

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

testsuite/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22

33
!/.gitignore
44
!/build
5+
!/custom-glibc.patch
56
!/test
67
!/testinger.c

testsuite/custom-glibc.patch

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
diff --git i/testsuite/build w/testsuite/build
2+
index cf760c0..fe575b8 100755
3+
--- i/testsuite/build
4+
+++ w/testsuite/build
5+
@@ -11,6 +11,7 @@ cargoflags="$1"
6+
shift
7+
buildtype="debug"
8+
cflags="-g3 -Og"
9+
+rustflags=""
10+
case "$cargoflags" in
11+
-*-release*)
12+
buildtype="release"
13+
@@ -27,6 +28,10 @@ if [ "$buildtype" = "release" ]
14+
then
15+
cflags="-O2"
16+
fi
17+
+if [ -e lib ]
18+
+then
19+
+ rustflags="-Clink-arg=-L$PWD/lib"
20+
+fi
21+
22+
cd "`dirname "$0"`"
23+
cd "$LIBINGER"
24+
@@ -34,8 +39,11 @@ cd "$LIBINGER"
25+
set -ve
26+
./configure || true
27+
mkdir -p "target/$buildtype"
28+
-cargo build $cargoflags
29+
cargo run $cargoflags >"target/$buildtype/libinger.h"
30+
+
31+
+export RUSTFLAGS="-Cprefer-dynamic=no"
32+
+cargo build $cargoflags --lib
33+
+cargo build $cargoflags --lib
34+
cp external/libgotcha/libgotcha_api.h "target/$buildtype/libgotcha.h"
35+
cp external/libgotcha/libgotcha_repl.h "target/$buildtype"
36+
objcopy -Wsignal --globalize-symbol libgotcha_dlsym --globalize-symbol libgotcha_signal "target/$buildtype/deps/libgotcha-"*.rlib 2>/dev/null
37+
@@ -43,7 +51,7 @@ rm "target/$buildtype/deps/libinger.so"
38+
cd -
39+
c99 $cflags -Wall -Wextra -Wpedantic -Werror "$@" -c -fpic -fno-optimize-sibling-calls -D_GNU_SOURCE -Wno-missing-attributes -I"$OLDPWD/target/$buildtype" testinger.c
40+
cd -
41+
-cargo rustc $cargoflags --lib -- -Clink-arg="$OLDPWD/testinger.o"
42+
+eval cargo rustc "$cargoflags" --lib -- -Clink-arg="$OLDPWD/testinger.o" "$rustflags" "`sed -n -e's/",/"/g' -e's/^rustflags = \[\(.\+\)\]$/\1/p' .cargo/config`"
43+
cd -
44+
mv "$OLDPWD/target/$buildtype/libinger.so" libtestinger.so
45+
rm "$OLDPWD/target/$buildtype/deps/libinger.so"
46+
diff --git i/testsuite/test w/testsuite/test
47+
index cfef791..0c83013 100755
48+
--- i/testsuite/test
49+
+++ w/testsuite/test
50+
@@ -1,5 +1,7 @@
51+
#!/bin/sh
52+
53+
+readonly VERSION="2.29"
54+
+
55+
GNULIB="$*"
56+
if [ -z "$GNULIB" ]
57+
then
58+
@@ -7,9 +9,38 @@ then
59+
fi
60+
61+
set -ve
62+
-[ ! -e libtestinger.so ] && ./build release
63+
[ ! -e gnulib/configure ] && "$GNULIB/gnulib-tool" --create-testdir --dir gnulib --single-configure `"$GNULIB/posix-modules"`
64+
-[ ! -e Makefile ] && gnulib/configure CFLAGS="-fpic -g3"
65+
+if [ ! -e Makefile ]
66+
+then
67+
+ cflags=""
68+
+ ldflags=""
69+
+ version="`ldd --version | head -n1 | rev | cut -d" " -f1 | rev`"
70+
+ if [ "$version" != "$VERSION" ]
71+
+ then
72+
+ echo >&2
73+
+ echo "!!! It looks like your system uses glibc $version." >&2
74+
+ echo "!!! We recommend running this suite on version $VERSION!" >&2
75+
+ echo >&2
76+
+ printf %s "Path to an alternative ld-linux.so (enter to use system's)? "
77+
+ read interp
78+
+ if [ -n "$interp" ]
79+
+ then
80+
+ interp="`realpath "$interp"`"
81+
+ ldflags="-Wl,-I$interp"
82+
+
83+
+ lib="`dirname "$interp"`"
84+
+ ldflags="-L$lib $ldflags"
85+
+ ln -s "$lib" .
86+
+ rm -f libtestinger.so
87+
+
88+
+ cflags="-I."
89+
+ mkdir sys
90+
+ echo "#error" >sys/single_threaded.h
91+
+ fi
92+
+ fi
93+
+ gnulib/configure CFLAGS="-fpic -g3 $cflags" LDFLAGS="$ldflags"
94+
+fi
95+
+[ ! -e libtestinger.so ] && ./build release
96+
make -j"`getconf _NPROCESSORS_ONLN`"
97+
[ ! -e gltests/test-suite.log ] && make check || true
98+
make check LD_PRELOAD="$PWD/libtestinger.so" LIBGOTCHA_NUMGROUPS="1" LIBGOTCHA_SKIP="`cat <<-tac

0 commit comments

Comments
 (0)