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

Shared library is disabled when undefined versions produce errors #960

Open
alyssais opened this issue Apr 2, 2024 · 1 comment
Open

Comments

@alyssais
Copy link

alyssais commented Apr 2, 2024

To check whether shared libraries are supported, the configure script tries to compile a test file. On Linux, GNU, Solaris, and BSD, this test file will be compiled with the version script. On some linkers, this produces an error, because that test file does not produce the symbols expected by the version script:

Checking for shared library support...
=== ztest41.c ===
extern int getchar();
int hello() {return getchar();}
===
x86_64-unknown-freebsd13-clang -c -O3 -fPIC ztest41.c
x86_64-unknown-freebsd13-clang -shared -Wl,-soname,libz.so.1,--version-script,zlib.map -O3 -fPIC -o ztest41.so ztest41.o
x86_64-unknown-freebsd13-ld: error: version script assignment of 'ZLIB_1.2.0' to symbol 'compressBound' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: version script assignment of 'ZLIB_1.2.0' to symbol 'deflateBound' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: version script assignment of 'ZLIB_1.2.0' to symbol 'inflateBack' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: version script assignment of 'ZLIB_1.2.0' to symbol 'inflateBackEnd' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: version script assignment of 'ZLIB_1.2.0' to symbol 'inflateBackInit_' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: version script assignment of 'ZLIB_1.2.0' to symbol 'inflateCopy' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: version script assignment of 'local' to symbol 'deflate_copyright' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: version script assignment of 'local' to symbol 'inflate_copyright' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: version script assignment of 'local' to symbol 'inflate_fast' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: version script assignment of 'local' to symbol 'inflate_table' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: version script assignment of 'local' to symbol 'zcalloc' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: version script assignment of 'local' to symbol 'zcfree' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: version script assignment of 'local' to symbol 'z_errmsg' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: version script assignment of 'local' to symbol 'gz_error' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: version script assignment of 'local' to symbol 'gz_intmax' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: version script assignment of 'ZLIB_1.2.0.2' to symbol 'gzclearerr' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: version script assignment of 'ZLIB_1.2.0.2' to symbol 'gzungetc' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: version script assignment of 'ZLIB_1.2.0.2' to symbol 'zlibCompileFlags' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: version script assignment of 'ZLIB_1.2.0.8' to symbol 'deflatePrime' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: version script assignment of 'ZLIB_1.2.2' to symbol 'adler32_combine' failed: symbol not defined
x86_64-unknown-freebsd13-ld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
(exit code 1)
No shared library support; try without defining CC and CFLAGS

On other linkers, the undefined versions are just warnings, so compilation succeeds and the static library is built.

An easy way to reproduce this error if you don't have a linker that defaults to an error here is to run configure with CC='clang -Wl,--no-undefined-version.

To fix this, the test file probably needs to be compiled without the version script, or with -Wl,--undefined-version or -Wl,--noinhibit-exec.

@shambodeva
Copy link

Seeing the same issue when cross-compiling with clang 17.x. Below is snippet from configure.log.

Can you update the test or version script to resolve this issue?

2024-04-17T13:41:06.5355664Z /home/runner/work/custom/maverick/toolchain_llvm17/bin/arm-linux-gnueabihf-clang -c -fPIC ztest2881.c
2024-04-17T13:41:06.5359084Z /home/runner/work/custom/maverick/toolchain_llvm17/bin/arm-linux-gnueabihf-clang -shared -Wl,-soname,libz.so.1,--version-script,zlib.map -fPIC -o ztest2881.so ztest2881.o
2024-04-17T13:41:06.5362681Z arm-linux-gnueabihf-ld: error: version script assignment of 'ZLIB_1.2.0' to symbol 'compressBound' failed: symbol not defined
2024-04-17T13:41:06.5364864Z arm-linux-gnueabihf-ld: error: version script assignment of 'ZLIB_1.2.0' to symbol 'deflateBound' failed: symbol not defined
2024-04-17T13:41:06.5366480Z arm-linux-gnueabihf-ld: error: version script assignment of 'ZLIB_1.2.0' to symbol 'inflateBack' failed: symbol not defined
2024-04-17T13:41:06.5367884Z arm-linux-gnueabihf-ld: error: version script assignment of 'ZLIB_1.2.0' to symbol 'inflateBackEnd' failed: symbol not defined
2024-04-17T13:41:06.5370567Z arm-linux-gnueabihf-ld: error: version script assignment of 'ZLIB_1.2.0' to symbol 'inflateBackInit_' failed: symbol not defined
2024-04-17T13:41:06.5372859Z arm-linux-gnueabihf-ld: error: version script assignment of 'ZLIB_1.2.0' to symbol 'inflateCopy' failed: symbol not defined
2024-04-17T13:41:06.5375491Z arm-linux-gnueabihf-ld: error: version script assignment of 'local' to symbol 'deflate_copyright' failed: symbol not defined
2024-04-17T13:41:06.5378027Z arm-linux-gnueabihf-ld: error: version script assignment of 'local' to symbol 'inflate_copyright' failed: symbol not defined
2024-04-17T13:41:06.5380691Z arm-linux-gnueabihf-ld: error: version script assignment of 'local' to symbol 'inflate_fast' failed: symbol not defined
2024-04-17T13:41:06.5383044Z arm-linux-gnueabihf-ld: error: version script assignment of 'local' to symbol 'inflate_table' failed: symbol not defined
2024-04-17T13:41:06.5385452Z arm-linux-gnueabihf-ld: error: version script assignment of 'local' to symbol 'zcalloc' failed: symbol not defined
2024-04-17T13:41:06.5387782Z arm-linux-gnueabihf-ld: error: version script assignment of 'local' to symbol 'zcfree' failed: symbol not defined
2024-04-17T13:41:06.5390170Z arm-linux-gnueabihf-ld: error: version script assignment of 'local' to symbol 'z_errmsg' failed: symbol not defined
2024-04-17T13:41:06.5392778Z arm-linux-gnueabihf-ld: error: version script assignment of 'local' to symbol 'gz_error' failed: symbol not defined
2024-04-17T13:41:06.5395280Z arm-linux-gnueabihf-ld: error: version script assignment of 'local' to symbol 'gz_intmax' failed: symbol not defined
2024-04-17T13:41:06.5397684Z arm-linux-gnueabihf-ld: error: version script assignment of 'ZLIB_1.2.0.2' to symbol 'gzclearerr' failed: symbol not defined
2024-04-17T13:41:06.5400903Z arm-linux-gnueabihf-ld: error: version script assignment of 'ZLIB_1.2.0.2' to symbol 'gzungetc' failed: symbol not defined
2024-04-17T13:41:06.5403401Z arm-linux-gnueabihf-ld: error: version script assignment of 'ZLIB_1.2.0.2' to symbol 'zlibCompileFlags' failed: symbol not defined
2024-04-17T13:41:06.5406056Z arm-linux-gnueabihf-ld: error: version script assignment of 'ZLIB_1.2.0.8' to symbol 'deflatePrime' failed: symbol not defined
2024-04-17T13:41:06.5408626Z arm-linux-gnueabihf-ld: error: version script assignment of 'ZLIB_1.2.2' to symbol 'adler32_combine' failed: symbol not defined
2024-04-17T13:41:06.5411106Z arm-linux-gnueabihf-ld: error: too many errors emitted, stopping now (use --error-limit=0 to see all errors)
2024-04-17T13:41:06.5412982Z clang: error: linker command failed with exit code 1 (use -v to see invocation)
2024-04-17T13:41:06.5414269Z (exit code 1)
2024-04-17T13:41:06.5415380Z No shared library support; try without defining CC and CFLAGS
2024-04-17T13:41:06.5417805Z Building static library libz.a version 1.3.1 with /home/runner/work/custom/maverick/toolchain_llvm17/bin/arm-linux-gnueabihf-clang.

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

No branches or pull requests

2 participants