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

Fix building with z_ prefix #936

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

DenizThatMenace
Copy link

@DenizThatMenace DenizThatMenace commented Feb 13, 2024

This PR fixes a problem with the version-script (zlib.map) when also building with enabled z_ prefix for the function names.

Without the changes from this PR the version-script did not properly assign version numbers to the function symbols in zlib.so (using GCC or Clang) if the function symbols are prefixed with z_!


Background

Most linkers silently ignored this error and just generated a zlib.so without any version numbers attached. Starting with lld 17 (or was it 16?), however, linking even fails with the following errors:

ld.lld-17: error: version script assignment of 'ZLIB_1.2.0' to symbol 'compressBound' failed: symbol not defined
ld.lld-17: error: version script assignment of 'ZLIB_1.2.0' to symbol 'deflateBound' failed: symbol not defined
ld.lld-17: error: version script assignment of 'ZLIB_1.2.0' to symbol 'inflateBack' failed: symbol not defined
ld.lld-17: error: version script assignment of 'ZLIB_1.2.0' to symbol 'inflateBackEnd' failed: symbol not defined
ld.lld-17: error: version script assignment of 'ZLIB_1.2.0' to symbol 'inflateBackInit_' failed: symbol not defined
ld.lld-17: error: version script assignment of 'ZLIB_1.2.0' to symbol 'inflateCopy' failed: symbol not defined
ld.lld-17: error: version script assignment of 'local' to symbol 'deflate_copyright' failed: symbol not defined
ld.lld-17: error: version script assignment of 'local' to symbol 'inflate_copyright' failed: symbol not defined
ld.lld-17: error: version script assignment of 'local' to symbol 'inflate_fast' failed: symbol not defined
ld.lld-17: error: version script assignment of 'local' to symbol 'inflate_table' failed: symbol not defined
ld.lld-17: error: version script assignment of 'local' to symbol 'zcalloc' failed: symbol not defined
ld.lld-17: error: version script assignment of 'local' to symbol 'zcfree' failed: symbol not defined
ld.lld-17: error: version script assignment of 'local' to symbol 'gz_error' failed: symbol not defined
ld.lld-17: error: version script assignment of 'local' to symbol 'gz_intmax' failed: symbol not defined
ld.lld-17: error: version script assignment of 'ZLIB_1.2.0.2' to symbol 'gzclearerr' failed: symbol not defined
ld.lld-17: error: version script assignment of 'ZLIB_1.2.0.2' to symbol 'gzungetc' failed: symbol not defined
ld.lld-17: error: version script assignment of 'ZLIB_1.2.0.2' to symbol 'zlibCompileFlags' failed: symbol not defined
ld.lld-17: error: version script assignment of 'ZLIB_1.2.0.8' to symbol 'deflatePrime' failed: symbol not defined
ld.lld-17: error: version script assignment of 'ZLIB_1.2.2' to symbol 'adler32_combine' failed: symbol not defined
ld.lld-17: error: version script assignment of 'ZLIB_1.2.2' to symbol 'crc32_combine' failed: symbol not defined
ld.lld-17: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)

The reason is that zlib.map did not care whether the z_ prefix is used or not.

@DenizThatMenace DenizThatMenace changed the title Fix building with zprefix Fix building with z_ prefix Feb 13, 2024
@DenizThatMenace DenizThatMenace force-pushed the fix-building-with-zprefix branch 2 times, most recently from 535d235 to 05a405e Compare May 8, 2024 17:13
@Neustradamus
Copy link

@madler: Have you seen this PR?

This also fixes out-of-source builds when the `-zprefix` option was
given to the configure script.
@DenizThatMenace
Copy link
Author

@madler, do you mind having a look at this PR?

Merging this would fix versioned symbols in the built shared object (zlib.so).

Without the change from this PR using the version-script (zlib.map) has no effect when the z_ prefix is used on function names! (Even worse, with newer lld linkers it will no longer build.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants