which: enable 64-bit API on 32-bit systems

Without the change `which` fails to find programs on filesystems with
64-bit inodes when `which` itself is 32-bit.

In my case it is `btrfs` and `i686-linux`.

`bison` is in the PATH:

    $ dev>bison
    bison: missing operand
    Try 'bison --help' for more information.

But `which` fails to find it:

    $ which bison
    which: no bison in ...

`bison` is a file with an inode number that overflows 2^31 limit:

    $ stat ~/bin/bison
      File: ~/bin/bison
      Size: 674260          Blocks: 1320       IO Block: 4096   regular file
    Device: 0,29    Inode: 4384368825  Links: 2
    Access: (0555/-r-xr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
    Access: 2023-09-05 04:48:43.000000000 +0100
    Modify: 1970-01-01 01:00:01.000000000 +0100
    Change: 2023-09-05 04:48:43.821566578 +0100
     Birth: 2023-09-05 04:48:43.772565733 +0100

The change fixes `which` run.
This commit is contained in:
Sergei Trofimovich 2023-09-05 09:24:28 +01:00
parent 3c1c30ec5e
commit a25d6143c6

View File

@ -12,6 +12,13 @@ stdenv.mkDerivation rec {
strictDeps = true;
enableParallelBuilding = true;
env.NIX_CFLAGS_COMPILE = toString (
# Enable 64-bit file API. Otherwise `which` fails to find tools
# on filesystems with 64-bit inodes (like `btrfs`) when running
# binaries from 32-bit systems (like `i686-linux`).
lib.optional stdenv.hostPlatform.is32bit "-D_FILE_OFFSET_BITS=64"
);
meta = with lib; {
homepage = "https://www.gnu.org/software/which/";
description = "Shows the full path of (shell) commands";