Subject: bug#17840: [PATCH] libtool: Use 'file' instead of '/usr/bin/file' on GNU systems.

From: Felix Lechner <[email-masked]>
Date: Wed, 28 Sep 2022 06:34:14 -0700

Hi,

> there are a number of different 'file' programs and libtool expects
> particular output from the 'file' program that it uses.

I only have one kind of 'file' program installed, and Libtool cannot find it.

Developing on Guix—which is a GNU project like Libtool—I hope to
migrate the authentication logic in Linux PAM to Guile (another GNU
project). I presently use Autotools and Libtool. [1] When running
'./configure' I get the error:

    ./configure: line 6750: /usr/bin/file: No such file or directory

As you can see at the bottom of this message, the issue probably
originated in Libtool, at least in part. With the help of a friend, I
found this bug.

While './configure' continues after the error, my appetite for
warnings is low due to the potential security implications of my work.

> If the 'file' encountered via PATH
> is not the same as the common one available as ‘/usr/bin/file’ on GNU
> systems, then there would be a problem.

That is a hypothetical. I have a real problem—for some value of
$problem. More significantly the hypothetical is my problem, and mine
alone.

If I were to use another implementation of the 'file' program,
/usr/bin/file would probably point to it. The use of the absolute path
does not ensure the program is the one Libtool expects. Moreover, it
falls outside the responsibilities of the Libtool maintainers to
curate my namespace of available executables. That is the domain of
distributions and system administrators. While the concern is valid,
it is not Libtool's problem.

As a side note, the positions here in favor of the absolute path
/usr/bin/file are only half correct. In Guix, we unequivocally believe
in absolute path names, perhaps more than most. The absolute
references allow us to have multiple versions of the same program
co-installed and available at the same time. Fans of /usr/bin/file are
encouraged to explore Guix. [2] You may find happiness!

Thank you for maintaining Libtool, an old and trusted friend!

Kind regards
Felix Lechner

[1] https://codeberg.org/lechner/guile-pam
[2] https://guix.gnu.org/

* * *

$ guix shell --development --file=guix.scm --check
$ autoreconf -fi
$ fgrep /usr/bin/file configure
  lt_cv_file_magic_cmd='/usr/bin/file -L'
      lt_cv_file_magic_cmd=/usr/bin/file
  lt_cv_file_magic_cmd=/usr/bin/file
  lt_cv_file_magic_cmd=/usr/bin/file
    case `/usr/bin/file conftest.$ac_objext` in
      case `/usr/bin/file conftest.$ac_objext` in
      case `/usr/bin/file conftest.$ac_objext` in
    case `/usr/bin/file conftest.$ac_objext` in
    case `/usr/bin/file conftest.$ac_objext` in
    case `/usr/bin/file conftest.$ac_objext` in
    case `/usr/bin/file conftest.o` in
        case `/usr/bin/file conftest.o` in
    case `/usr/bin/file conftest.o` in
$ fgrep -n usr/bin -r
/gnu/store/81n58x4293zwhvydzvvnypcz7y59jqmx-libtool-2.4.6/share/aclocal/libtool.m4
1295:    case `/usr/bin/file conftest.$ac_objext` in
1312:      case `/usr/bin/file conftest.$ac_objext` in
1324:      case `/usr/bin/file conftest.$ac_objext` in
1346:    case `/usr/bin/file conftest.$ac_objext` in
1354:    case `/usr/bin/file conftest.$ac_objext` in
1362:    case `/usr/bin/file conftest.$ac_objext` in
1382:    case `/usr/bin/file conftest.o` in
1389:    case `/usr/bin/file conftest.o` in
1457:    case `/usr/bin/file conftest.o` in
2661:  if test -x /usr/bin/objformat; then
2662:    objformat=`/usr/bin/objformat`
3226:[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
3229:    _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
3457:  lt_cv_file_magic_cmd='/usr/bin/file -L'
3498:      lt_cv_file_magic_cmd=/usr/bin/file
3512:  lt_cv_file_magic_cmd=/usr/bin/file
3559:  lt_cv_file_magic_cmd=/usr/bin/file