zlib-ng: Cmake sets up but fails to compile with native optimizations using gcc-8.3.0 on Raspbian

uname -a

Linux retropie 6.1.61-v8+ #1696 SMP PREEMPT Thu Nov  2 16:44:46 GMT 2023 aarch64 GNU/Linux

gcc -v

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/8/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Raspbian 8.3.0-6+rpi1' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=arm-linux-gnueabihf- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-sjlj-exceptions --with-arch=armv6 --with-fpu=vfp --with-float=hard --disable-werror --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 8.3.0 (Raspbian 8.3.0-6+rpi1) 

Tested both develop and the 2.1.5 release, as follows:

cmake -DWITH_NATIVE_INSTRUCTIONS=ON .

-- Using CMake version 3.16.3
-- ZLIB_HEADER_VERSION: 1.3.0
-- ZLIBNG_HEADER_VERSION: 2.1.5
-- The C compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Arch detected: 'armv6'
-- Basearch of 'armv6' has been detected as: 'arm'
-- Looking for arm_acle.h
-- Looking for arm_acle.h - found
-- Looking for sys/auxv.h
-- Looking for sys/auxv.h - found
-- Looking for sys/sdt.h
-- Looking for sys/sdt.h - not found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - done
-- Looking for fseeko

-- Looking for fseeko - found
-- Looking for strerror
-- Looking for strerror - found
-- Looking for posix_memalign
-- Looking for posix_memalign - found
-- Looking for aligned_alloc
-- Looking for aligned_alloc - found
-- Performing Test HAVE_NO_INTERPOSITION
-- Performing Test HAVE_NO_INTERPOSITION - Success
-- Performing Test HAVE_ATTRIBUTE_VISIBILITY_HIDDEN
-- Performing Test HAVE_ATTRIBUTE_VISIBILITY_HIDDEN - Success
-- Performing Test HAVE_ATTRIBUTE_VISIBILITY_INTERNAL
-- Performing Test HAVE_ATTRIBUTE_VISIBILITY_INTERNAL - Success
-- Performing Test HAVE_ATTRIBUTE_ALIGNED
-- Performing Test HAVE_ATTRIBUTE_ALIGNED - Success
-- Performing Test HAVE_THREAD_LOCAL
-- Performing Test HAVE_THREAD_LOCAL - Success
-- Performing Test HAVE_BUILTIN_CTZ
-- Performing Test HAVE_BUILTIN_CTZ - Success
-- Performing Test HAVE_BUILTIN_CTZLL
-- Performing Test HAVE_BUILTIN_CTZLL - Success
-- Performing Test HAVE_PTRDIFF_T
-- Performing Test HAVE_PTRDIFF_T - Success
-- Performing Test ARM_AUXV_HAS_CRC32
-- Performing Test ARM_AUXV_HAS_CRC32 - Failed
-- Performing Test ARM_HWCAP_HAS_CRC32
-- Performing Test ARM_HWCAP_HAS_CRC32 - Success
-- Performing Test ARM_AUXV_HAS_NEON
-- Performing Test ARM_AUXV_HAS_NEON - Success
-- Performing Test HAVE_ACLE_FLAG
-- Performing Test HAVE_ACLE_FLAG - Success
-- Performing Test NEON_AVAILABLE
-- Performing Test NEON_AVAILABLE - Success
-- Performing Test NEON_HAS_LD4
-- Performing Test NEON_HAS_LD4 - Failed
-- Performing Test HAVE_ARMV6_INLINE_ASM
-- Performing Test HAVE_ARMV6_INLINE_ASM - Success
-- Performing Test HAVE_ARMV6_INTRIN
-- Performing Test HAVE_ARMV6_INTRIN - Failed
-- Architecture-specific source files: arch/arm/arm_features.c;arch/arm/crc32_acle.c;arch/arm/insert_string_acle.c;arch/arm/adler32_neon.c;arch/arm/chunkset_neon.c;arch/arm/compare256_neon.c;arch/arm/slide_hash_neon.c;arch/arm/slide_hash_armv6.c
-- The CXX compiler identification is GNU 8.3.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY) 

-- Found Python: /usr/bin/python3.7 (found version "3.7.3") found components: Interpreter 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- The following features have been enabled:

 * CMAKE_BUILD_TYPE, Build type: Release (default)
 * ACLE_CRC, Support ACLE optimized CRC hash generation, using ""
 * NEON_ADLER32, Support NEON instructions in adler32, using ""
 * NEON_SLIDEHASH, Support NEON instructions in slide_hash, using ""
 * ARMV6, Support ARMv6 SIMD instructions in slide_hash, using ""
 * WITH_GZFILEOP, Compile with support for gzFile related functions
 * ZLIB_ENABLE_TESTS, Build test binaries
 * ZLIBNG_ENABLE_TESTS, Test zlib-ng specific API
 * WITH_SANITIZER, Enable sanitizer support
 * WITH_GTEST, Build gtest_zlib
 * WITH_OPTIM, Build with optimisation
 * WITH_NEW_STRATEGIES, Use new strategies
 * WITH_NATIVE_INSTRUCTIONS, Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native)
 * WITH_ACLE, Build with ACLE
 * WITH_NEON, Build with NEON intrinsics
 * WITH_ARMV6, Build with ARMv6 SIMD

-- The following OPTIONAL packages have been found:

 * Python
 * Threads

-- The following features have been disabled:

 * ZLIB_SYMBOL_PREFIX, Publicly exported symbols DO NOT have a custom prefix
 * ZLIB_COMPAT, Compile with zlib compatible API
 * WITH_FUZZERS, Build test/fuzz
 * WITH_BENCHMARKS, Build test/benchmarks
 * WITH_BENCHMARK_APPS, Build application benchmarks
 * WITH_MAINTAINER_WARNINGS, Build with project maintainer warnings
 * WITH_CODE_COVERAGE, Enable code coverage reporting
 * WITH_INFLATE_STRICT, Build with strict inflate distance checking
 * WITH_INFLATE_ALLOW_INVALID_DIST, Build with zero fill for inflate invalid distances
 * INSTALL_UTILS, Copy minigzip and minideflate during install

-- The following OPTIONAL packages have not been found:

 * GTest

CMake Warning at CMakeLists.txt:1304 (message):
  Building to source folder is not recommended.  Cpack will be unable to
  generate source package.


-- Configuring done
-- Generating done
-- Build files have been written to: /home/pi/src/zlib-ng

cmake --build . --config Release

Scanning dependencies of target zlibstatic
[  1%] Building C object CMakeFiles/zlibstatic.dir/adler32.c.o
[  1%] Building C object CMakeFiles/zlibstatic.dir/adler32_fold.c.o
[  2%] Building C object CMakeFiles/zlibstatic.dir/chunkset.c.o
[  3%] Building C object CMakeFiles/zlibstatic.dir/compare256.c.o
[  4%] Building C object CMakeFiles/zlibstatic.dir/compress.c.o
[  4%] Building C object CMakeFiles/zlibstatic.dir/cpu_features.c.o
[  5%] Building C object CMakeFiles/zlibstatic.dir/crc32_braid.c.o
[  6%] Building C object CMakeFiles/zlibstatic.dir/crc32_braid_comb.c.o
[  6%] Building C object CMakeFiles/zlibstatic.dir/crc32_fold.c.o
[  7%] Building C object CMakeFiles/zlibstatic.dir/deflate.c.o
[  8%] Building C object CMakeFiles/zlibstatic.dir/deflate_fast.c.o
[  9%] Building C object CMakeFiles/zlibstatic.dir/deflate_huff.c.o
[  9%] Building C object CMakeFiles/zlibstatic.dir/deflate_medium.c.o
[ 10%] Building C object CMakeFiles/zlibstatic.dir/deflate_quick.c.o
[ 11%] Building C object CMakeFiles/zlibstatic.dir/deflate_rle.c.o
[ 12%] Building C object CMakeFiles/zlibstatic.dir/deflate_slow.c.o
[ 12%] Building C object CMakeFiles/zlibstatic.dir/deflate_stored.c.o
[ 13%] Building C object CMakeFiles/zlibstatic.dir/functable.c.o
[ 14%] Building C object CMakeFiles/zlibstatic.dir/infback.c.o
[ 15%] Building C object CMakeFiles/zlibstatic.dir/inflate.c.o
[ 15%] Building C object CMakeFiles/zlibstatic.dir/inftrees.c.o
[ 16%] Building C object CMakeFiles/zlibstatic.dir/insert_string.c.o
[ 17%] Building C object CMakeFiles/zlibstatic.dir/insert_string_roll.c.o
[ 17%] Building C object CMakeFiles/zlibstatic.dir/slide_hash.c.o
[ 18%] Building C object CMakeFiles/zlibstatic.dir/trees.c.o
[ 20%] Building C object CMakeFiles/zlibstatic.dir/uncompr.c.o
[ 21%] Building C object CMakeFiles/zlibstatic.dir/zutil.c.o
[ 21%] Building C object CMakeFiles/zlibstatic.dir/arch/arm/arm_features.c.o
[ 22%] Building C object CMakeFiles/zlibstatic.dir/arch/arm/crc32_acle.c.o
[ 23%] Building C object CMakeFiles/zlibstatic.dir/arch/arm/insert_string_acle.c.o
[ 24%] Building C object CMakeFiles/zlibstatic.dir/arch/arm/adler32_neon.c.o
In file included from /home/pi/src/zlib-ng/arch/arm/neon_intrins.h:8,
                 from /home/pi/src/zlib-ng/arch/arm/adler32_neon.c:9:
/home/pi/src/zlib-ng/arch/arm/neon_intrins.h: In function ‘vld1q_u16_x4’:
/usr/lib/gcc/arm-linux-gnueabihf/8/include/arm_neon.h:10406:1: error: inlining failed in call to always_inline ‘vld1q_u16’: target specific option mismatch
 vld1q_u16 (const uint16_t * __a)
 ^~~~~~~~~
In file included from /home/pi/src/zlib-ng/arch/arm/adler32_neon.c:9:
/home/pi/src/zlib-ng/arch/arm/neon_intrins.h:36:27: note: called from here
                           vld1q_u16(a+24)}};
                           ^~~~~~~~~~~~~~~
In file included from /home/pi/src/zlib-ng/arch/arm/neon_intrins.h:8,
                 from /home/pi/src/zlib-ng/arch/arm/adler32_neon.c:9:
/usr/lib/gcc/arm-linux-gnueabihf/8/include/arm_neon.h:10406:1: error: inlining failed in call to always_inline ‘vld1q_u16’: target specific option mismatch
 vld1q_u16 (const uint16_t * __a)
 ^~~~~~~~~
In file included from /home/pi/src/zlib-ng/arch/arm/adler32_neon.c:9:
/home/pi/src/zlib-ng/arch/arm/neon_intrins.h:35:27: note: called from here
                           vld1q_u16(a+16),
                           ^~~~~~~~~~~~~~~
In file included from /home/pi/src/zlib-ng/arch/arm/neon_intrins.h:8,
                 from /home/pi/src/zlib-ng/arch/arm/adler32_neon.c:9:
/usr/lib/gcc/arm-linux-gnueabihf/8/include/arm_neon.h:10406:1: error: inlining failed in call to always_inline ‘vld1q_u16’: target specific option mismatch
 vld1q_u16 (const uint16_t * __a)
 ^~~~~~~~~
In file included from /home/pi/src/zlib-ng/arch/arm/adler32_neon.c:9:
/home/pi/src/zlib-ng/arch/arm/neon_intrins.h:34:27: note: called from here
                           vld1q_u16(a+8),
                           ^~~~~~~~~~~~~~
In file included from /home/pi/src/zlib-ng/arch/arm/neon_intrins.h:8,
                 from /home/pi/src/zlib-ng/arch/arm/adler32_neon.c:9:
/usr/lib/gcc/arm-linux-gnueabihf/8/include/arm_neon.h:10406:1: error: inlining failed in call to always_inline ‘vld1q_u16’: target specific option mismatch
 vld1q_u16 (const uint16_t * __a)
 ^~~~~~~~~
In file included from /home/pi/src/zlib-ng/arch/arm/adler32_neon.c:9:
/home/pi/src/zlib-ng/arch/arm/neon_intrins.h:33:27: note: called from here
                           vld1q_u16(a),
                           ^~~~~~~~~~~~
make[2]: *** [CMakeFiles/zlibstatic.dir/build.make:453: CMakeFiles/zlibstatic.dir/arch/arm/adler32_neon.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:175: CMakeFiles/zlibstatic.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

About this issue

  • Original URL
  • State: closed
  • Created 6 months ago
  • Comments: 16 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Yeah looking at the tests in the CMakeLists.txt and configure scripts, they only check whether or not the compiler can use getauxval(), not whether or not the compiler intrinsics will work with the given flags like we do on other platforms. This is probably a separate bug, though. Yours in particular involves dealing with aarch32 on gcc 8. Does a newer GCC compile just fine? I suspect on newer gccs -mfpu=neon is redundant.

Have you tried using ‘develop’ branch?

hmmm, do you have the Cmake output from the compilation (flags.txt or whatever it’s called)? That might tell us more. It’s also possible gcc 8, as old as it is, didn’t support this and the test pretended to work because it got optimized out (similar to: https://github.com/zlib-ng/zlib-ng/issues/1616)

It seems very probable that you’re enabling Neon when you have a CPU that doesn’t support it (such as the RPi 1). @ccawley2011 has been adding some support for the armv6 ABI to make things better for those ancient CPUs.

The “native” support tests ought to be ruling out these instructions with the inclusion of -mpcu or -march=native in the compilation flags. I’m a little surprised it isn’t. In any case, you aren’t really missing out on too much by not compiling with -march=native, the runtime detection of supported instructions should be dispatching to the best available version and I really don’t think armv6 has any special tricks it doesn’t know about from the base instruction set to apply to the scalar code.