Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ld.lld linker error on gz_intmax like symbol not defined #75056

Closed
lonewolf73 opened this issue Dec 11, 2023 · 3 comments
Closed

ld.lld linker error on gz_intmax like symbol not defined #75056

lonewolf73 opened this issue Dec 11, 2023 · 3 comments
Labels
lld:ELF question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

Comments

@lonewolf73
Copy link

Hello everyone!

I have ubuntu 22.04 LTS with :

  1. Android SDK --> release 8.1.0 (AndroidVersion.ApiLevel=27);
  2. Android NDK --> release 26.1.10909125
  3. sources of vlc library

trying to compile vlc library returns error on :

[1/15] Linking C shared library libzlib.so.1.2.13
FAILED: libzlib.so.1.2.13
: && /usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android27-clang -fPIC -g -O2 -fPIC -fdata-sections -ffunction-sections -funwind-tables  -fstack-protector-strong -no-canonical-prefixes -DNDEBUG  -I/home/dev/projects/libvlcjni/buildsystem/vlc/contrib/aarch64-linux-android/include -g -O2 -O2 -g -DNDEBUG  -L/home/dev/projects/libvlcjni/buildsystem/vlc/contrib/aarch64-linux-android/lib  -Wl,--version-script,"/home/dev/projects/libvlcjni/buildsystem/vlc/contrib/contrib-android-aarch64-linux-android/zlib/zlib.map" -shared -Wl,-soname,libzlib.so.1 -o libzlib.so.1.2.13 CMakeFiles/zlib.dir/adler32.o CMakeFiles/zlib.dir/compress.o CMakeFiles/zlib.dir/crc32.o CMakeFiles/zlib.dir/deflate.o CMakeFiles/zlib.dir/gzclose.o CMakeFiles/zlib.dir/gzlib.o CMakeFiles/zlib.dir/gzread.o CMakeFiles/zlib.dir/gzwrite.o CMakeFiles/zlib.dir/inflate.o CMakeFiles/zlib.dir/infback.o CMakeFiles/zlib.dir/inftrees.o CMakeFiles/zlib.dir/inffast.o CMakeFiles/zlib.dir/trees.o CMakeFiles/zlib.dir/uncompr.o CMakeFiles/zlib.dir/zutil.o   && :
ld.lld: error: version script assignment of 'local' to symbol 'gz_intmax' failed: symbol not defined
clang: error: linker command failed with exit code 1 (use -v to see invocation)

where if I do a grep on gz_intmax I can see it's present in :

vlc/contrib/contrib-android-aarch64-linux-android/zlib/zlib.map:    gz_intmax;
vlc/contrib/contrib-android-aarch64-linux-android/zlib/gzguts.h:unsigned ZLIB_INTERNAL gz_intmax OF((void));
vlc/contrib/contrib-android-aarch64-linux-android/zlib/gzguts.h:#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
vlc/contrib/contrib-android-aarch64-linux-android/zlib/zconf.h.in:#    define gz_intmax             z_gz_intmax
vlc/contrib/contrib-android-aarch64-linux-android/zlib/vlc_build/zconf.h:#    define gz_intmax             z_gz_intmax
vlc/contrib/contrib-android-aarch64-linux-android/zlib/gzlib.c:unsigned ZLIB_INTERNAL gz_intmax()
vlc/contrib/contrib-android-aarch64-linux-android/zlib/zconf.h.included:#    define gz_intmax             z_gz_intmax
vlc/contrib/contrib-android-aarch64-linux-android/zlib/zconf.h.cmakein:#    define gz_intmax             z_gz_intmax
vlc/contrib/contrib-android-aarch64-linux-android/freetype/src/gzip/ftzconf.h:#    define gz_intmax             z_gz_intmax
vlc/contrib/contrib-android-aarch64-linux-android/freetype/src/gzip/gzguts.h:unsigned ZLIB_INTERNAL gz_intmax OF((void));
vlc/contrib/contrib-android-aarch64-linux-android/freetype/src/gzip/gzguts.h:#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())

so as like as I followed the discussion inside comment on LLD --no-undefined-version , is that error I am getting related to --no-undefined-version ? If yes, where I could add --undefined-version to revert to old behavior?

Thanks!
Cheers!

@github-actions github-actions bot added the lld label Dec 11, 2023
@EugeneZelenko EugeneZelenko added lld:ELF and removed lld labels Dec 11, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Dec 11, 2023

@llvm/issue-subscribers-lld-elf

Author: None (lonewolf73)

Hello everyone!

I have ubuntu 22.04 LTS with :

  1. Android SDK --> release 8.1.0 (AndroidVersion.ApiLevel=27);
  2. Android NDK --> release 26.1.10909125
  3. sources of vlc library

trying to compile vlc library returns error on :

[1/15] Linking C shared library libzlib.so.1.2.13
FAILED: libzlib.so.1.2.13
: && /usr/lib/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android27-clang -fPIC -g -O2 -fPIC -fdata-sections -ffunction-sections -funwind-tables  -fstack-protector-strong -no-canonical-prefixes -DNDEBUG  -I/home/dev/projects/libvlcjni/buildsystem/vlc/contrib/aarch64-linux-android/include -g -O2 -O2 -g -DNDEBUG  -L/home/dev/projects/libvlcjni/buildsystem/vlc/contrib/aarch64-linux-android/lib  -Wl,--version-script,"/home/dev/projects/libvlcjni/buildsystem/vlc/contrib/contrib-android-aarch64-linux-android/zlib/zlib.map" -shared -Wl,-soname,libzlib.so.1 -o libzlib.so.1.2.13 CMakeFiles/zlib.dir/adler32.o CMakeFiles/zlib.dir/compress.o CMakeFiles/zlib.dir/crc32.o CMakeFiles/zlib.dir/deflate.o CMakeFiles/zlib.dir/gzclose.o CMakeFiles/zlib.dir/gzlib.o CMakeFiles/zlib.dir/gzread.o CMakeFiles/zlib.dir/gzwrite.o CMakeFiles/zlib.dir/inflate.o CMakeFiles/zlib.dir/infback.o CMakeFiles/zlib.dir/inftrees.o CMakeFiles/zlib.dir/inffast.o CMakeFiles/zlib.dir/trees.o CMakeFiles/zlib.dir/uncompr.o CMakeFiles/zlib.dir/zutil.o   && :
ld.lld: error: version script assignment of 'local' to symbol 'gz_intmax' failed: symbol not defined
clang: error: linker command failed with exit code 1 (use -v to see invocation)

where if I do a grep on gz_intmax I can see it's present in :

vlc/contrib/contrib-android-aarch64-linux-android/zlib/zlib.map:    gz_intmax;
vlc/contrib/contrib-android-aarch64-linux-android/zlib/gzguts.h:unsigned ZLIB_INTERNAL gz_intmax OF((void));
vlc/contrib/contrib-android-aarch64-linux-android/zlib/gzguts.h:#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
vlc/contrib/contrib-android-aarch64-linux-android/zlib/zconf.h.in:#    define gz_intmax             z_gz_intmax
vlc/contrib/contrib-android-aarch64-linux-android/zlib/vlc_build/zconf.h:#    define gz_intmax             z_gz_intmax
vlc/contrib/contrib-android-aarch64-linux-android/zlib/gzlib.c:unsigned ZLIB_INTERNAL gz_intmax()
vlc/contrib/contrib-android-aarch64-linux-android/zlib/zconf.h.included:#    define gz_intmax             z_gz_intmax
vlc/contrib/contrib-android-aarch64-linux-android/zlib/zconf.h.cmakein:#    define gz_intmax             z_gz_intmax
vlc/contrib/contrib-android-aarch64-linux-android/freetype/src/gzip/ftzconf.h:#    define gz_intmax             z_gz_intmax
vlc/contrib/contrib-android-aarch64-linux-android/freetype/src/gzip/gzguts.h:unsigned ZLIB_INTERNAL gz_intmax OF((void));
vlc/contrib/contrib-android-aarch64-linux-android/freetype/src/gzip/gzguts.h:#  define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())

so as like as I followed the discussion inside comment on LLD --no-undefined-version , is that error I am getting related to --no-undefined-version ? If yes, where I could add --undefined-version to revert to old behavior?

Thanks!
Cheers!

@DimitryAndric
Copy link
Collaborator

It is likely that the actual existence of gz_intmax in any of your object files is dependent on configuration, compile flags, environment, platform, or something else. If the symbol does not exist, lld complains about it by default. If you don't care about those missing symbols, add -Wl,--undefined-version to your linker flags. If you do care about those missing symbols, either implement them (exercise left for the reader), or delete them from the linker version script.

@MaskRay MaskRay closed this as not planned Won't fix, can't repro, duplicate, stale Dec 11, 2023
@EugeneZelenko EugeneZelenko added the question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! label Dec 11, 2023
@mtl1979
Copy link

mtl1979 commented Jun 13, 2024

gz_intmax is not needed or defined in zlib for modern compilers. It has been very common practice to use just one symbol map or version script for all environments, as using separate for each toolchain/configuration combination would exponentially increase the effort to keep them all updated and synchronized.

There is chicken and egg dilemma when checking the sanity of toolchain and creating customized symbol map or version script as it would require testing the toolchain (specifically linker) twice, once with dummy version, and then with the real one.

As VLC already patches the zlib sources, it would be best solution to just strip the symbol definition from the version script.

Biggest problem with zlib since early days has been that it's supposed to support very old compilers and toolchains, so it really does very little effort to support all the intricacies of modern toolchains (especially for 64-bit targets). That is also why few years ago forks were started that focus on supporting modern toolchains instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lld:ELF question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Projects
None yet
Development

No branches or pull requests

6 participants