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

Remove Dependencies to Allow the Zstd Binary to Dynamically Link to the Library #2977

Merged
merged 2 commits into from
Jan 7, 2022

Conversation

felixhandte
Copy link
Contributor

This PR avoids dependencies on symbols that are not exported in the dynamic library.

I believe this works. However, I'm not sure that (a) this is really a worthwhile goal and (b) that this is a good solution for that goal. Your feedback is welcome.

This PR resolves #2950.

xxHash symbols are present in `libzstd.so`, but they are local and therefore
unavailable outside the lib. There are two possible solutions to the problem.
We could make those symbols global, or we could remove the dependency.

This commit chooses the latter approach. I suppose this comes at the cost of
code size / build time. I'm open to comments on whether this is a good thing
to do, especially since this will apply even when we are statically linking
everything.
@Cyan4973
Copy link
Contributor

Cyan4973 commented Jan 6, 2022

I'm not sure if this is a worthwhile goal either,
but the PR you propose looks all fine to me.
That's very little changes.

@felixhandte felixhandte changed the title [RFC] Remove Dependencies to Allow the Zstd Binary to Dynamically Link to the Library Remove Dependencies to Allow the Zstd Binary to Dynamically Link to the Library Jan 7, 2022
@felixhandte felixhandte merged commit 844c53e into facebook:dev Jan 7, 2022
@eli-schwartz
Copy link
Contributor

Sorry, I didn't notice this PR before (GitHub doesn't email you when someone links a PR that may close your subscribed ticket).

The general topic of dynamic linking I raised in #2976 and I also suggested a potential solution -- which does however require somewhat more long-term consideration and possible source code restructuring, but shouldn't have an effect on code size or build time.

As far as fixing the meson setup goes, the program was already linking to both the shared library and directly to the xxhash built .o file. The unused include fix was probably enough to get that working.

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

Successfully merging this pull request may close these issues.

Building with -O0 causes programs/zstd to fail to link
5 participants