Skip to content

[BUG] libz.a for armeabi-v7a is missing symbols #1391

@topjohnwu

Description

@topjohnwu

Using NDK r22-beta1 (22.0.6917172-beta1) on macOS with ndk-build to build static binaries.
When statically linking libz.a in 32 bit ARM code, the linker will complain with the following error:

ld: error: undefined symbol: arm_cpu_enable_crc32
>>> referenced by deflate.c:0 (external/zlib/deflate.c:0)
>>>               deflate.o:(deflateInit2_) in archive /Volumes/Developer/android/sdk/ndk/magisk/toolchains/llvm/prebuilt/darwin-x86_64/bin/../sysroot/usr/lib/arm-linux-androideabi/21/libz.a

ld: error: undefined symbol: x86_cpu_enable_simd
>>> referenced by deflate.c:0 (external/zlib/deflate.c:0)
>>>               deflate.o:(deflateInit2_) in archive /Volumes/Developer/android/sdk/ndk/magisk/toolchains/llvm/prebuilt/darwin-x86_64/bin/../sysroot/usr/lib/arm-linux-androideabi/21/libz.a
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

Using readelf to print out symbols of all libz.a for arm 32, it seems all libz.a archives are missing cpu_features.o, causing the following symbols to be undefined:

int arm_cpu_enable_crc32;
int arm_cpu_enable_pmull;
int x86_cpu_enable_sse2;
int x86_cpu_enable_ssse3;
int x86_cpu_enable_simd;

This issue does not happen on any other arch.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions