nixpkgs/pkgs/stdenv
Alyssa Ross 2ebeb02a99 stdenv/setup: tell libtool about library paths
Packages that use libtool run it as a wrapper around the linker.
Before calling the linker, libtool will determine what libraries would
be linked, and check if there's a corresponding libtool
archive (libfoo.la) file in the same directory .  This file
contains extra information about the library.  This is especially
important for static linking, because static archives don't contain
dependency information, so we need libtool to use the .la files to
figure out which libraries actually need to be linked against.

But in Nixpkgs, this has never worked.  libtool isn't able to find any
libraries, because only the compiler wrapper knows how to find them,
and the compiler wrapper is opaque to libtool.  This is why
pkgsStatic.util-linuxMinimal doesn't build prior to this patch — it
depends on libpam, which depends on libaudit, and if libtool can't
find the .la file, nothing will tell the linker to also link against
libaudit when linking libpam.  (It was previously possible to build a
static util-linux, because linux-pam only recently had the audit
dependency added.)

There are a couple of ways we could fix this, so that libtool knows
where to look for .la files.

 * Set LD_LIBRARY_PATH/DYLD_LIBRARY_PATH/whatever, which libtool will
   examine.  This would have major side effects though, because the
   dynamic linker looks at it too.

 * Inject libtool scripts with the appropriate information.  That's
   what I've done here.  It was the obvious choice because we're
   already finding and modifying the libtool scripts, to remove paths
   outside the Nix store that libtool might check in unsandboxed
   builds.  Instead of emptying out the system paths, we can
   repopulate it with our own library paths.

(We can't use a wrapper like we do for other tools in Nixpkgs, because
libtool scripts are often distributed in source tarballs, so we can't
just add a wrapped version of libtool as a dependency.  That's why
there's already the fixLibtool function in stdenv.)

With this change, libtool is able to discover .la files, and
pkgsStatic.util-linuxMinimal can build again, linking correctly
against libpam and libaudit.
2021-11-23 21:33:16 +00:00
..
cross pkgsStatic: Finally obviate overlay! 2021-08-20 06:09:48 +00:00
custom
cygwin treewide: Make still dont* Variables are optional in most cases 2019-11-01 14:44:44 -04:00
darwin libxml2: use libiconv on Darwin 2021-10-02 10:05:17 +09:00
freebsd Make the bootsrap respect the contentAddressedByDefault setting 2021-04-28 10:25:49 +02:00
generic stdenv/setup: tell libtool about library paths 2021-11-23 21:33:16 +00:00
linux stdenv: move --enable-deterministic-archives flag into GNU wrapper 2021-09-18 15:11:17 +02:00
native stdenv/native: fix bintools import 2021-06-07 11:26:15 +00:00
nix stdenv/{native,nix}: add lib to cc-wrapper args 2021-04-21 11:56:55 -04:00
adapters.nix pkgsStatic: Finally obviate overlay! 2021-08-20 06:09:48 +00:00
booter.nix pkgs/stdenv/booter.nix: Add comment explaining hasCC trickery 2019-12-30 18:09:45 -05:00
common-path.nix
default.nix stdenv/darwin: Apple Silicon support 2021-05-17 00:27:02 +09:00