unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Philip McGrath" <philip@philipmcgrath.com>
To: "Maxime Devos" <maximedevos@telenet.be>,
	"Liliana Marie Prikler" <liliana.prikler@ist.tugraz.at>,
	57050@debbugs.gnu.org
Cc: Liliana Marie Prikler <liliana.prikler@gmail.com>,
	Efraim Flashner <efraim@flashner.co.il>,
	Thiago Jung Bauermann <bauermann@kolabnow.com>
Subject: [bug#57050] [PATCH v2 04/13] gnu: Add Zuo.
Date: Mon, 22 Aug 2022 21:40:29 -0400	[thread overview]
Message-ID: <d77982b0-50df-4bf9-9fc4-1a0e3e700cbe@www.fastmail.com> (raw)
In-Reply-To: <923c0709-4fe9-5f02-06a1-196095f5199e@telenet.be>

Hi,

On Tue, Aug 16, 2022, at 10:47 AM, Maxime Devos wrote:
> On 11-08-2022 16:00, Philip McGrath wrote:
>>>> +        #~`(,(string-append "CPPFLAGS=-DGUIX_RKTIO_BIN_SH="
>>>> +                            #$(file-append (this-package-input
>>>> "bash-minimal")
>>>> +                                           "/bin/sh"))
>>>> 
>>> As with chez-scheme, I do think using a Racket-agnostic macro name is
>>> helpful here.
>>> 
>> I'm planning to respond in the other thread about the possibility of a truly generic macro name, but I hope it doesn't need to become an issue blocking this patch series. For now, I'm not entirely sure what "Racket-agnostic" means; the bottom line for my is I think it would be absurdly awful to have to write, e.g. if cross-compiling using `distro-build` with the top-level Makefile:
>> 
>>     ./configure CPPFLAGS="GUIX_RKTIO_BIN_SH=/input/bin/sh GUIX_ZUO_BIN_SH=/input/bin/sh GUIX_CHEZ_BIN_SH=/input/bin/sh" CPPFLAGS_FOR_BUILD="GUIX_RKTIO_BIN_SH=/native-input/bin/sh GUIX_ZUO_BIN_SH=/native-input/bin/sh GUIX_CHEZ_BIN_SH=/native-input/bin/sh"
>
> Example: GUIX_SH=/inputs/bin/sh.
> 

I will use GUIX_SH in v3 of this series.

My concern with it originally was that it's generic enough that it might be used in other ways elsewhere in Guix, but, since I'm hoping it's only going to be a medium-term solution, it seems good enough, and I haven't heard any objections to it.

> I haven't been following the discussion on the other patches, but didn't I give an example of something independent of the Racket component in use and even independent of Racket itself? See the suggestion of using the already existing _PATH_BSHELL from <paths.h>. It's even not Guix-specific, apparently it's a BSD-ism!
> 

On Wed, Aug 10, 2022, at 7:46 AM, Maxime Devos wrote:
> On 09-08-2022 23:58, Philip McGrath wrote:
>
>> On Tuesday, August 9, 2022 5:38:56 PM EDT ( wrote:
>>> On Tue Aug 9, 2022 at 10:24 PM BST, Maxime Devos wrote:
>>>> In the glibc headers, there's some (POSIX?) standard macro that points
>>>> at "/gnu/store/.../bin/sh" (I don't recall the name), any reason we
>>>> aren't using that macro?  That would be Guix-independent. I'm not sure
>>>> if a /gnu/store/... prefix is included, but if not, maybe we could try
>>>> overriding it with -D...="/gnu/store/...", or failing that, add a
>>>> post-unpack substitute* replacing [the macro name] ->
>>>> "/gnu/store/.../bin/sh".
>>> I believe you might be referring to <paths.h>, which defines _PATH_BSHELL.
>>>
>>> It's not standard C <https://en.cppreference.com/w/c/header> nor POSIX
>>> <https://pubs.opengroup.org/onlinepubs/9699919799/idx/head.html> though.
>>>
>>>      -- (
>
> Looking at the "paths.h" header, it appears to be a BSDism. Not really 
> standard but still better than a Guix-ism.
>
>> I'd love to be wrong, but I also can't find such a macro. In the glibc source
>> tree, "stdlib/system.c" defines a stub implementation that always fails with
>> ENOSYS, and "sysdeps/posix/system.c" contains:
>>
>>      #define	SHELL_PATH	"/bin/sh"	/* Path of the shell.  */
>>      #define	SHELL_NAME	"sh"	/* Name to give it.  */
>>
>> Concretely, I think Guix's glibc currently uses /bin/sh dynamically: in my
>> Chez example above, if you replace `process` with `system` (which uses libc's
>> `system`), the result is always "/bin/sh\n".
>
> If so, that's a bug.  I do not know what result you are referring to.

(Disregard this part; I think I was thinking about some other way I had tried things.)

>
> Anyway, the Guix package definition of glibc substitutes _PATH_BSHELL 
> and SHELL_PATH, so unless there's a bug, it doesn't depend on /bin/sh.
>

I have been looking further into options for addressing this upstream.

First of all, I have found that there *is* another Unix-like system where "/bin/sh" doesn't exist: on Android, the POSIX shell is usually at "/system/bin/sh". Also, at least on some versions, _PATH_BSHELL isn't a compile-time constant. It is:

    #define _PATH_BSHELL __bionic_get_shell_path()

(There are also systems where "/bin/sh" is some non-POSIX shell and the POSIX shell is at "/usr/xpg4/bin/sh". If changing this upstream, Racket may need to decide whether POSIX compatibility or historical compatibility is more important there.)

I've found that there does seem to be a POSIX recommendation for finding "sh". The POSIX spec for `system` <https://pubs.opengroup.org/onlinepubs/9699919799/functions/system.html> says, under "Application Usage", "There is no defined way for an application to find the specific path for the shell. However, confstr() can provide a value for PATH that is guaranteed to find the sh utility." Similarly, <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html> says that "applications should note that the standard PATH to the shell cannot be assumed to be either /bin/sh or /usr/bin/sh, and should be determined by interrogation of the PATH returned by getconf PATH, ensuring that the returned pathname is an absolute pathname and not a shell built-in." Most emphatically, <https://pubs.opengroup.org/onlinepubs/9699919799/functions/confstr.html> says in the normative "Description":

>
> If the implementation supports the POSIX shell option, the string stored in buf after a call to:
>
>     confstr(_CS_PATH, buf, sizeof(buf))
>
> can be used as a value of the PATH environment variable that accesses all of the standard utilities of POSIX.1-2017, that are provided in a manner accessible via the exec family of functions, if the return value is less than or equal to sizeof(buf).
>

However, apparently using `confstr` with `_CS_PATH` does not give a useful result in Guix build environments. Try building the following package with `guix build -f`: I've put the interesting log output in the description. In particular, note that *both* bash-minimal and bash-static are present!

--8<---------------cut here---------------start------------->8---
(use-modules
 (guix build-system gnu)
 (guix gexp)
 ((guix licenses) #:prefix license:)
 (guix packages))
(define src
  (plain-file "demo.c"
              "#include <stdlib.h>
#include <stdio.h>
#include <paths.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
  puts(_PATH_BSHELL);
  size_t buf_len = confstr(_CS_PATH, NULL, 0);
  char* buf = malloc(buf_len);
  if (NULL == buf) {
    return 1;
  };
  confstr(_CS_PATH, buf, buf_len);
  puts(buf);
  fflush(stdout);
  int status = system(\"echo $BASH\");
  fflush(stdout);
  printf(\"status: %i\\n\", status);
  return 0;
}
"))
(package
  (name "libc-system-demo")
  (version "0")
  (source src)
  (build-system gnu-build-system)
  (arguments
   (list
    #:phases
    #~(modify-phases %standard-phases
        (delete 'configure)
        (replace 'build
          (lambda args
            (invoke "gcc" "-o" "demo" #$src)))
        (replace 'check
          (lambda args
            (invoke "./demo")))
        (replace 'install
          (lambda args
            (install-file "demo" (string-append #$output "/bin")))))))
  (home-page "https://issues.guix.gnu.org/57050")
  (synopsis "Some 'sh'-related values from glibc")
  (description "starting phase `check'
/gnu/store/720rj90bch716isd8z7lcwrnvz28ap4y-bash-static-5.1.8/bin/sh
/bin:/usr/bin
/gnu/store/4y5m9lb8k3qkb1y9m02sw9w9a6hacd16-bash-minimal-5.1.8/bin/sh
status: 0
phase `check' succeeded after 0.0 seconds")
  (license license:cc0))
--8<---------------cut here---------------end--------------->8---

AFAICT, Glibc's `confstr` implementation for `_CS_PATH` doesn't have any mechanism for configuring the search path; it simply uses the compile-time version, `CS_PATH`, which is:

    #define	CS_PATH	"/bin:/usr/bin"

More generally, it seems questionable for our glibc to retain a store reference to Bash (let alone two). Wouldn't that prevent creating containers or packs without a shell present?

After I've sent a v3 of this series, I plan to raise these questions on the guix-devel list. Then, once I have a sense of whether Guix would like to support `confstr` with  `_CS_PATH` as a way of finding the shell, I'll propose some changes to Racket upstream.

-Philip




  reply	other threads:[~2022-08-23  1:41 UTC|newest]

Thread overview: 122+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-08  6:06 [bug#57050] [PATCH 0/6] gnu: Update Racket to 8.6. Add Zuo Philip McGrath
2022-08-08  6:10 ` [bug#57050] [PATCH 1/6] gnu: stex: Update to 1.2.2-2.afa6075 Philip McGrath
2022-08-08  6:10 ` [bug#57050] [PATCH 2/6] gnu: stex: Fix read-only gifs and math directories Philip McGrath
2022-08-08  6:10 ` [bug#57050] [PATCH 3/6] gnu: chez-scheme: Fix use of "/bin/sh" Philip McGrath
2022-08-08  8:53   ` Liliana Marie Prikler
2022-08-09 20:25     ` Philip McGrath
2022-08-09 21:24       ` Maxime Devos
2022-08-09 21:38         ` ( via Guix-patches via
2022-08-09 21:58           ` Philip McGrath
2022-08-09 22:09             ` ( via Guix-patches via
2022-08-10 11:46             ` Maxime Devos
2022-08-08  6:10 ` [bug#57050] [PATCH 4/6] gnu: Update Racket to 8.6. Add Zuo Philip McGrath
2022-08-08  9:01   ` Liliana Marie Prikler
2022-08-09 20:56     ` Philip McGrath
2022-08-10  7:34       ` Liliana Marie Prikler
2022-08-08  6:10 ` [bug#57050] [PATCH 5/6] gnu: racket: Use Racket CS on all systems Philip McGrath
2022-08-08  9:10   ` Liliana Marie Prikler
2022-08-08  6:10 ` [bug#57050] [PATCH 6/6] gnu: chez-scheme-for-racket: Suport " Philip McGrath
2022-08-08  9:15   ` Liliana Marie Prikler
2022-08-10 15:30 ` [bug#57050] [PATCH 0/6] gnu: Update Racket to 8.6. Add Zuo Thiago Jung Bauermann via Guix-patches via
2022-08-11  4:00   ` Philip McGrath
2022-08-11 11:08     ` [bug#57050] [PATCH v2 00/13] " Philip McGrath
2022-08-11 11:08       ` [bug#57050] [PATCH v2 01/13] gnu: stex: Update to 1.2.2-2.afa6075 Philip McGrath
2022-08-11 11:08       ` [bug#57050] [PATCH v2 02/13] gnu: stex: Fix read-only gifs and math directories Philip McGrath
2022-08-11 11:13         ` Liliana Marie Prikler
2022-08-11 11:08       ` [bug#57050] [PATCH v2 03/13] gnu: chez-scheme: Fix use of "/bin/sh" Philip McGrath
2022-08-11 11:08       ` [bug#57050] [PATCH v2 04/13] gnu: Add Zuo Philip McGrath
2022-08-11 11:31         ` Liliana Marie Prikler
2022-08-11 14:00           ` Philip McGrath
2022-08-11 15:34             ` Liliana Marie Prikler
2022-08-11 23:32               ` Philip McGrath
2022-08-16 14:47             ` Maxime Devos
2022-08-23  1:40               ` Philip McGrath [this message]
2022-08-23  9:11                 ` Maxime Devos
2022-08-23 23:24                   ` Philip McGrath
2022-08-23  9:20                 ` Maxime Devos
2022-08-24  0:27                   ` Philip McGrath
2022-08-24  5:42                     ` Liliana Marie Prikler
2022-08-24  5:47                       ` Philip McGrath
2022-08-25  8:54                     ` [bug#57050] [PATCH v3 00/14] gnu: Update Racket to 8.6. " Philip McGrath
2022-08-25  8:54                       ` [bug#57050] [PATCH v3 01/14] gnu: stex: Update to 1.2.2-2.afa6075 Philip McGrath
2022-08-25  8:54                       ` [bug#57050] [PATCH v3 02/14] gnu: stex: Fix read-only gifs and math directories Philip McGrath
2022-08-25  8:54                       ` [bug#57050] [PATCH v3 03/14] etc: teams: Add racket team Philip McGrath
2022-08-25  8:54                       ` [bug#57050] [PATCH v3 04/14] etc: teams: Add entry for Philip McGrath Philip McGrath
2022-08-25  8:54                       ` [bug#57050] [PATCH v3 05/14] gnu: racket: Adjust patch for "/bin/sh" in rktio Philip McGrath
2022-08-25  9:09                         ` Liliana Marie Prikler
2022-08-25 19:16                           ` Philip McGrath
2022-08-25  8:54                       ` [bug#57050] [PATCH v3 06/14] gnu: chez-scheme: Fix use of "/bin/sh" Philip McGrath
2022-08-25  8:54                       ` [bug#57050] [PATCH v3 07/14] gnu: Add Zuo Philip McGrath
2022-08-25  9:12                         ` Liliana Marie Prikler
2022-08-25 10:30                         ` Efraim Flashner
2022-08-25 20:04                           ` Philip McGrath
2022-08-26 12:01                             ` Liliana Marie Prikler
2022-08-27 18:08                               ` Philip McGrath
2022-08-27 18:58                                 ` Liliana Marie Prikler
2022-08-27 19:54                                   ` Philip McGrath
2022-08-27 21:18                                     ` Liliana Marie Prikler
2022-08-27 21:28                                       ` Philip McGrath
2022-08-27 22:26                                         ` Liliana Marie Prikler
2022-08-25  8:54                       ` [bug#57050] [PATCH v3 08/14] gnu: racket: Update to 8.6 Philip McGrath
2022-08-25  9:14                         ` Liliana Marie Prikler
2022-08-25 10:39                         ` Efraim Flashner
2022-08-25  8:54                       ` [bug#57050] [PATCH v3 09/14] gnu: chez-scheme: Make bootfiles regular inputs Philip McGrath
2022-08-25  8:54                       ` [bug#57050] [PATCH v3 10/14] gnu: chez-scheme-for-racket: Support cross-compilation Philip McGrath
2022-08-25  8:54                       ` [bug#57050] [PATCH v3 11/14] gnu: racket: Support cross-compiling the VM packages Philip McGrath
2022-08-25  8:54                       ` [bug#57050] [PATCH v3 12/14] gnu: chez-scheme-for-racket: Suport all systems Philip McGrath
2022-08-25  9:24                         ` Liliana Marie Prikler
2022-08-25 10:50                           ` Efraim Flashner
2022-08-25 20:17                             ` Philip McGrath
2022-08-25  8:54                       ` [bug#57050] [PATCH v3 13/14] gnu: racket-vm-bc: Add workaround for ppc64le Philip McGrath
2022-08-25  8:54                       ` [bug#57050] [PATCH v3 14/14] gnu: racket: Use Racket CS on all systems Philip McGrath
2022-08-25  9:17                         ` Liliana Marie Prikler
2022-08-26 21:15                       ` [bug#57050] [PATCH v3 00/14] gnu: Update Racket to 8.6. Add Zuo Thiago Jung Bauermann via Guix-patches via
2022-08-27 18:55                     ` [bug#57050] [PATCH v4 " Philip McGrath
2022-08-27 18:55                       ` [bug#57050] [PATCH v4 01/14] gnu: stex: Update to 1.2.2-2.afa6075 Philip McGrath
2022-08-27 18:55                       ` [bug#57050] [PATCH v4 02/14] gnu: stex: Fix read-only gifs and math directories Philip McGrath
2022-08-27 18:55                       ` [bug#57050] [PATCH v4 03/14] etc: teams: Add racket team Philip McGrath
2022-08-27 18:55                       ` [bug#57050] [PATCH v4 04/14] etc: teams: Add entry for Philip McGrath Philip McGrath
2022-08-27 18:55                       ` [bug#57050] [PATCH v4 05/14] gnu: racket: Adjust patch for "/bin/sh" in rktio Philip McGrath
2022-08-27 18:55                       ` [bug#57050] [PATCH v4 06/14] gnu: chez-scheme: Fix use of "/bin/sh" Philip McGrath
2022-08-27 18:55                       ` [bug#57050] [PATCH v4 07/14] gnu: Add Zuo Philip McGrath
2022-08-27 18:55                       ` [bug#57050] [PATCH v4 08/14] gnu: racket: Update to 8.6 Philip McGrath
2022-08-27 19:21                         ` Liliana Marie Prikler
2022-08-27 20:30                           ` Philip McGrath
2022-08-27 18:55                       ` [bug#57050] [PATCH v4 09/14] gnu: chez-scheme: Make bootfiles regular inputs Philip McGrath
2022-08-27 18:55                       ` [bug#57050] [PATCH v4 10/14] gnu: chez-scheme-for-racket: Support cross-compilation Philip McGrath
2022-08-27 18:55                       ` [bug#57050] [PATCH v4 11/14] gnu: racket: Support cross-compiling the VM packages Philip McGrath
2022-08-27 18:55                       ` [bug#57050] [PATCH v4 12/14] gnu: chez-scheme-for-racket: Support all systems Philip McGrath
2022-08-27 18:55                       ` [bug#57050] [PATCH v4 13/14] gnu: racket-vm-bc: Add workaround for ppc64le Philip McGrath
2022-08-27 18:55                       ` [bug#57050] [PATCH v4 14/14] gnu: racket: Use Racket CS on all systems Philip McGrath
2022-09-04 20:53                       ` bug#57050: [PATCH 0/6] gnu: Update Racket to 8.6. Add Zuo Ludovic Courtès
2022-08-11 11:08       ` [bug#57050] [PATCH v2 05/13] gnu: racket: Update to 8.6 Philip McGrath
2022-08-11 11:44         ` Liliana Marie Prikler
2022-08-11 22:40           ` Philip McGrath
2022-08-12  6:34             ` Liliana Marie Prikler
2022-08-22  8:41         ` Efraim Flashner
2022-08-22 18:56           ` Philip McGrath
2022-08-11 11:08       ` [bug#57050] [PATCH v2 06/13] gnu: chez-scheme: Bootfiles should not be native inputs Philip McGrath
2022-08-11 11:47         ` Liliana Marie Prikler
2022-08-11 22:45           ` Philip McGrath
2022-08-12  4:21             ` Liliana Marie Prikler
2022-08-11 11:08       ` [bug#57050] [PATCH v2 07/13] gnu: chez-scheme-for-racket: Support cross-compilation Philip McGrath
2022-08-11 11:56         ` Liliana Marie Prikler
2022-08-11 22:49           ` Philip McGrath
2022-08-11 11:08       ` [bug#57050] [PATCH v2 08/13] gnu: racket: Support cross-compiling the VM packages Philip McGrath
2022-08-11 11:58         ` Liliana Marie Prikler
2022-08-11 23:23           ` Philip McGrath
2022-08-11 11:08       ` [bug#57050] [PATCH v2 09/13] gnu: chez-scheme-for-racket: Suport all systems Philip McGrath
2022-08-11 12:02         ` Liliana Marie Prikler
2022-08-11 23:25           ` Philip McGrath
2022-08-11 11:08       ` [bug#57050] [PATCH v2 10/13] gnu: racket-vm-bc: Add workaround for ppc64le Philip McGrath
2022-08-11 11:08       ` [bug#57050] [PATCH v2 11/13] gnu: racket: Use Racket CS on all systems Philip McGrath
2022-08-11 12:03         ` Liliana Marie Prikler
2022-08-11 11:08       ` [bug#57050] [PATCH v2 12/13] etc: teams: Add racket team Philip McGrath
2022-08-11 12:11         ` Liliana Marie Prikler
2022-08-11 11:08       ` [bug#57050] [PATCH v2 13/13] etc: teams: Add entry for Philip McGrath Philip McGrath
2022-08-13 17:43       ` [bug#57050] [PATCH v2 00/13] gnu: Update Racket to 8.6. Add Zuo Thiago Jung Bauermann via Guix-patches via
2022-08-15  5:47       ` [bug#57050] [RFC PATCH] gnu: racket-vm-cs: Avoid 'configure' bug with '--enable-racket' Philip McGrath
2022-08-15  6:12         ` Philip McGrath
2022-08-15 19:54       ` [bug#57050] [RFC PATCH v2] gnu: racket: Backport fix for powerpc64le Philip McGrath
2022-08-19  0:51         ` Thiago Jung Bauermann via Guix-patches via
2022-08-19 10:10           ` Maxime Devos

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

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=d77982b0-50df-4bf9-9fc4-1a0e3e700cbe@www.fastmail.com \
    --to=philip@philipmcgrath.com \
    --cc=57050@debbugs.gnu.org \
    --cc=bauermann@kolabnow.com \
    --cc=efraim@flashner.co.il \
    --cc=liliana.prikler@gmail.com \
    --cc=liliana.prikler@ist.tugraz.at \
    --cc=maximedevos@telenet.be \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).