zlib-ng: error when linking on aarch64

Steps to reproduce:

git clone --depth=1 --recursive --shallow-submodules https://github.com/zlib-ng/zlib-ng
cd zlib-ng
CC=clang CXX=clang++ cmake -DWITH_NATIVE_INSTRUCTIONS=ON -DZLIB_COMPAT=ON -DCMAKE_C_FLAGS="-O3 -march=native -mtune=native -flto=thin" -DCMAKE_CXX_FLAGS="-O3 -march=native -mtune=native -flto=thin" .
MAKEFLAGS=-j"$(nproc)" cmake --build . --config Release

Logs:

/usr/bin/ld: error: LLVM gold plugin: <inline asm>:1:2: unrecognized instruction mnemonic, did you mean: uqsub?
        uqsub16 x13, x13, x8
        ^

clang: error: unable to execute command: Segmentation fault
clang: error: linker command failed due to signal (use -v to see invocation)
gmake[2]: *** [test/CMakeFiles/minigzip.dir/build.make:98: minigzip] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:248: test/CMakeFiles/minigzip.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
[ 45%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_deflate_copy.cc.o
/usr/bin/ld: error: LLVM gold plugin: <inline asm>:1:2: unrecognized instruction mnemonic, did you mean: uqsub?
        uqsub16 x13, x13, x8
        ^

clang: error: unable to execute command: Segmentation fault
clang: error: linker command failed due to signal (use -v to see invocation)
gmake[2]: *** [CMakeFiles/zlib.dir/build.make:689: libz.so.1.3.0.zlib-ng] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:170: CMakeFiles/zlib.dir/all] Error 2
[ 45%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_deflate_dict.cc.o
[ 46%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_deflate_hash_head_0.cc.o
[ 47%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_deflate_header.cc.o
[ 47%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_deflate_params.cc.o
[ 48%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_deflate_pending.cc.o
[ 49%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_deflate_prime.cc.o
[ 50%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_deflate_quick_bi_valid.cc.o
[ 50%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_deflate_quick_block_open.cc.o
[ 51%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_deflate_tune.cc.o
[ 52%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_dict.cc.o
[ 53%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_inflate_adler32.cc.o
[ 54%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_raw.cc.o
[ 54%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_large_buffers.cc.o
[ 55%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_small_buffers.cc.o
[ 56%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_small_window.cc.o
[ 56%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_gzio.cc.o
[ 57%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_adler32.cc.o
[ 58%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_aligned_alloc.cc.o
[ 60%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_compare256.cc.o
[ 60%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_crc32.cc.o
[ 61%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_inflate_sync.cc.o
[ 62%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_main.cc.o
[ 62%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_version.cc.o
[ 63%] Building CXX object test/CMakeFiles/gtest_zlib.dir/test_deflate_concurrency.cc.o
[ 64%] Linking CXX executable ../gtest_zlib
/usr/bin/ld: error: LLVM gold plugin: <inline asm>:1:2: unrecognized instruction mnemonic, did you mean: uqsub?
        uqsub16 x13, x13, x8
        ^

This doesn’t seem to happen on amd64.

About this issue

  • Original URL
  • State: closed
  • Created 6 months ago
  • Comments: 24 (15 by maintainers)

Most upvoted comments

@FireMasterK Could you please test whether PR #1622 fixes your problem and whether it fails in any other way? The theory is that the cause of the problem is that LTO with these aggressive parameters ends up optimizing out the test code in the compiler feature tests, so they will not fail because there is no real feature being tested.

@FireMasterK -DCMAKE_C_FLAGS=-march=native should not need to be specified if using -DWITH_NATIVE_INSTRUCTIONS=ON.

Right, that would be #1538 I don’t think that should be built on Aarch64 at all, so that will require a bugfix in CMake.

I think the check_armv6_compiler_flag test needs to be replaced with a check_c_source_compiles based one. The first one only checks that the compiler accepts the armv6 architecture, but never tests linking a binary.

I can confirm that building with -DWITH_ARMV6=OFF fixes the issue.