mold wrapper issue when building in an armv7l container on a arm64/armv7l host using mold 2.4.0
I'm seeing this issue when doing mold -run ninja in one of our armv7l containers running on an arm64/armv7l hosts.
[508/2712] Compiling C object src/vulkan/runtime/libvulkan_runtime.a.p/vk_command_pool.c.o
ERROR: ld.so: object '/usr/local/lib/mold/mold-wrapper.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
[509/2712] Compiling C object src/vulkan/runtime/libvulkan_runtime.a.p/vk_debug_report.c.o
ERROR: ld.so: object '/usr/local/lib/mold/mold-wrapper.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
[510/2712] Compiling C object src/vulkan/runtime/libvulkan_runtime.a.p/vk_descriptor_set_layout.c.o
ERROR: ld.so: object '/usr/local/lib/mold/mold-wrapper.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
[511/2712] Compiling C object src/vulkan/runtime/libvulkan_runtime.a.p/vk_deferred_operation.c.o
ERROR: ld.so: object '/usr/local/lib/mold/mold-wrapper.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
[512/2712] Compiling C object src/vulkan/runtime/libvulkan_runtime.a.p/vk_debug_utils.c.o
ERROR: ld.so: object '/usr/local/lib/mold/mold-wrapper.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
[513/2712] Compiling C object src/vulkan/runtime/libvulkan_runtime.a.p/vk_descriptors.c.o
ERROR: ld.so: object '/usr/local/lib/mold/mold-wrapper.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
[514/2712] Compiling C object src/vulkan/runtime/libvulkan_runtime.a.p/vk_device_memory.c.o
ERROR: ld.so: object '/usr/local/lib/mold/mold-wrapper.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
[515/2712] Compiling C object src/vulkan/runtime/libvulkan_runtime.a.p/vk_descriptor_update_template.c.o
ERROR: ld.so: object '/usr/local/lib/mold/mold-wrapper.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
[516/2712] Compiling C object src/vulkan/runtime/libvulkan_runtime.a.p/vk_device.c.o
ERROR: ld.so: object '/usr/local/lib/mold/mold-wrapper.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
[517/2712] Compiling C object src/vulkan/runtime/libvulkan_runtime.a.p/vk_framebuffer.c.o
ERROR: ld.so: object '/usr/local/lib/mold/mold-wrapper.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
[518/2712] Compiling C object src/vulkan/runtime/libvulkan_runtime.a.p/vk_fence.c.o
ERROR: ld.so: object '/usr/local/lib/mold/mold-wrapper.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
[519/2712] Compiling C object src/vulkan/runtime/libvulkan_runtime.a.p/vk_log.c.o
ERROR: ld.so: object '/usr/local/lib/mold/mold-wrapper.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
[520/2712] Compiling C object src/vulkan/runtime/libvulkan_runtime.a.p/vk_image.c.o
ERROR: ld.so: object '/usr/local/lib/mold/mold-wrapper.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
[521/2712] Compiling C object src/vulkan/runtime/libvulkan_runtime.a.p/vk_instance.c.o
ERROR: ld.so: object '/usr/local/lib/mold/mold-wrapper.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
[522/2712] Compiling C object src/vulkan/runtime/libvulkan_runtime.a.p/vk_meta.c.o
ERROR: ld.so: object '/usr/local/lib/mold/mold-wrapper.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
[523/2712] Compiling C object src/vulkan/runtime/libvulkan_runtime.a.p/vk_meta_draw_rects.c.o
ERROR: ld.so: object '/usr/local/lib/mold/mold-wrapper.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored.
chronos@rpi51-armv7l /usr/local/lib/crew/packages $ mold --version
mold 2.4.0 (3d9b4d5c05250fa7c507b0c74038915929f990f1; compatible with GNU ld)
It looks like you built mold as a 32 bit application and use it with a 64 bit compiler. Is this correct? If so, you may want to rebuild mold as a 64 bit application.
We're using it with a 32-bit armv7l userland. The kernel on such systems is often a 64-bit kernel.
This would be equivalent to running a i686 binary on an x86_64 system.
Is there a way of passing a flag to mold -run to avoid this? Or just turn off this auto detection at compile time?
We don't have 64-bit libraries to compile against on this 32-bit armv7l userland.
Is that really the case? I have a Raspberry Pi 4 that is 64-bit kernel and 32-bit userland system, and I didn't see that error on that one. What is the output of the following commands?
$ file /usr/local/lib/mold/mold-wrapper.so
$ file /path/to/your/compiler
chronos@rpi51-armv7l /usr/local/lib/crew/packages $ file /usr/local/lib/mold/mold-wrapper.so
/usr/local/lib/mold/mold-wrapper.so: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, stripped
chronos@rpi51-armv7l /usr/local/lib/crew/packages $ file /usr/local/bin/gcc
/usr/local/bin/gcc: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), statically linked, no section header
chronos@rpi51-armv7l /usr/local/lib/crew/packages $
Also:
chronos@rpi51-armv7l /usr/local/lib/crew/packages $ uname -a
Linux rpi51-armv7l 6.1.0-rpi7-rpi-v8 #1 SMP PREEMPT Debian 1:6.1.63-1+rpt1 (2023-11-24) armv8l ARMv8 Processor rev 1 (v8l) GNU/Linux
chronos@rpi51-armv7l /usr/local/lib/crew/packages $