about summary refs log tree commit diff
path: root/pkgs/stdenv
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2023-11-23 12:28:49 +0100
committerAdam Joseph <54836058+amjoseph-nixpkgs@users.noreply.github.com>2023-11-30 10:46:44 +0000
commit0d44b5b7733e35fe17b34921c611c21f805068a9 (patch)
tree474f9a493ed0ed51a469f5df9736e73201b20156 /pkgs/stdenv
parent4552f3aa254e5c50406ca59c2c04483ef8539161 (diff)
downloadnixlib-0d44b5b7733e35fe17b34921c611c21f805068a9.tar
nixlib-0d44b5b7733e35fe17b34921c611c21f805068a9.tar.gz
nixlib-0d44b5b7733e35fe17b34921c611c21f805068a9.tar.bz2
nixlib-0d44b5b7733e35fe17b34921c611c21f805068a9.tar.lz
nixlib-0d44b5b7733e35fe17b34921c611c21f805068a9.tar.xz
nixlib-0d44b5b7733e35fe17b34921c611c21f805068a9.tar.zst
nixlib-0d44b5b7733e35fe17b34921c611c21f805068a9.zip
pkgsStatic.stdenv: fix custom CMake LINKER_LANGUAGE
If a CMake target has a non-default LINKER_LANGUAGE set, CMake will
manually add the libraries it has detected that language's compiler as
linking implicitly.  When it does this, it'll pass -Bstatic and
-Bdynamic options based on the vibes it gets from each such detected
library.  This in itself isn't a problem, because the compiler
toolchain, or our wrapper, or something, seems to be smart enough to
ignore -Bdynamic for those libraries.  But it does create a problem if
the compiler adds extra libraries to the linker command line after
that final -Bdynamic, because those will be linked dynamically.  Since
our compiler is static by default, CMake should reset to -Bstatic
after it's done manually specifying libraries, but CMake didn't
actually know that our compiler is static by default.  The fix for
that is to tell it, like so.

Until recently, this problem was difficult to notice, because it would
result binaries that worked, but that were dynamically linked.  Since
e08ce498f03f ("cc-wrapper: Account for NIX_LDFLAGS and NIX_CFLAGS_LINK
in linkType"), though, -Wl,-dynamic-linker is no longer mistakenly
passed for executables that are supposed to be static, so they end up
created with a /lib interpreter path, and so don't run at all on
NixOS.

This fixes pkgsStatic.graphite2.
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r--pkgs/stdenv/generic/make-derivation.nix2
1 files changed, 2 insertions, 0 deletions
diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix
index 63d02c8f0857..faa83507893f 100644
--- a/pkgs/stdenv/generic/make-derivation.nix
+++ b/pkgs/stdenv/generic/make-derivation.nix
@@ -427,6 +427,8 @@ else let
           "-DCMAKE_HOST_SYSTEM_VERSION=${stdenv.buildPlatform.uname.release}"
         ] ++ optionals (stdenv.buildPlatform.canExecute stdenv.hostPlatform) [
           "-DCMAKE_CROSSCOMPILING_EMULATOR=env"
+        ] ++ lib.optionals stdenv.hostPlatform.isStatic [
+          "-DCMAKE_LINK_SEARCH_START_STATIC=ON"
         ]);
 
       mesonFlags =