madler / zlib

A massively spiffy yet delicately unobtrusive compression library.
http://zlib.net/
Other
5.58k stars 2.43k forks source link

error: version script assignment of 'local' to symbol 'gz_intmax' failed: symbol not defined #856

Closed AbduSharif closed 7 months ago

AbduSharif commented 1 year ago

With NDK 26-rc1, Zlib fails to compile for this:

ld.lld: error: version script assignment of 'local' to symbol 'gz_intmax' failed: symbol not defined

Reason was most likely was: https://reviews.llvm.org/D135402

That means, the error (for now) could be ignored with passing this:

 -Wl,--undefined-version
davidgraeff commented 12 months ago

A fix for me was to edit the https://github.com/madler/zlib/blob/develop/zlib.map file and remove gz_intmax in line 18

ZLIB_1.2.0 {
  global:
    compressBound;
    deflateBound;
    inflateBack;
    inflateBackEnd;
    inflateBackInit_;
    inflateCopy;
  local:
    deflate_copyright;
    inflate_copyright;
    inflate_fast;
    inflate_table;
    zcalloc;
    zcfree;
    z_errmsg;
    gz_error;
-    gz_intmax;
    _*;
};
emmenlau commented 11 months ago

Same issue when building latest zlib with LLVM clang 17.0.2 on Ubuntu 22.04 x86_64. The exact error from clang is:

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)              
emmenlau commented 11 months ago

The workaround suggested in the upstream issue is to add -Wl,--undefined-version to the linker flags. I have added this to LDFLAGS before calling cmake and the build now works.

I think the problem here with zlib is that the symbol gz_intmax should be conditionally enabled. It depends on the definition of INT_MAX. But the map-file unconditionally asks the linker to provide it, which seems wrong. However I'm not sure what a better solution would be...

speedym commented 11 months ago

Note that I have, a few days ago, posted a proposal for a proper fix for this issue.

Neustradamus commented 10 months ago

@madler: Can you look this ticket?

Neustradamus commented 7 months ago

@madler: Can you look this ticket?

madler commented 7 months ago

gz_intmax() is now always there.

Neustradamus commented 7 months ago

Merged commit: