I was compiling an older mysql-client against an old openssl 1.0.2u on Ubuntu 22.04 aarch64, and I was seeing linking errors:

/usr/bin/ld: /opt/openssl-1.0.2u/lib/libcrypto.a(sha1-armv8.o): relocation R_AARCH64_PREL64 against symbol `OPENSSL_armcap_P' which may bind externally can not be used when making a shared object; recompile with -fPIC
/opt/openssl-1.0.2u/lib/libcrypto.a(sha1-armv8.o): in function `sha1_block_armv8':
(.text+0x1240): dangerous relocation: unsupported relocation
/usr/bin/ld: /opt/openssl-1.0.2u/lib/libcrypto.a(sha256-armv8.o): relocation R_AARCH64_PREL64 against symbol `OPENSSL_armcap_P' which may bind externally can not be used when making a shared object; recompile with -fPIC
/opt/openssl-1.0.2u/lib/libcrypto.a(sha256-armv8.o): in function `sha256_block_data_order':
(.text+0xf48): dangerous relocation: unsupported relocation
/usr/bin/ld: /opt/openssl-1.0.2u/lib/libcrypto.a(sha512-armv8.o): relocation R_AARCH64_PREL64 against symbol `OPENSSL_armcap_P' which may bind externally can not be used when making a shared object; recompile with -fPIC
/opt/openssl-1.0.2u/lib/libcrypto.a(sha512-armv8.o): in function `sha512_block_data_order':
(.text+0x10c8): dangerous relocation: unsupported relocation
collect2: error: ld returned 1 exit status
make[2]: *** [libmysql/CMakeFiles/libmysql.dir/build.make:112: libmysql/libmysqlclient.so.18.1.0] Error 1
make[1]: *** [CMakeFiles/Makefile2:1073: libmysql/CMakeFiles/libmysql.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

I knew that I’d definitely compiled openssl with -fPIC, because I’d used ./config -fPIC shared.

A little googling turned up this issue. The patch on that issue didn’t work for me, because it’s against a different openssl version, but it looked like I could crib from it.

I made this patch:

which when applied with patch -p1 applied cleanly and fixed those linking errors. Thanks for the original patch Tamás!