-
Notifications
You must be signed in to change notification settings - Fork 77
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
Add LIB_SYS_TRY_SHARED ENV var to try to link with shared library #206
base: main
Are you sure you want to change the base?
Add LIB_SYS_TRY_SHARED ENV var to try to link with shared library #206
Conversation
On cross-compilation libz-sys is always building static zlib library, except for Apple platforms. If target has an installed zlib shared library, this is problem, because: 1. the binary is increased, because we are including a static zlib as well 2. it may cause build issues if the pkg-config sets the linker arguments, like this: /tmp/rustc0ZqD0F/liblibz_sys-84983a050a121d20.rlib(inflate.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol '__stack_chk_guard' which may bind externally can not be used when making a shared object; recompile with -fPIC To workaround the issue, add a LIB_SYS_TRY_SHARED=1 ENV var (similarly to LIBZ_SYS_STATIC=1) to force the use of the shared library, recognized by the pkg-config. fixes rust-lang#201
612984b
to
2422982
Compare
Thanks a lot for tackling this. @jongiddy I feel that Thanks everyone for your help. |
Neither option is ideal. Using an environment variable means there is a hidden dependency that affects the build. When anyone needs support, it is an extra relevant piece of information they need to supply. And it is easy to not be aware whether it is set or not. Using a feature is painful when a transitive dependency is deeply nested, and Pragmatically, since there is already an environment variable for controlling static vs dynamic, I'd accept using an environment variable here. However, I suggest that the existing variable is reused, so that setting |
FWIW there is precedent in other
|
Thanks a lot for the summary, it's good to know the standards. This PR is at a stage where the question remains if |
This one is interesting. Matches the proposed one variable model with 0 meaning force dynamic and 1 meaning force static. |
On cross-compilation libz-sys is always building static zlib library, except for Apple platforms. If target has an installed zlib shared library, this is problem, because:
the binary is increased, because we are including a static zlib as well
it may cause build issues if the pkg-config sets the linker arguments, like this:
/tmp/rustc0ZqD0F/liblibz_sys-84983a050a121d20.rlib(inflate.o): relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol '__stack_chk_guard' which may bind externally can not be used when making a shared object; recompile with -fPIC
To workaround the issue, add a LIB_SYS_TRY_SHARED=1 ENV var (similarly to LIBZ_SYS_STATIC=1) to force the use of the shared library, recognized by the pkg-config.
fixes #201