rui314 / mold

Mold: A Modern Linker šŸ¦ 
MIT License
14.4k stars 471 forks source link

Mold 2.34.0 regression after 2.33.0 on armel and armhl targets #1351

Closed Chilledheart closed 1 month ago

Chilledheart commented 1 month ago

Previous:

1s
Run rui314/setup-mold@v1
Run set -x
+ echo 'mold 2.33.0'
mold 2.33.0

working linked program:

Now:

Run rui314/setup-mold@v1
Run set -x
+ echo 'mold 2.34.0'
mold 2.34.0

coredumped program:

Output of qemu:


Run # TMPDIR is required by leveldb unittests
  # TMPDIR is required by leveldb unittests
  qemu-armhf-static -L $SDK_ROOT \
    -E TMPDIR=$PWD/build-linux-armhf \
    $PWD/build-linux-armhf/yass_test \
    --no_exec_proc_tests
  shell: /usr/bin/bash -e {0}
  env:
    CACHE_EPOCH: 130-2
    GOPROXY: direct
    SDK_ROOT: /home/runner/work/yass/yass/debian_bullseye_armhf-sysroot
    EXTRA_BUILD_FLAGS: -use-mold -enable-lto=false
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
/home/runner/work/_temp/8678933d-55ef-43e1-8316-ad41e38608a8.sh: line 5: 11254 Segmentation fault      (core dumped) qemu-armhf-static -L $SDK_ROOT -E TMPDIR=$PWD/build-linux-armhf $PWD/build-linux-armhf/yass_test --no_exec_proc_tests

Using qemu 8.2.5+ds-1 (from debian sid, not available outside build cache for now)

rui314 commented 1 month ago

I built yass on Docker (docker run --platform armhf --rm -it ubuntu:24.04) with the following CMake options

cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DGUI=on -DENABLE_GOLD=off -DUSE_LIBCXX=off -DUSE_GTK4=off -DBUILD_TESTS=1 ..

with mold 2.34.0 that I downloaded from the release notes page (https://github.com/rui314/mold/releases/download/v2.34.0/mold-2.34.0-arm-linux.tar.gz), but it seems I cannot reproduce the issue. yass_test just passed without crashing.

Can you reproduce the issue on a ARM32 Docker image? If so, how?

Chilledheart commented 1 month ago

I can give it a try with native compiling but I don't have arm32 machine. So I will try your way.

In the failing GitHub action job, yass is cross-compiled to target armel/armhf in an x64 machine and runs the unittest via qemu.

rui314 commented 1 month ago

If you can reproduce the issue on a x86-64 Docker image, that would work for me too. I just need to reproduce the issue locally.

Chilledheart commented 1 month ago

Okay. Steps to reproduce locally.

(Make sure your install go,python,cmake,ninja-build,qemu-user-static previously)

git clone https://github.com/Chilledheart/yass
cd yass
# download sysroot
./scripts/install-sysroot.py --arch armel
# download toolchain
./scripts/download-clang-prebuilt-binaries.py
cd tools
go build
cd ..
./tools/build --variant gui --arch armel --sysroot $PWD/debian_bullseye_armel-sysroot --system linux --cmake-build-type Release -build-benchmark -build-test --no-packaging -use-mold -nc -enable-lto=false
qemu-armel-static -L $PWD/debian_bullseye_armel-sysroot $PWD/build-linux-armel/yass_test

Output:

āžœ  yass git:(develop) qemu-armel-static -L $PWD/debian_bullseye_armel-sysroot $PWD/build-linux-armel/yass_test
[1]    24118 segmentation fault (core dumped)  qemu-armel-static -L $PWD/debian_bullseye_armel-sysroot

For your interests: cmake's option:

cmake .. -DOFFICIAL_BUILD=on -DENABLE_LLD=on -DUSE_ZLIB=on -DUSE_JSONCPP=on -DGUI=ON -DCLI=ON -DSERVER=ON -DCMAKE_BUILD_TYPE=Release -G Ninja -DUSE_HOST_TOOLS=on -DBUILD_BENCHMARKS=on -DBUILD_TESTS=on -DUSE_LIBCXX=on -DENABLE_LTO=off -DUSE_MOLD=on -DUSE_CARES=ON -DCMAKE_TOOLCHAIN_FILE=/home/hky/yass-develop/build-linux-armel/../cmake/platforms/Linux.cmake -DLLVM_SYSROOT=/home/hky/yass-develop/third_party/llvm-build/Release+Asserts -DGCC_SYSROOT=/home/hky/yass-develop/debian_bullseye_armel-sysroot -DGCC_SYSTEM_PROCESSOR=armel -DGCC_TARGET=arm-linux-gnueabi -DUSE_TCMALLOC=on -DENABLE_FORTIFY=on
Chilledheart commented 1 month ago

PS I use the mold from https://github.com/rui314/mold/releases/download/v2.34.0/mold-2.34.0-x86_64-linux.tar.gz and extract it to /usr/local directory.

Chilledheart commented 1 month ago

PS2 you need to cd tools and run go build to build tools/build executable. Sorry for missing it at my first glance.

Chilledheart commented 1 month ago

PS3 It takes sometime for me to download required component from internet here to give docker a try and I need some time to rebuild qemu with static-user flag in my Gentoo.

Chilledheart commented 1 month ago
āžœ  ~ sudo systemctl status systemd-binfmt
ā— systemd-binfmt.service - Set Up Additional Binary Formats
     Loaded: loaded (/usr/lib/systemd/system/systemd-binfmt.service; static)
     Active: active (exited) since Thu 2024-10-03 18:02:13 CST; 1min 45s ago
       Docs: man:systemd-binfmt.service(8)
             man:binfmt.d(5)
             https://docs.kernel.org/admin-guide/binfmt-misc.html
             https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
    Process: 106839 ExecStart=/usr/lib/systemd/systemd-binfmt (code=exited, status=0/SUCCESS)
   Main PID: 106839 (code=exited, status=0/SUCCESS)
        CPU: 10ms

Oct 03 18:02:13 define7 systemd[1]: Starting Set Up Additional Binary Formats...
Oct 03 18:02:13 define7 systemd[1]: Finished Set Up Additional Binary Formats.
āžœ  ~ docker run --platform armhf --rm -it ubuntu:24.04 /bin/echo
exec /bin/echo: no such file or directory

Somehow it doesn't work. I will re-try native compiling if I have time later.

rui314 commented 1 month ago

Thank you for the instruction. With that, I could reproduce the issue. It looks like it was a regression introduced in 431fc39db00afb6b5dc9ac7260cd49823fa19160. I think I managed to fix the issue. Can you try again to verify?

I think this bug is worth a new maintenance release.

Chilledheart commented 1 month ago

I can confirm the issue is gone at 186272a (after failing 5fcbf252) locally

āžœ  build-linux-armel git:(develop) mold --version
mold 2.34.0 (186272a425a36d12fd25897aa3628631f3df0099; compatible with GNU ld)
rui314 commented 1 month ago

Cool. I'll release 2.34.1 soon.

Chilledheart commented 1 month ago

PS

From the documentation available online, it seems there is some exception to handling TARGET1 as ABS32 such as cpp init.

image

For kernel space, it is true that it is alias to ABS32 https://patchwork.kernel.org/project/linux-arm-kernel/patch/1407498836-2797-1-git-send-email-a.ryabinin@samsung.com/

rui314 commented 1 month ago

We've been handling R_ARM_TARGET1 as a synonym for R_ARM_ABS32 since the first release of mold with ARM support. So it's been working correctly as far as I know, and we don't want to change that at least in a point release.