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

pruneLibtoolFiles: init setup hook #41819

Merged
merged 1 commit into from Jun 11, 2018
Merged

Conversation

orivej
Copy link
Contributor

@orivej orivej commented Jun 11, 2018

A .la file specifies linker flags to link with the library it describes. Its
"dependency_libs" field lists the libraries that this library depends upon.
This list often contains "-l" flags without corresponding "-L" flags. Many
packages in Nixpkgs deal with this in one of these ways:

  • delete .la file [1]
  • clear dependency_libs [2]
  • add -L flags to dependency_libs [3]
  • propagate dependencies [4]

Sometimes "dependency_libs" contain wrong "-L" flags pointing to the "dev"
output with headers rather than to the main output with libraries. They have to
be edited or deleted to reduce closure size [5].

Deleting .la files is often but not always safe [6]. Atomatically deleting as
many of them as possible is complex [7]. Deleting .la files that describe
shared rather than static libraries is probably safe; but clearing their
"dependency_libs" field achieves the same effect with less potential for
unintended consequences. This is the approach that may be enabled for all
Nixpkgs.

[1] 2a79d29
[2] c83a530
[3] 9e0dcf3
[4] 01134e6
[5] f6c73f1
[6] https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Handling_Libtool_Archives
[7] https://github.com/gentoo/gentoo/blob/fb1f2435/eclass/ltprune.eclass


I intend to merge this not enabled by default for use by individual packages, and to enable it by default on the next staging cycle.

A .la file specifies linker flags to link with the library it describes. Its
"dependency_libs" field lists the libraries that this library depends upon.
This list often contains "-l" flags without corresponding "-L" flags. Many
packages in Nixpkgs deal with this in one of these ways:
- delete .la file [1]
- clear dependency_libs [2]
- add -L flags to dependency_libs [3]
- propagate dependencies [4]

Sometimes "dependency_libs" contain wrong "-L" flags pointing to the "dev"
output with headers rather than to the main output with libraries. They have to
be edited or deleted to reduce closure size [5].

Deleting .la files is often but not always safe [6].  Atomatically deleting as
many of them as possible is complex [7].  Deleting .la files that describe
shared rather than static libraries is probably safe; but clearing their
"dependency_libs" field achieves the same effect with less potential for
unintended consequences.  This is the approach that may be enabled for all
Nixpkgs.

[1] NixOS@2a79d29
[2] NixOS@c83a530
[3] NixOS@9e0dcf3
[4] NixOS@01134e6
[5] NixOS@f6c73f1
[6] https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Handling_Libtool_Archives
[7] https://github.com/gentoo/gentoo/blob/fb1f2435/eclass/ltprune.eclass
@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Attempted: pruneLibtoolFiles

Partial log (click to expand)

these derivations will be built:
  /nix/store/av4rg547r8ls3w1xyhwv710icfy7abm3-prune-libtool-files.drv
building '/nix/store/av4rg547r8ls3w1xyhwv710icfy7abm3-prune-libtool-files.drv'...
/nix/store/ycn0pilhc58x4h9aycpg650g53i7ivxq-prune-libtool-files

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Attempted: pruneLibtoolFiles

Partial log (click to expand)

these derivations will be built:
  /nix/store/jcaj9v25nxx58ya3pagyai4yvlvy4hfa-prune-libtool-files.drv
building '/nix/store/jcaj9v25nxx58ya3pagyai4yvlvy4hfa-prune-libtool-files.drv'...
/nix/store/z4y0sq4w6q2d9imxx1k63pyr2yv7279q-prune-libtool-files

@GrahamcOfBorg
Copy link

Success on x86_64-darwin (full log)

Attempted: pruneLibtoolFiles

Partial log (click to expand)

these derivations will be built:
  /nix/store/xiklfkggbx11ajjj614kcxg33jz6g2vj-prune-libtool-files.drv
these paths will be fetched (0.11 MiB download, 0.26 MiB unpacked):
  /nix/store/r4796h6pmcfds0m8ln9dcvkx5n2a23z4-stdenv-darwin
  /nix/store/wwpsf6lp73i2fpzv6cdics69zas7rx05-patch-2.7.6
copying path '/nix/store/wwpsf6lp73i2fpzv6cdics69zas7rx05-patch-2.7.6' from 'https://cache.nixos.org'...
copying path '/nix/store/r4796h6pmcfds0m8ln9dcvkx5n2a23z4-stdenv-darwin' from 'https://cache.nixos.org'...
building '/nix/store/xiklfkggbx11ajjj614kcxg33jz6g2vj-prune-libtool-files.drv'...
/nix/store/03hzid4gczvi3drjq06h2b5i2r41hlgz-prune-libtool-files

@orivej
Copy link
Contributor Author

orivej commented Jun 11, 2018

For the record, triton has opted to discover and replace -L flags in libtool and pkgconfig files: https://github.com/triton/triton/blob/a8b6386c/pkgs/build-support/setup-hooks/absolute-libtool.sh . (This works for closure reduction too because original -L flags are deleted.)

@matthewbauer
Copy link
Member

For the record, triton has opted to discover and replace -L flags in libtool and pkgconfig files: https://github.com/triton/triton/blob/a8b6386c/pkgs/build-support/setup-hooks/absolute-libtool.sh . (This works for closure reduction too because original -L flags are deleted.)

One thing I've found though is that sometimes "-R" is used as well. See e93a8cb.

@orivej orivej merged commit fd97db4 into NixOS:master Jun 11, 2018
orivej referenced this pull request Jun 13, 2018
Using multiple outputs we can easily build static libraries. This is a proposal to always statically link things. Needs testing & discussion before merging.

/cc @orivej @nlewo @xeji
orivej-nixos added a commit that referenced this pull request Jan 11, 2019
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.

None yet

4 participants