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

[lib] Fix libzstd.pc for lib-mt builds #2659

Merged
merged 1 commit into from Dec 7, 2021

Conversation

ericonr
Copy link
Contributor

@ericonr ericonr commented May 16, 2021

Add the libzstd.pc target to the lib target in lib/Makefile, which makes
it inherit LDFLAGS_DYNLIB from the lib-mt target. This allows us to add
a Libs.private field to libzstd.pc which gets conditionally populated
with '-pthread'.

The 1.5.0 release notes mention that the static library isn't
multi-threaded by default, due to concern for people building static
binaries with libzstd:

Now the dynamic library supports multi-threaded compression by
default. Note that this property is not extended to the static
library because doing so would have impacted the build script of
existing client applications (requiring them to add -pthread to their
recipe), thus potentially breaking their build.

To get closer to being able to enable multi-threading for all library
builds by default, this commit makes it so that any libzstd consumer
using pkg-config gets the correct flags.

@facebook-github-bot
Copy link

Hi @ericonr!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@ericonr
Copy link
Contributor Author

ericonr commented May 20, 2021

It would seem something about this broke the mingw builds:

Thread model: posix
gcc version 6.3.0 (x86_64-posix-seh-rev1, Built by MinGW-W64 project) 
make[1]: Entering directory '/c/projects/zstd-p0yf0/lib'
make[1]: *** No rule to make target 'libzstd.pc', needed by 'lib'.  Stop.
make[1]: *** Waiting for unfinished jobs....

I will try to figure out what it was, would appreciate guidance.

@ericonr
Copy link
Contributor Author

ericonr commented Jun 19, 2021

Ok, should be fixed now.

Add the libzstd.pc target to the lib target in lib/Makefile, which makes
it inherit LDFLAGS_DYNLIB from the lib-mt target. This allows us to add
a Libs.private field to libzstd.pc which gets conditionally populated
with '-pthread'.

The 1.5.0 release notes mention that the static library isn't
multi-threaded by default, due to concern for people building static
binaries with libzstd:

   Now the dynamic library supports multi-threaded compression by
   default.  Note that this property is not extended to the static
   library because doing so would have impacted the build script of
   existing client applications (requiring them to add -pthread to their
   recipe), thus potentially breaking their build.

To get closer to being able to enable multi-threading for all library
builds by default, this commit makes it so that any libzstd consumer
using pkg-config gets the correct flags.

We also fix the indentation of the rule for libzstd.pc and move it
outside the if/endif block for install rules (which uses a list of OSs
where the rules were validated), so the rule is available for all users
of the 'lib*' targets.
@ericonr
Copy link
Contributor Author

ericonr commented Jun 21, 2021

Travis on aarch64 fails due to Travis: https://travis-ci.com/github/facebook/zstd/jobs/516610662

Automatic restarts limited: Please try restarting this job later or contact support@travis-ci.com.

@terrelln terrelln added the release-blocking Must be done by the release label Dec 7, 2021
@felixhandte
Copy link
Contributor

@ericonr,

Thanks for this PR! Sorry it took so long for us to get to it. It looks like you're fundamentally doing three things:

  1. Adding a field to the generated pkg-config file.
  2. Building libzstd.pc whenever the library is built.
  3. Moving the libzstd.pc definition out of the unix-only section.

The first looks correct and important.

The last two are tricky since people may build zstd on platforms where a .pc file is meaningless and they may not even have sed installed. In those situations, we don't want this dependency.

I'm going to merge this PR into a working branch and make a few fix-ups. I'll tag you when I put it up and if you can make sure it's still addressing your needs, that would be great.

@felixhandte felixhandte changed the base branch from dev to pkg-config-fix December 7, 2021 19:18
@felixhandte felixhandte merged commit 9118ee0 into facebook:pkg-config-fix Dec 7, 2021
felixhandte added a commit to felixhandte/zstd that referenced this pull request Dec 7, 2021
felixhandte added a commit to felixhandte/zstd that referenced this pull request Dec 8, 2021
felixhandte added a commit that referenced this pull request Dec 8, 2021
Fix Up #2659; Build libzstd.pc Whenever Building the Lib on Unix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed release-blocking Must be done by the release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants