zlib-ng: mingw64 build failed: relocation truncated to fit: R_X86_64_32S against undefined symbol `functable@tpoff'

When I upgrade to 2.1.0 Beta1, it build failed since: relocation truncated to fit: R_X86_64_32S against undefined symbol `functable@tpoff’

Full log can be found in: https://github.com/abcfy2/aria2-static-build/actions/runs/4836084657/jobs/8644381682

x86_64-w64-mingw32-gcc -O2  -std=c11 -Wall -DNDEBUG -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE=1 -Wno-pedantic-ms-format -D_LARGEFILE64_SOURCE=1 -DZLIB_COMPAT -DWITH_GZFILEOP -DHAVE_ATTRIBUTE_ALIGNED -DHAVE_THREAD_LOCAL -DHAVE_BUILTIN_CTZ -DHAVE_BUILTIN_CTZLL -DX86_FEATURES -DX86_AVX2 -DX86_AVX512 -DX86_MASK_INTRIN -DX86_AVX512VNNI -DX86_SSE42 -DX86_SSE42_CRC_INTRIN -DX86_SSE2 -DX86_SSSE3 -DX86_PCLMULQDQ_CRC -DX86_VPCLMULQDQ_CRC -I/usr/src/zlib-ng-2.1.0-beta1 -c -o makefixed.o /usr/src/zlib-ng-2.1.0-beta1/tools/makefixed.c
x86_64-w64-mingw32-ar rcs libz.a adler32.o adler32_fold.o chunkset.o compare256.o compress.o cpu_features.o crc32_braid.o crc32_braid_comb.o crc32_fold.o deflate.o deflate_fast.o deflate_huff.o deflate_medium.o deflate_quick.o deflate_rle.o deflate_slow.o deflate_stored.o functable.o infback.o inflate.o inftrees.o insert_string.o insert_string_roll.o slide_hash.o trees.o uncompr.o zutil.o x86_features.o slide_hash_avx2.o chunkset_avx2.o compare256_avx2.o adler32_avx2.o adler32_avx512.o adler32_avx512_vnni.o adler32_sse42.o insert_string_sse42.o chunkset_sse2.o compare256_sse2.o slide_hash_sse2.o adler32_ssse3.o chunkset_ssse3.o crc32_pclmulqdq.o crc32_vpclmulqdq.o gzlib.o gzread.o gzwrite.o
x86_64-w64-mingw32-gcc -O2  -std=c11 -Wall -DNDEBUG -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE=1 -Wno-pedantic-ms-format -D_LARGEFILE64_SOURCE=1 -DZLIB_COMPAT -DWITH_GZFILEOP -DHAVE_ATTRIBUTE_ALIGNED -DHAVE_THREAD_LOCAL -DHAVE_BUILTIN_CTZ -DHAVE_BUILTIN_CTZLL -DX86_FEATURES -DX86_AVX2 -DX86_AVX512 -DX86_MASK_INTRIN -DX86_AVX512VNNI -DX86_SSE42 -DX86_SSE42_CRC_INTRIN -DX86_SSE2 -DX86_SSSE3 -DX86_PCLMULQDQ_CRC -DX86_VPCLMULQDQ_CRC -I/usr/src/zlib-ng-2.1.0-beta1 -c -o maketrees.o /usr/src/zlib-ng-2.1.0-beta1/tools/maketrees.c
x86_64-w64-mingw32-gcc -O2  -std=c11 -Wall -DNDEBUG -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE=1 -Wno-pedantic-ms-format -D_LARGEFILE64_SOURCE=1 -DZLIB_COMPAT -DWITH_GZFILEOP -DHAVE_ATTRIBUTE_ALIGNED -DHAVE_THREAD_LOCAL -DHAVE_BUILTIN_CTZ -DHAVE_BUILTIN_CTZLL -DX86_FEATURES -DX86_AVX2 -DX86_AVX512 -DX86_MASK_INTRIN -DX86_AVX512VNNI -DX86_SSE42 -DX86_SSE42_CRC_INTRIN -DX86_SSE2 -DX86_SSSE3 -DX86_PCLMULQDQ_CRC -DX86_VPCLMULQDQ_CRC -I/usr/src/zlib-ng-2.1.0-beta1 -c -o makecrct.o /usr/src/zlib-ng-2.1.0-beta1/tools/makecrct.c
x86_64-w64-mingw32-gcc -O2  -std=c11 -Wall -DNDEBUG -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE=1 -Wno-pedantic-ms-format -D_LARGEFILE64_SOURCE=1 -DZLIB_COMPAT -DWITH_GZFILEOP -DHAVE_ATTRIBUTE_ALIGNED -DHAVE_THREAD_LOCAL -DHAVE_BUILTIN_CTZ -DHAVE_BUILTIN_CTZLL -DX86_FEATURES -DX86_AVX2 -DX86_AVX512 -DX86_MASK_INTRIN -DX86_AVX512VNNI -DX86_SSE42 -DX86_SSE42_CRC_INTRIN -DX86_SSE2 -DX86_SSSE3 -DX86_PCLMULQDQ_CRC -DX86_VPCLMULQDQ_CRC -L/cross_root/x86_64-w64-mingw32/lib64 -L/cross_root/x86_64-w64-mingw32/lib -s -static --static -o example.exe example.o  libz.a 
/cross_root/bin/../lib/gcc/x86_64-w64-mingw32/11.2.1/../../../../x86_64-w64-mingw32/bin/ld: libz.a(crc32_braid.o):crc32_braid.c:(.text+0x21): undefined reference to `functable@tpoff'
libz.a(crc32_braid.o):crc32_braid.c:(.text+0x21): relocation truncated to fit: R_X86_64_32S against undefined symbol `functable@tpoff'
/cross_root/bin/../lib/gcc/x86_64-w64-mingw32/11.2.1/../../../../x86_64-w64-mingw32/bin/ld: libz.a(crc32_braid.o):crc32_braid.c:(.text+0x44): undefined reference to `functable@tpoff'
libz.a(crc32_braid.o):crc32_braid.c:(.text+0x44): relocation truncated to fit: R_X86_64_32S against undefined symbol `functable@tpoff'
/cross_root/bin/../lib/gcc/x86_64-w64-mingw32/11.2.1/../../../../x86_64-w64-mingw32/bin/ld: libz.a(deflate.o):deflate.c:(.text+0x92): undefined reference to `functable@tpoff'
libz.a(deflate.o):deflate.c:(.text+0x92): relocation truncated to fit: R_X86_64_32S against undefined symbol `functable@tpoff'
/cross_root/bin/../lib/gcc/x86_64-w64-mingw32/11.2.1/../../../../x86_64-w64-mingw32/bin/ld: libz.a(deflate.o):deflate.c:(.text+0xa0): undefined reference to `functable@tpoff'
libz.a(deflate.o):deflate.c:(.text+0xa0): relocation truncated to fit: R_X86_64_32S against undefined symbol `functable@tpoff'
/cross_root/bin/../lib/gcc/x86_64-w64-mingw32/11.2.1/../../../../x86_64-w64-mingw32/bin/ld: libz.a(deflate.o):deflate.c:(.text+0xa7): undefined reference to `functable@tpoff'
libz.a(deflate.o):deflate.c:(.text+0xa7): relocation truncated to fit: R_X86_64_32S against undefined symbol `functable@tpoff'
/cross_root/bin/../lib/gcc/x86_64-w64-mingw32/11.2.1/../../../../x86_64-w64-mingw32/bin/ld: libz.a(deflate.o):deflate.c:(.text+0x354): more undefined references to `functable@tpoff' follow
libz.a(deflate.o):deflate.c:(.text+0x354): relocation truncated to fit: R_X86_64_32S against undefined symbol `functable@tpoff'
libz.a(deflate.o):deflate.c:(.text+0xaec): relocation truncated to fit: R_X86_64_32S against undefined symbol `functable@tpoff'
libz.a(deflate.o):deflate.c:(.text+0x1011): relocation truncated to fit: R_X86_64_32S against undefined symbol `functable@tpoff'
libz.a(deflate.o):deflate.c:(.text+0x10b2): relocation truncated to fit: R_X86_64_32S against undefined symbol `functable@tpoff'
libz.a(deflate.o):deflate.c:(.text+0x135d): relocation truncated to fit: R_X86_64_32S against undefined symbol `functable@tpoff'
libz.a(deflate.o):deflate.c:(.text+0x1ae4): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
make: *** [Makefile:257: example.exe] Error 1
make: *** Waiting for unfinished jobs....
Error: Process completed with exit code 2.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 21 (7 by maintainers)

Most upvoted comments

I have very very little experience with MinGW myself, but maybe this can help. Have you had a look at how we compile MinGW builds in our CI? https://github.com/zlib-ng/zlib-ng/blob/develop/.github/workflows/cmake.yml

Firstly we make use of the Cmake Toolchain file that sets up cmake to support the MinGW build correcly. cmake/toolchain-mingw-x86_64.cmake. It also uses wine to be able to actually run the cross-compiled binaries, so that needs to be installed.

We also specify some very specific package versions to ensure MinGW compilation succeeds, not sure whether this is necessary or the bugs have been resolved, but that might be something you could test next.