all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: elaexuotee--- via Bug reports for GNU Guix <bug-guix@gnu.org>
To: 25258@debbugs.gnu.org
Subject: bug#25258: Bashisms in make rules
Date: Sat, 16 May 2020 15:33:09 +0900	[thread overview]
Message-ID: <3QC37OOAPFHT8.3ELLIYWH54G6D@wilsonb.com> (raw)
In-Reply-To: <c3eb8da7-acf5-f661-48d1-fd70d322560d@pelzflorian.de>


[-- Attachment #1.1: Type: text/plain, Size: 3242 bytes --]

Resurrecting this, since it cause me significant grief, and is a simple
workaround which I believe is worth putting in the documentation. First, here
is a short summary of the problem:

Currently, some of our make rules contain bashisms. As of commit 408ae72c, this
ends up generating broken texinfo translations under doc/*.texi, eventually
failing with "@ref reference to nonexistent node..." errors.

From a pristine repository (e.g. after running `git clean -xfd'), running make
shows a bunch of errors from the broken rules, but since they happen to be
multi-line scripts, the errors fail to propogate up to make. Thus make leaves
around the broken texinfo files. The real kicker is that subsequent runs pick
up the broken files and make fails just as above, but without encountering or
showing the errors from the broken rules. This makes tracking down the error
significantly more painful and non-obvious.

Anyway, the source of the problem is a combination of our use of bashisms and
autoconf trying really hard to use the least-common-denominator shell.
Autoconf's configure script sets make's SHELL by first looking for /bin/sh and
only finding sh on PATH as a last resort. Thus, even when running under `guix
environment --pure guix' make will run with /bin/sh instead of
$GUIX_ENVIRONMENT/bin/sh.

On a Guix System this ends up running make with the sh of the system profile
which, at the moment, resolves to bash. However, on a foreign distribution,
/bin/sh often resolves to a non-bash shell; in particular, it is common these
days for it to be a symlink to dash. Hence, lots of pain.

Once we know the source of the error, the fix is simple. We can explicitly tell
make to run it's rules with bash:

    $ make SHELL=$(command -v bash)

In a guix environment, this should pick up the bash in $GUIX_ENVIRONMENT.
Better yet, we can do this once, by telling *configure* what shell to use:

    $ CONFIG_SHELL=$(command -v bash) ./configure

and all subsequent runs of make will Just Work from within the environment.

Does this make sense? Am I missing something obvious? If not, would it make
sense to include the above ./configure invocation in our documentation?

Ideally, we could modify Makefile.am or configure.ac in some way to
automatically fix the problem; however, if we want to support build exterior to
a guix build environment, I suspect the "most correct" course of action is to
simply remove our bashisms.

That said, we could tell automake to *not* explicity set make's SHELL by a
simple one-liner in `configure.ac':

    AM_SUBST_NOTMAKE([SHELL])

This will cause make to use it's baked-in default instead of the one autoconf
detects. Luckily, for guix builds make correctly references the profile's sh:

    $ strings $GUIX_ENVIRONMENT/bin/make | grep bin/sh
    /gnu/store/<hash>-bash-<version>/bin/sh

and non-guix make is likely to point to something relevant for that
distribution anyway. That said, I am sure automake and autoconf set make's
SHELL for a reason, so perhaps this solution is too heavy of a hammer.
Thoughts?

Anyway, this turned into a lot longer of an email than I anticipated. Thanks
for taking the time to read through it.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 260 bytes --]

  parent reply	other threads:[~2020-05-16  6:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-24  7:26 bug#25258: Bashisms when building 0.11.0 pelzflorian (Florian Pelz)
2019-02-13  1:46 ` Leo Famulari
2020-03-22 20:28   ` Leo Famulari
2020-05-16  6:33 ` elaexuotee--- via Bug reports for GNU Guix [this message]
2020-05-17 16:42 ` bug#25258: Bashisms in make rules Vincent Legoll
2020-05-17 17:34   ` Tobias Geerinckx-Rice via Bug reports for GNU Guix

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3QC37OOAPFHT8.3ELLIYWH54G6D@wilsonb.com \
    --to=bug-guix@gnu.org \
    --cc=25258@debbugs.gnu.org \
    --cc=elaexuotee@wilsonb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.