Closed ausil closed 3 months ago
I cannot debug it myself because Fedora doesn't provide a Docker image for riscv64.
Can you run the failing tests as bash -x test/elf/static-pie.sh
and bash -x test/elf/ifunc-static-pie.sh
and copy-n-paste the output?
running the tests alone they pass okay, but as part of the rpm build they fail
The following tests FAILED:
122 - riscv64-ifunc-static-pie (Failed)
225 - riscv64-static-pie (Failed)
Errors while running CTest
error: Bad exit status from /var/tmp/rpm-tmp.aoysuV (%check)
RPM build errors:
Bad exit status from /var/tmp/rpm-tmp.aoysuV (%check)
[mockbuild@a460513229fd4580ab9226e651e0bfbe ~]$ cd /builddir/build/BUILD/mold-2.32.0/
[mockbuild@a460513229fd4580ab9226e651e0bfbe mold-2.32.0]$ bash -x test/elf/static-pie.sh
++ dirname test/elf/static-pie.sh
+ . test/elf/common.inc
++ export LC_ALL=C
++ LC_ALL=C
++ '[' -z '' ']'
++++ uname -m
+++ canonical_name riscv64
+++ case $1 in
+++ echo riscv64
++ MACHINE=riscv64
++ '[' -z '' ']'
++ TESTDIR=out/test/elf/riscv64
++ CC=cc
++ CXX=c++
++ GCC=gcc
++ GXX=g++
++ OBJDUMP=objdump
++ OBJCOPY=objcopy
++ STRIP=strip
++ QEMU=
++ '[' riscv64 = x86_64 -o riscv64 = i686 -o riscv64 = arm ']'
++ '[' riscv64 = aarch64 ']'
++ trap 'on_error $LINENO' ERR
++ trap on_exit EXIT
+++ basename test/elf/static-pie.sh .sh
++ testname=static-pie
++ echo -n 'Testing static-pie ... '
Testing static-pie ... ++ t=out/test/elf/riscv64/static-pie
++ mkdir -p out/test/elf/riscv64/static-pie
+ test_cflags -static-pie
+ echo 'int main() {}'
+ cc -static-pie -o /dev/null -xc -
+ cat
+ cc -o out/test/elf/riscv64/static-pie/a.o -c -xc - -fPIE
+ cc -B. -o out/test/elf/riscv64/static-pie/exe1 out/test/elf/riscv64/static-pie/a.o -static-pie
+ out/test/elf/riscv64/static-pie/exe1
+ grep -q 'Hello world'
+ cc -B. -o out/test/elf/riscv64/static-pie/exe2 out/test/elf/riscv64/static-pie/a.o -static-pie -Wl,--no-relax
+ out/test/elf/riscv64/static-pie/exe2
+ grep -q 'Hello world'
+ on_exit
+ echo OK
OK
+ exit 0
[mockbuild@a460513229fd4580ab9226e651e0bfbe mold-2.32.0]$ bash -x test/elf/ifunc-static-pie.sh
++ dirname test/elf/ifunc-static-pie.sh
+ . test/elf/common.inc
++ export LC_ALL=C
++ LC_ALL=C
++ '[' -z '' ']'
++++ uname -m
+++ canonical_name riscv64
+++ case $1 in
+++ echo riscv64
++ MACHINE=riscv64
++ '[' -z '' ']'
++ TESTDIR=out/test/elf/riscv64
++ CC=cc
++ CXX=c++
++ GCC=gcc
++ GXX=g++
++ OBJDUMP=objdump
++ OBJCOPY=objcopy
++ STRIP=strip
++ QEMU=
++ '[' riscv64 = x86_64 -o riscv64 = i686 -o riscv64 = arm ']'
++ '[' riscv64 = aarch64 ']'
++ trap 'on_error $LINENO' ERR
++ trap on_exit EXIT
+++ basename test/elf/ifunc-static-pie.sh .sh
++ testname=ifunc-static-pie
++ echo -n 'Testing ifunc-static-pie ... '
Testing ifunc-static-pie ... ++ t=out/test/elf/riscv64/ifunc-static-pie
++ mkdir -p out/test/elf/riscv64/ifunc-static-pie
+ test_cflags -static-pie
+ echo 'int main() {}'
+ cc -static-pie -o /dev/null -xc -
+ supports_ifunc
+ is_musl
+ ldd --version
+ grep -q musl
+ echo 'void x() __attribute__((ifunc("y"))); void *y() { return 0; }'
+ cc -c -o /dev/null -xc -
+ cat
+ cc -o out/test/elf/riscv64/ifunc-static-pie/a.o -c -xc - -fPIC
+ cc -B. -o out/test/elf/riscv64/ifunc-static-pie/exe2 out/test/elf/riscv64/ifunc-static-pie/a.o -static-pie
+ out/test/elf/riscv64/ifunc-static-pie/exe2
+ grep -q 'Hello world'
+ on_exit
+ echo OK
OK
+ exit 0
ctest
runs the scripts just like you manually did, so it is odd that the scripts failed only for the rpm build. I'm not familiar with the RPM packaging system. Can you debug a little bit to see which command in the scripts failed?
rpmbuild output the full failure
125/338 Test #122: riscv64-ifunc-static-pie ....................***Failed 3.05 sec
++ dirname /builddir/build/BUILD/mold-2.32.0/test/elf/ifunc-static-pie.sh
+ . /builddir/build/BUILD/mold-2.32.0/test/elf/common.inc
++ export LC_ALL=C
++ LC_ALL=C
++ '[' -z riscv64 ']'
++ '[' -z '' ']'
++ TESTDIR=out/test/elf/riscv64
++ CC=cc
++ CXX=c++
++ GCC=gcc
++ GXX=g++
++ OBJDUMP=objdump
++ OBJCOPY=objcopy
++ STRIP=strip
++ QEMU=
++ '[' riscv64 = x86_64 -o riscv64 = i686 -o riscv64 = arm ']'
++ '[' riscv64 = aarch64 ']'
++ trap 'on_error $LINENO' ERR
++ trap on_exit EXIT
+++ basename /builddir/build/BUILD/mold-2.32.0/test/elf/ifunc-static-pie.sh .sh
++ testname=ifunc-static-pie
++ echo -n 'Testing ifunc-static-pie ... '
Testing ifunc-static-pie ... ++ t=out/test/elf/riscv64/ifunc-static-pie
++ mkdir -p out/test/elf/riscv64/ifunc-static-pie
+ test_cflags -static-pie
+ echo 'int main() {}'
+ cc -static-pie -o /dev/null -xc -
+ supports_ifunc
+ is_musl
+ ldd --version
+ grep -q musl
+ echo 'void x() __attribute__((ifunc("y"))); void *y() { return 0; }'
+ cc -c -o /dev/null -xc -
+ cat
+ cc -o out/test/elf/riscv64/ifunc-static-pie/a.o -c -xc - -fPIC
+ cc -B. -o out/test/elf/riscv64/ifunc-static-pie/exe2 out/test/elf/riscv64/ifunc-static-pie/a.o -static-pie
+ out/test/elf/riscv64/ifunc-static-pie/exe2
+ grep -q 'Hello world'
++ on_error 27
++ code=1
++ echo 'command failed: 27: grep -q '\''Hello world'\'''
command failed: 27: grep -q 'Hello world'
++ trap - EXIT
++ exit 1
231/338 Test #225: riscv64-static-pie ..........................***Failed 2.81 sec
++ dirname /builddir/build/BUILD/mold-2.32.0/test/elf/static-pie.sh
+ . /builddir/build/BUILD/mold-2.32.0/test/elf/common.inc
++ export LC_ALL=C
++ LC_ALL=C
++ '[' -z riscv64 ']'
++ '[' -z '' ']'
++ TESTDIR=out/test/elf/riscv64
++ CC=cc
++ CXX=c++
++ GCC=gcc
++ GXX=g++
++ OBJDUMP=objdump
++ OBJCOPY=objcopy
++ STRIP=strip
++ QEMU=
++ '[' riscv64 = x86_64 -o riscv64 = i686 -o riscv64 = arm ']'
++ '[' riscv64 = aarch64 ']'
++ trap 'on_error $LINENO' ERR
++ trap on_exit EXIT
+++ basename /builddir/build/BUILD/mold-2.32.0/test/elf/static-pie.sh .sh
++ testname=static-pie
++ echo -n 'Testing static-pie ... '
Testing static-pie ... ++ t=out/test/elf/riscv64/static-pie
++ mkdir -p out/test/elf/riscv64/static-pie
+ test_cflags -static-pie
+ echo 'int main() {}'
+ cc -static-pie -o /dev/null -xc -
+ cat
+ cc -o out/test/elf/riscv64/static-pie/a.o -c -xc - -fPIE
+ cc -B. -o out/test/elf/riscv64/static-pie/exe1 out/test/elf/riscv64/static-pie/a.o -static-pie
+ out/test/elf/riscv64/static-pie/exe1
+ grep -q 'Hello world'
++ on_error 14
++ code=1
++ echo 'command failed: 14: grep -q '\''Hello world'\'''
command failed: 14: grep -q 'Hello world'
++ trap - EXIT
++ exit 1
the rpmbuild puts its output in a slightly different location. The binaries segfault from those two tests
[mockbuild@a460513229fd4580ab9226e651e0bfbe mold-2.32.0]$ redhat-linux-build/out/test/elf/riscv64/static-pie/exe1
Segmentation fault (core dumped)
[mockbuild@a460513229fd4580ab9226e651e0bfbe mold-2.32.0]$ redhat-linux-build/out/test/elf/riscv64/ifunc-static-pie/exe2
Segmentation fault (core dumped)
http://fedora.riscv.rocks:3000/davidlt/-/packages/container/fedora-generic/40 has info on getting a fedora container image
When building mold for riscv on Fedora 40 the test suite fails on 2 tests. I am not sure of the best way to debug them further