Skip to content

Problems with mold-linker on riscv64 #2854

@irieger

Description

@irieger

I tried to build the dependencies of a project of mine on my new riscV system. For that I use conan and had traditionally used (and copied) profiles with mold linker instead of the default on Linux. This is due to problems when building dynamic libs where ld requires all recursive dependencies being in the LD_LIBRARY_PATH at link time, not only at runtime. For now I switched to default LD linking which works fine for the projects I currently start on the riscv with. But as I'm not sure if it is highway or mold but all other stuff had worked with mold so far, I'm reporting here first.

This is the error I get:

2026-01-24T23:59:27.821123Z 01E mold: error: CMakeFiles/hwy_list_targets.dir/hwy/tests/list_targets.cc.o: corrupted .riscv.attributes ISA string: rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zmmul1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0

Here is the log output of my conan build.

2026-01-24T23:58:00.658490Z 01E -------- Installing package highway/1.2.0 (5 of 26) --------
2026-01-24T23:58:00.658505Z 01E highway/1.2.0: Building from source
2026-01-24T23:58:00.658512Z 01E highway/1.2.0: Package highway/1.2.0:02a24663675c0c6536ef7fb9b121700649ee896a
2026-01-24T23:58:00.659111Z 01E highway/1.2.0: settings: os=Linux arch=riscv64 compiler=gcc compiler.cppstd=20 compiler.libcxx=libstdc++11 compiler.version=13 build_type=Release
2026-01-24T23:58:00.659135Z 01E highway/1.2.0: options: fPIC=True shared=False with_test=False
2026-01-24T23:58:00.665342Z 01E highway/1.2.0: Copying sources to build folder
2026-01-24T23:58:00.947622Z 01E highway/1.2.0: Building your package in /home/.conan2/p/b/highwc1b12c6903552/b
2026-01-24T23:58:00.948158Z 01E highway/1.2.0: Calling generate()
2026-01-24T23:58:00.948176Z 01E highway/1.2.0: Generators folder: /home/.conan2/p/b/highwc1b12c6903552/b/build/Release/generators
2026-01-24T23:58:01.257740Z 01E highway/1.2.0: CMakeToolchain generated: conan_toolchain.cmake
2026-01-24T23:58:01.262434Z 01E highway/1.2.0: CMakeToolchain generated: /home/.conan2/p/b/highwc1b12c6903552/b/build/Release/generators/CMakePresets.json
2026-01-24T23:58:01.263358Z 01E highway/1.2.0: CMakeToolchain generated: /home/.conan2/p/b/highwc1b12c6903552/b/src/CMakeUserPresets.json
2026-01-24T23:58:01.272209Z 01E highway/1.2.0: Generating aggregated env files
2026-01-24T23:58:01.272232Z 01E highway/1.2.0: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh']
2026-01-24T23:58:01.273750Z 01E highway/1.2.0: Calling build()
2026-01-24T23:58:01.273781Z 01E highway/1.2.0: Apply patch (backport): fix incorrect DLLEXPORT
2026-01-24T23:58:01.306340Z 01E highway/1.2.0: Running CMake.configure()
2026-01-24T23:58:01.307376Z 01E highway/1.2.0: RUN: cmake -G "Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE="generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="/home/.conan2/p/b/highwc1b12c6903552/p" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "/home/.conan2/p/b/highwc1b12c6903552/b/src"
2026-01-24T23:58:01.366523Z 01E CMake Deprecation Warning at CMakeLists.txt:28 (cmake_policy):
2026-01-24T23:58:01.366561Z 01E   The OLD behavior for policy CMP0111 will be removed from a future version
2026-01-24T23:58:01.366574Z 01E   of CMake.
2026-01-24T23:58:01.366578Z 01E 
2026-01-24T23:58:01.366583Z 01E   The cmake-policies(7) manual explains that the OLD behaviors of all
2026-01-24T23:58:01.366589Z 01E   policies are deprecated and that a policy should be set to OLD only under
2026-01-24T23:58:01.366594Z 01E   specific short-term circumstances.  Projects should be ported to the NEW
2026-01-24T23:58:01.366599Z 01E   behavior and not rely on setting a policy to OLD.
2026-01-24T23:58:01.366604Z 01E 
2026-01-24T23:58:01.366608Z 01E 
2026-01-24T23:58:01.387156Z 01E -- Using Conan toolchain: /home/.conan2/p/b/highwc1b12c6903552/b/build/Release/generators/conan_toolchain.cmake
2026-01-24T23:58:01.387202Z 01E -- Conan toolchain: Setting CMAKE_POSITION_INDEPENDENT_CODE=ON (options.fPIC)
2026-01-24T23:58:01.387212Z 01E -- Conan toolchain: C++ Standard 20 with extensions OFF
2026-01-24T23:58:01.387898Z 01E -- Conan toolchain: Setting BUILD_SHARED_LIBS = OFF
2026-01-24T23:58:01.760442Z 01E -- The C compiler identification is GNU 13.3.0
2026-01-24T23:58:02.229433Z 01E -- The CXX compiler identification is GNU 13.3.0
2026-01-24T23:58:02.330606Z 01E -- Detecting C compiler ABI info
2026-01-24T23:58:02.872899Z 01E -- Detecting C compiler ABI info - done
2026-01-24T23:58:02.954585Z 01E -- Check for working C compiler: /usr/bin/cc - skipped
2026-01-24T23:58:02.956823Z 01E -- Detecting C compile features
2026-01-24T23:58:02.960998Z 01E -- Detecting C compile features - done
2026-01-24T23:58:03.018016Z 01E -- Detecting CXX compiler ABI info
2026-01-24T23:58:03.585525Z 01E -- Detecting CXX compiler ABI info - done
2026-01-24T23:58:03.669313Z 01E -- Check for working CXX compiler: /usr/bin/c++ - skipped
2026-01-24T23:58:03.671413Z 01E -- Detecting CXX compile features
2026-01-24T23:58:03.676427Z 01E -- Detecting CXX compile features - done
2026-01-24T23:58:03.705551Z 01E -- Warning: Standard CMAKE_CXX_STANDARD value defined in conan_toolchain.cmake to 20 has been modified to 11 by /home/.conan2/p/b/highwc1b12c6903552/b/src/cmake/FindAtomics.cmake
2026-01-24T23:58:03.706175Z 01E -- Performing Test ATOMICS_LOCK_FREE_INSTRUCTIONS
2026-01-24T23:58:04.578538Z 01E -- Performing Test ATOMICS_LOCK_FREE_INSTRUCTIONS - Success
2026-01-24T23:58:06.830212Z 01E -- Performing Test HWY_EMSCRIPTEN
2026-01-24T23:58:07.117681Z 01E -- Performing Test HWY_EMSCRIPTEN - Failed
2026-01-24T23:58:07.118608Z 01E -- Performing Test HWY_RISCV
2026-01-24T23:58:07.781828Z 01E -- Performing Test HWY_RISCV - Success
2026-01-24T23:58:07.786108Z 01E -- Looking for sys/auxv.h
2026-01-24T23:58:08.704666Z 01E -- Looking for sys/auxv.h - found
2026-01-24T23:58:08.705693Z 01E -- Looking for asm/hwcap.h
2026-01-24T23:58:09.278765Z 01E -- Looking for asm/hwcap.h - found
2026-01-24T23:58:09.313137Z 01E -- Configuring done (8.0s)
2026-01-24T23:58:09.415649Z 01E -- Generating done (0.1s)
2026-01-24T23:58:09.498633Z 01E -- Build files have been written to: /home/.conan2/p/b/highwc1b12c6903552/b/build/Release
2026-01-24T23:58:09.524044Z 01E 
2026-01-24T23:58:09.524079Z 01E highway/1.2.0: Running CMake.build()
2026-01-24T23:58:09.525870Z 01E highway/1.2.0: RUN: cmake --build "/home/.conan2/p/b/highwc1b12c6903552/b/build/Release" -- -j8
2026-01-24T23:58:09.843725Z 01E [  2%] Building CXX object CMakeFiles/hwy.dir/hwy/abort.cc.o
2026-01-24T23:58:09.843783Z 01E [  7%] Building CXX object CMakeFiles/hwy.dir/hwy/per_target.cc.o
2026-01-24T23:58:09.843797Z 01E [  7%] Building CXX object CMakeFiles/hwy.dir/hwy/nanobenchmark.cc.o
2026-01-24T23:58:09.845014Z 01E [ 12%] Building CXX object CMakeFiles/hwy.dir/hwy/print.cc.o
2026-01-24T23:58:09.845074Z 01E [ 12%] Building CXX object CMakeFiles/hwy.dir/hwy/aligned_allocator.cc.o
2026-01-24T23:58:09.849641Z 01E [ 15%] Building CXX object CMakeFiles/hwy.dir/hwy/targets.cc.o
2026-01-24T23:58:09.858406Z 01E [ 17%] Building CXX object CMakeFiles/hwy.dir/hwy/timer.cc.o
2026-01-24T23:58:48.801600Z 01E [ 20%] Linking CXX static library libhwy.a
2026-01-24T23:58:49.093534Z 01E [ 20%] Built target hwy
2026-01-24T23:58:49.255554Z 01E [ 25%] Building CXX object CMakeFiles/hwy_test.dir/hwy/tests/test_util.cc.o
2026-01-24T23:58:49.259846Z 01E [ 25%] Building CXX object CMakeFiles/hwy_list_targets.dir/hwy/tests/list_targets.cc.o
2026-01-24T23:58:49.259907Z 01E [ 27%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_128a.cc.o
2026-01-24T23:58:49.261342Z 01E [ 30%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_f16a.cc.o
2026-01-24T23:58:49.266430Z 01E [ 37%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_128d.cc.o
2026-01-24T23:58:49.272787Z 01E [ 37%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_f32a.cc.o
2026-01-24T23:58:49.272848Z 01E [ 37%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_f16d.cc.o
2026-01-24T23:58:49.277964Z 01E [ 40%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_f32d.cc.o
2026-01-24T23:58:55.370269Z 01E [ 42%] Linking CXX static library libhwy_test.a
2026-01-24T23:58:55.680886Z 01E [ 42%] Built target hwy_test
2026-01-24T23:58:55.901677Z 01E [ 45%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_f64a.cc.o
2026-01-24T23:59:27.541034Z 01E [ 47%] Linking CXX executable hwy_list_targets
2026-01-24T23:59:27.674162Z 01E mimalloc: warning: unable to directly request hinted aligned OS memory (error: 2 (0x2), size: 0x2000000 bytes, alignment: 0x2000000, hint address: 0x20000000000)
2026-01-24T23:59:27.674230Z 01E mimalloc: warning: unable to allocate aligned OS memory directly, fall back to over-allocation (size: 0x2000000 bytes, address: 0x3f9176c000, alignment: 0x2000000, commit: 1)
2026-01-24T23:59:27.752218Z 01E [ 50%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_f64d.cc.o
2026-01-24T23:59:27.821123Z 01E mold: error: CMakeFiles/hwy_list_targets.dir/hwy/tests/list_targets.cc.o: corrupted .riscv.attributes ISA string: rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zmmul1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0
2026-01-24T23:59:28.029848Z 01E [ 52%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_i16a.cc.o
2026-01-24T23:59:30.332361Z 01E collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped
2026-01-24T23:59:30.332420Z 01E compilation terminated.
2026-01-24T23:59:30.340788Z 01E gmake[2]: *** [CMakeFiles/hwy_list_targets.dir/build.make:98: hwy_list_targets] Error 1
2026-01-24T23:59:30.341721Z 01E gmake[1]: *** [CMakeFiles/Makefile2:167: CMakeFiles/hwy_list_targets.dir/all] Error 2
2026-01-24T23:59:30.342086Z 01E gmake[1]: *** Waiting for unfinished jobs....
2026-01-24T23:59:30.424676Z 01E [ 55%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_i16d.cc.o
2026-01-25T00:00:20.915918Z 01E [ 57%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_i32a.cc.o
2026-01-25T00:00:22.560735Z 01E [ 60%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_i32d.cc.o
2026-01-25T00:00:28.276873Z 01E [ 62%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_i64a.cc.o
2026-01-25T00:00:29.466665Z 01E [ 65%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_i64d.cc.o
2026-01-25T00:00:46.362126Z 01E [ 67%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_kv128a.cc.o
2026-01-25T00:00:57.071909Z 01E [ 70%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_kv128d.cc.o
2026-01-25T00:01:01.870716Z 01E [ 72%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_kv64a.cc.o
2026-01-25T00:01:12.829407Z 01E [ 75%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_kv64d.cc.o
2026-01-25T00:01:52.128855Z 01E [ 77%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_u16a.cc.o
2026-01-25T00:01:56.388771Z 01E [ 80%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_u16d.cc.o
2026-01-25T00:02:12.467240Z 01E [ 82%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_u32a.cc.o
2026-01-25T00:02:14.279752Z 01E [ 85%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_u32d.cc.o
2026-01-25T00:02:22.857147Z 01E [ 87%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_u64a.cc.o
2026-01-25T00:02:35.924874Z 01E [ 90%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort_u64d.cc.o
2026-01-25T00:02:41.849995Z 01E [ 92%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/image/image.cc.o
2026-01-25T00:02:54.772254Z 01E [ 95%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/sort/vqsort.cc.o
2026-01-25T00:03:29.925197Z 01E [ 97%] Building CXX object CMakeFiles/hwy_contrib.dir/hwy/contrib/thread_pool/topology.cc.o
2026-01-25T00:04:09.559851Z 01E [100%] Linking CXX static library libhwy_contrib.a
2026-01-25T00:04:10.131155Z 01E [100%] Built target hwy_contrib
2026-01-25T00:04:10.137825Z 01E gmake: *** [Makefile:136: all] Error 2
2026-01-25T00:04:10.146605Z 01E 
2026-01-25T00:04:10.156059Z 01E highway/1.2.0: ERROR: 
2026-01-25T00:04:10.156097Z 01E Package '02a24663675c0c6536ef7fb9b121700649ee896a' build failed
2026-01-25T00:04:10.156468Z 01E highway/1.2.0: WARN: Build folder /home/.conan2/p/b/highwc1b12c6903552/b/build/Release
2026-01-25T00:04:10.165962Z 01E ERROR: highway/1.2.0: Error in build() method, line 96
2026-01-25T00:04:10.165997Z 01E 	cmake.build()
2026-01-25T00:04:10.166003Z 01E 	ConanException: Error 2 while executing

The warnings regarding allocation (based on my research isn't tragic) and is a known issue of mold on riscv64:

2026-01-24T23:59:27.674230Z 01E mimalloc: warning: unable to allocate aligned OS memory directly, fall back to over-allocation (size: 0x2000000 bytes, address: 0x3f9176c000, alignment: 0x2000000, commit: 1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions