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

zlib: Properly clean up static/shared distinction #66490

Merged
merged 1 commit into from
Aug 17, 2019

Conversation

nh2
Copy link
Contributor

@nh2 nh2 commented Aug 11, 2019

Includes #66486 (a simple comments change) which is for master, while this is for staging.

Motivation for this change

The previous logic was "grown" and has become pretty crazy to understand.

This improves what commit e999def (zlib: clean up static/shared distincion) described as "kind of a mess" and "confusing". And indeed it was confusing.

Now, the concept whether or not the .a file is moved to a split output is controlled by a clean variable.

The defaults remain unchanged.

The new approach also finally cleanly allows building statically but NOT using a split output, like all other autoconf-based projects in nixpkgs do (using the dontDisableStatic setting).
That is important for overlays that want to enable static libs for all packages in one go, without having to hand-patch idiosynchrasies like zlib had until now.

Until now, if you wanted the .a in the main output, the only way was to go via static=false, shared=true -- which made no sense, because you had to say static=false even though you want a static lib. That is fixed now.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
  • Tested all boolean combinations of shared, static and splitStaticOutput, checking that the files in the outputs are as expected.
Notify maintainers

cc @matthewbauer

@nh2
Copy link
Contributor Author

nh2 commented Aug 11, 2019

@GrahamcOfBorg build zlib

@nh2 nh2 force-pushed the zlib-static-shared-split-cleanup branch from b6e2ad4 to bd66819 Compare August 13, 2019 00:18
nh2 added a commit to nh2/static-haskell-nix that referenced this pull request Aug 13, 2019
@matthewbauer
Copy link
Member

The comments look good, but I'm a little bit surprised this needs to be a mass rebuild. I didn't think dontDisableStatic would be needed at all, --disable-static is not being passed to zlib.

splitStaticOutput definitely makes things clearer, although for the same reasons you describe in .pc, I was hoping we could eventually phase those out altogether. There are a few things that rely on this output existing though. pkg-config assumes that all of your libraries are in the same directory.

Changing the order seems reasonable though, at least to make things more clear. Not sure why it has that behavior, but my understanding was that zlib just always assumed you wanted static libraries.

@nh2
Copy link
Contributor Author

nh2 commented Aug 13, 2019

I didn't think dontDisableStatic would be needed at all, --disable-static is not being passed to zlib.

@matthewbauer Can you elaborate a bit on that? I thought that's passed in general, is there an exception for zlib somehwere that I could refer to?

for the same reasons you describe in .pc, I was hoping we could eventually phase those out altogether. There are a few things that rely on this output existing though

I wasn't sure if there's anyone who wants the zlib.static output to exist. Do you know if such someone exists?

I didn't find many uses of it; what's the best way to find them all?

Changing the order seems reasonable though, at least to make things more clear. Not sure why it has that behavior

As far as I can tell, zlib has a hand-writen ./configure script, not autoconf, and I suspect that the logic is that by default it builds both, that they added a --static option to build only static, and that later somebody added a --shared flag so that you can "turn it back on", and that the order is simply because their command line argument parsing code "grew that way". But I haven't checked.

@nh2 nh2 force-pushed the zlib-static-shared-split-cleanup branch from bd66819 to 5647474 Compare August 13, 2019 18:42
@nh2
Copy link
Contributor Author

nh2 commented Aug 13, 2019

I thought that's passed in general, is there an exception for zlib somehwere that I could refer to?

Ah I see:

# By default, disable static builds.
if [ -z "${dontDisableStatic:-}" ]; then
if [ -f "$configureScript" ] && grep -q enable-static "$configureScript"; then
configureFlags="--disable-static $configureFlags"
fi
fi

This greps for enable-static in the ./configure file, and zlib's handwritten one doesn't have that.

I'm a little bit surprised this needs to be a mass rebuild

I've pushed a fix that should avoid mass rebuilds, with extra commentary for rationale.

@nh2
Copy link
Contributor Author

nh2 commented Aug 13, 2019

@GrahamcOfBorg eval

@GrahamcOfBorg build zlib

nh2 added a commit to nh2/static-haskell-nix that referenced this pull request Aug 13, 2019
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux and removed 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild 10.rebuild-linux-stdenv This PR causes stdenv to rebuild 10.rebuild-darwin: 501+ 10.rebuild-darwin: 5001+ 10.rebuild-linux: 501+ 10.rebuild-linux: 5001+ labels Aug 13, 2019
This improves what commit

    e999def zlib: clean up static/shared distincion

described as "kind of a mess" and "confusing". And indeed it was confusing.

Now, the concept whether or not the .a file is moved to a split output
is controlled by a clean variable.

The defaults remain unchanged.

The new approach also finally cleanly allows building statically but NOT
using a split output, like all other autoconf-based projects in nixpkgs do
(using the `dontDisableStatic` setting).
That is important for overlays that want to enable static libs for all
packages in one go, without having to hand-patch idiosynchrasies like zlib
had until now.

Until now, if you wanted the .a in the main output, the only way was to go via
`static=false, shared=true` -- which made no sense, because you had to say
`static=false` even though you want a static lib. That is fixed now.
@nh2 nh2 force-pushed the zlib-static-shared-split-cleanup branch from 5647474 to 3d87db9 Compare August 14, 2019 22:06
@nh2 nh2 requested a review from Ericson2314 as a code owner August 14, 2019 22:06
@ofborg ofborg bot removed 8.has: changelog 8.has: documentation 8.has: module (update) This PR changes an existing module in `nixos/` labels Aug 14, 2019
@Ericson2314
Copy link
Member

madler/zlib#394 may it someday be better upstream.

@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 101-500 10.rebuild-linux: 501+ 10.rebuild-linux: 501-1000 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux 10.rebuild-darwin: 101-500 10.rebuild-linux: 501+ 10.rebuild-linux: 501-1000 labels Aug 14, 2019
nh2 added a commit to nh2/static-haskell-nix that referenced this pull request Aug 14, 2019
@nh2
Copy link
Contributor Author

nh2 commented Aug 15, 2019

splitStaticOutput definitely makes things clearer, although for the same reasons you describe in .pc, I was hoping we could eventually phase those out altogether. There are a few things that rely on this output existing though. pkg-config assumes that all of your libraries are in the same directory.

I have filed a separate issue for this task at #66658.

nh2 added a commit to nh2/static-haskell-nix that referenced this pull request Aug 15, 2019
Our submodule now includes the fix from
NixOS/nixpkgs#66490
which makes this unnecessary.
nh2 added a commit to nh2/static-haskell-nix that referenced this pull request Aug 16, 2019
nh2 added a commit to nh2/static-haskell-nix that referenced this pull request Aug 16, 2019
Our submodule now includes the fix from
NixOS/nixpkgs#66490
which makes this unnecessary.
nh2 added a commit to nh2/static-haskell-nix that referenced this pull request Aug 16, 2019
nh2 added a commit to nh2/static-haskell-nix that referenced this pull request Aug 16, 2019
Our submodule now includes the fix from
NixOS/nixpkgs#66490
which makes this unnecessary.
nh2 added a commit to nh2/static-haskell-nix that referenced this pull request Aug 16, 2019
nh2 added a commit to nh2/static-haskell-nix that referenced this pull request Aug 16, 2019
Our submodule now includes the fix from
NixOS/nixpkgs#66490
which makes this unnecessary.
@nh2 nh2 merged commit aa99a26 into NixOS:master Aug 17, 2019
nh2 added a commit to nh2/static-haskell-nix that referenced this pull request Aug 17, 2019
nh2 added a commit to nh2/static-haskell-nix that referenced this pull request Aug 17, 2019
Our submodule now includes the fix from
NixOS/nixpkgs#66490
which makes this unnecessary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.has: package (new) This PR adds a new package 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants