GNU bug report logs - #47180
[PATCH] gnu: racket: Don't inject store paths into Racket files.

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: Philip McGrath <philip@HIDDEN>; Keywords: patch; Done: Ludovic Courtès <ludo@HIDDEN>; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 47180 <at> debbugs.gnu.org:


Received: (at 47180) by debbugs.gnu.org; 16 Apr 2021 20:16:23 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Apr 16 16:16:23 2021
Received: from localhost ([127.0.0.1]:41761 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lXUt4-0002Xy-V9
	for submit <at> debbugs.gnu.org; Fri, 16 Apr 2021 16:16:23 -0400
Received: from mail-qv1-f45.google.com ([209.85.219.45]:36467)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <philip@HIDDEN>) id 1lXUt0-0002P6-7W
 for 47180 <at> debbugs.gnu.org; Fri, 16 Apr 2021 16:16:22 -0400
Received: by mail-qv1-f45.google.com with SMTP id i9so13889172qvo.3
 for <47180 <at> debbugs.gnu.org>; Fri, 16 Apr 2021 13:16:18 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=philipmcgrath.com; s=google;
 h=subject:to:cc:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=1cebKuR+FwSj+zb9myXg+ynbyGW85KLQw54p7yIfSfg=;
 b=PBB0Q/le4z14eyOoEIfJTytJCzLTZBp0Lq36lJmTGauwEUIU3Y4tPLsouHOetwxyvq
 h9HNSy14lS8cQitqB7gVwAT5wLoSlLQvbA4NW9GYoWJ8+2YWgYydcTW5trz7adi4F9x+
 VJIcs8BAFp1tc831TIt26VfJIPL1mSo/KrQA3LivtIKjWYAVixwp6UDyNnd67l2gZPAK
 iTOHGwuCFzJO1ZltTY65XW84pfxIxeqxCgtT9XWrXqtHuUgvQcV1zy1ZKeJeGIeqeIcY
 PHIgoR2ehG7ERLEhzE27PSwSJPS1XeX9PFJwx2I6EmEy/vEvJ9+HbNuAqiVGL+vfJI4a
 0Czg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:subject:to:cc:references:from:message-id:date
 :user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=1cebKuR+FwSj+zb9myXg+ynbyGW85KLQw54p7yIfSfg=;
 b=NRfzrAP6zsXZFT+rP9gVy2t6SQ9hnhUpffAGtyUWpNvuHX5cX6VBzIJEYgKay7URCJ
 TxsxL4VAcwfn6Xt+daBQCq/t+wmbyBN4SUZKKMUd2rI/0BMsyrK+d/7EnO2klUSvy7mR
 irouiKpi7+ZUY+b3LT+fF8Iigl7/JOjnANEBeMLOtN838OwvInPrDPe0IWJa9sV3wte2
 vww/Uq1MCGNmn9RrbOobrW4TDNZzUBIE0nRUDSOzyWINfNSa4yh+KQmgCrz8zNwLvwAe
 aYMWVnTkvf7T7ilg4NG+tv9gxXJhFTGsaU1yLYPvPuffSrKiLp9H/WvRQ4xpsQ37MdlB
 zj7Q==
X-Gm-Message-State: AOAM530mBRufPOf0Zfsu5VCVdnSK5cj3eSB3JtOMxpmm/cuurTXOufQq
 KeGlt1LlhS+SFYYUe1RThnikEbFpFx55aDwR6p0=
X-Google-Smtp-Source: ABdhPJwMHZX5YHb+tmxsYIBmaXxiO7Shy4ehyYXzshk2uVhvCM1TDiGwyMJ4cj8uxa/MlnZN5yBfNw==
X-Received: by 2002:a05:6214:12d3:: with SMTP id
 s19mr10530749qvv.26.1618604172745; 
 Fri, 16 Apr 2021 13:16:12 -0700 (PDT)
Received: from Sapientia.local (c-73-125-89-242.hsd1.fl.comcast.net.
 [73.125.89.242])
 by smtp.gmail.com with ESMTPSA id 198sm16117qkf.20.2021.04.16.13.16.11
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Fri, 16 Apr 2021 13:16:12 -0700 (PDT)
Subject: Re: bug#47180: [PATCH] gnu: racket: Don't inject store paths into
 Racket files.
To: =?UTF-8?Q?Ludovic_Court=c3=a8s?= <ludo@HIDDEN>
References: <20210316025632.9767-1-philip@HIDDEN>
 <87wnt9zwix.fsf@HIDDEN>
 <f56d2244-070f-69fb-9c20-dbb89ebd8cd6@HIDDEN>
 <877dl7psqc.fsf@HIDDEN>
From: Philip McGrath <philip@HIDDEN>
Message-ID: <397f0533-1be0-aab8-d3e5-fd81d59ae1ce@HIDDEN>
Date: Fri, 16 Apr 2021 16:16:04 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
 Gecko/20100101 Thunderbird/78.9.1
MIME-Version: 1.0
In-Reply-To: <877dl7psqc.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: 47180
Cc: jackhill@HIDDEN, 47180 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.3 (/)

Hi,

On 4/12/21 8:55 AM, Ludovic Courtès wrote:
> Philip McGrath <philip@HIDDEN> skribis:
>> Rather than using "config.rktd", an alternative approach would be to
>> set things up so that `dlopen` would find the foreign libraries,
>> perhaps via `LD_LIBRARY_PATH`. This has some intriguing possibilities:
>> I could imagine Guix providing an alternate `dlopen` implementation
>> that might be useful beyond Racket.
> 
> What would that alternate dlopen do?  It still has to know where to look
> for things, somehow.

This was a very fuzzy thought with a lot of reliance on "somehow"—I'm 
not certain it would actually make sense or even be possible—but what I 
had in mind is that `dlopen`, together with the dynamic linker and its 
various configuration and cache files, has some places it will search 
for shared libraries, e.g. in "/lib" and "/usr/lib". If 
`gnu-build-system` could somehow communicate with those mechanisms, then 
packages doing things like `dlopen("libm.so.6", RTLD_LAZY)` wouldn't 
need to have their source code rewritten to include store files: Guix 
would arrange for `dlopen` to find "libm.so.6" among the package inputs. 
Then Guix would only need to know how to graft whatever mechanism it 
used to configure things for `dlopen`, rather than having to worry about 
all of the strange things compilers might do with string literals.

But I don't have much of an idea of what "somehow" might be, and I'm not 
really a C hacker when I can avoid it :)

-Philip




Information forwarded to guix-patches@HIDDEN:
bug#47180; Package guix-patches. Full text available.

Message received at 47180-done <at> debbugs.gnu.org:


Received: (at 47180-done) by debbugs.gnu.org; 12 Apr 2021 16:49:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 12 12:49:03 2021
Received: from localhost ([127.0.0.1]:57918 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lVzkF-0004Ka-IF
	for submit <at> debbugs.gnu.org; Mon, 12 Apr 2021 12:49:03 -0400
Received: from eggs.gnu.org ([209.51.188.92]:46642)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1lVzkE-0004Jd-63
 for 47180-done <at> debbugs.gnu.org; Mon, 12 Apr 2021 12:49:02 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:58421)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <ludo@HIDDEN>)
 id 1lVzk5-0007bH-F6; Mon, 12 Apr 2021 12:48:56 -0400
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=49070 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1lVzk4-0004Ly-3T; Mon, 12 Apr 2021 12:48:53 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Philip McGrath <philip@HIDDEN>
Subject: Re: bug#47180: [PATCH] gnu: racket: Don't inject store paths into
 Racket files.
References: <alpine.DEB.2.21.2103162312040.8138@HIDDEN>
 <20210319023451.3405-1-philip@HIDDEN>
Date: Mon, 12 Apr 2021 18:48:50 +0200
In-Reply-To: <20210319023451.3405-1-philip@HIDDEN> (Philip
 McGrath's message of "Thu, 18 Mar 2021 22:34:51 -0400")
Message-ID: <87eeffo3d9.fsf_-_@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 47180-done
Cc: 47180-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Philip McGrath <philip@HIDDEN> skribis:

> Apparently, during grafting, Guix can somehow mangle compiled
> Racket CS files (.zo) such that Racket will refuse to load them.
> (Maybe it has something to do with compression?)
> So, we stop patching Racket sources with absolute paths to store
> files (i.e. for foreign libraries to dlopen).
> Instead, we put them in a data file that doesn't get compiled or,
> in one case, embed it in C.
>
> Fixes https://issues.guix.gnu.org/47064
>
> * gnu/packages/patches/racket-sh-via-rktio.patch: New file.
> Adds a special case at the C level, controlled by a preprocessor macro,
> to handle attempts to execute "/bin/sh".
> * gnu/local.mk (dist_patch_DATA): Add it.
> * gnu/packages/scheme.scm (racket)[source](patches): Apply it.
> (racket)[arguments](#:configure-flags): Add the CPP flag to enable it.
> (racket)[arguments](#:modules): Use srfi-1.
> (racket)[arguments](#:phases): Remove 'patch-/bin/sh and 'pre-configure.
> Change 'pre-configure-minimal to just change directory.
> Add 'patch-config.rktd-lib-search-dirs after 'build and before 'install
> to configure Racket's "lib-search-dirs".
> (racket, racket-minimal)[inputs]: Add bash-minimal as an explicit input.
> (racket-minimal)[source]: Adjust to inherit patches from racket.
> (racket-minimal)[arguments]: Inherit from racket: changes no longer neede=
d.
> ---
>  gnu/local.mk                                  |   2 +
>  .../patches/racket-sh-via-rktio.patch         |  87 ++++++++
>  gnu/packages/scheme.scm                       | 191 ++++++++----------
>  3 files changed, 176 insertions(+), 104 deletions(-)
>  create mode 100644 gnu/packages/patches/racket-sh-via-rktio.patch

Pushed as 834aa48504a24f0c79e858fc295edbf63815a408.

Thanks!

Ludo=E2=80=99.




Notification sent to Philip McGrath <philip@HIDDEN>:
bug acknowledged by developer. Full text available.
Reply sent to Ludovic Courtès <ludo@HIDDEN>:
You have taken responsibility. Full text available.

Message received at 47180 <at> debbugs.gnu.org:


Received: (at 47180) by debbugs.gnu.org; 12 Apr 2021 12:55:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 12 08:55:55 2021
Received: from localhost ([127.0.0.1]:56824 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lVw6c-0006Nt-EH
	for submit <at> debbugs.gnu.org; Mon, 12 Apr 2021 08:55:54 -0400
Received: from eggs.gnu.org ([209.51.188.92]:60338)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1lVw6Y-0006NO-AP
 for 47180 <at> debbugs.gnu.org; Mon, 12 Apr 2021 08:55:50 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:53861)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <ludo@HIDDEN>)
 id 1lVw6T-0000Zu-2W; Mon, 12 Apr 2021 08:55:45 -0400
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=48060 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1lVw6P-0007Pl-5a; Mon, 12 Apr 2021 08:55:42 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Philip McGrath <philip@HIDDEN>
Subject: Re: bug#47180: [PATCH] gnu: racket: Don't inject store paths into
 Racket files.
In-Reply-To: <f56d2244-070f-69fb-9c20-dbb89ebd8cd6@HIDDEN> (Philip
 McGrath's message of "Sun, 11 Apr 2021 23:40:59 -0400")
References: <20210316025632.9767-1-philip@HIDDEN>
 <87wnt9zwix.fsf@HIDDEN>
 <f56d2244-070f-69fb-9c20-dbb89ebd8cd6@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 23 Germinal an 229 de la =?utf-8?Q?R=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Mon, 12 Apr 2021 14:55:39 +0200
Message-ID: <877dl7psqc.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 47180
Cc: jackhill@HIDDEN, 47180 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Hi Philip,

Philip McGrath <philip@HIDDEN> skribis:

> So there seem to be at least three bad cases:
>
>  1. The grafter can mangle .zo files so that Racket can't
>     read them at all.
>  2. The grafter can miss store references in .zo files, so Racket could
>     end up using the ungrafted versions.
>  3. With a garbage collection, Racket could try to use the ungrafted
>     versions but fail to find them at runtime.

Yes, similar to the problems observed with SBCL:

  https://issues.guix.gnu.org/33848

>> Would it be an option to instead turn off compression and keep doing
>> things as usual?
>
> In theory, this should be possible. I see two significant downsides:
>
>  1. Compiled code would be much larger=E2=80=94maybe twice as big=E2=80=
=94and, if I
>     recall correctly, load times would be worse, too. With the move to
>     Racket CS, existing Racket code moved from a world of small and
>     cheap bytecode to a world of machine code: the default compression
>     settings have been tuned to avoid an unacceptable worsening of
>     binary size and load time.

Interesting (I=E2=80=99m curious how load time can be improved by (1) readi=
ng
files in memory instead of merely mmap=E2=80=99ing, and (2) decompressing.)

[...]

> More broadly, I think the best strategy for Racket packaging will be,
> as much as possible, to use Racket's supported configuration features=20
> rather than Guix-specific hacks. This seems especially viable since
> Racket has been willing to accept unobtrusive patches upstream that
> help things go smoothly for Guix, e.g. with 8.1 we should no longer
> need any patches to the build scripts: we're all friendly,
> parentheses-loving folks.

That makes sense to me, I=E2=80=99m all for uniting with parentheses-loving
folks of the world.  :-)

> For another example, it looks like existing
> "racket-store-checksum-override.patch" fixes a previous issue
> discussed in <https://issues.guix.gnu.org/30680> caused by grafting zo
> files: I hope this change will also let us remove that patch, though
> I'd want to test more before proposing we drop it. So these problems
> aren't fundamentally new; they just have an additional symptom since
> the change to Racket CS by default in Racket 8.0. If we can fix the
> root problem of violating Racket's assumptions by patching zo files,
> we should be able to stop hunting down symptoms.

OK.

I=E2=80=99m testing v2 of the patch and will push shortly if everything goes
well.

> Rather than using "config.rktd", an alternative approach would be to
> set things up so that `dlopen` would find the foreign libraries,
> perhaps via `LD_LIBRARY_PATH`. This has some intriguing possibilities:
> I could imagine Guix providing an alternate `dlopen` implementation
> that might be useful beyond Racket.

What would that alternate dlopen do?  It still has to know where to look
for things, somehow.

> Nix apparently configures some things via `LD_LIBRARY_PATH`, but their
> approach (as I understand it) relies on generating Racket scripts
> around all Racket-generated executable, which causes other
> problems. There should be workarounds, but it seems better to avoid
> going down that road if we can.

Yeah, as a rule of thumb I=E2=80=99d say: don=E2=80=99t fiddle with LD_LIBR=
ARY_PATH.

> Finally, here's a sketch of how `guix import racket` and such might
> work. Racket's package system has a concept of "package scope", so
> that "installation" scope can coexist with narrower scopes (mostly
> per-user scope, though there are more complex possibilities). Right
> now, Guix puts installation scope in the read-only store, which
> basically corresponds to how other package managers put it in
> root-owned places, except Guix can't write to the store to install
> additional packages. I'm still at the information-gathering stage, but
> my current thinking is that the hypothetical `racket-build-system`
> should basically take the source package and turn it into what Racket
> calls a "built" package ready to be installed in `static-link` mode,
> which includes compiling the code and building the docs (which can
> involve quite a lot, e.g. ray tracing icons). Then a profile hook
> could knit together all of the Racket packages into an installation
> package scope. For packages that depend on foreign libraries, this
> would be a chance for Guix to add the necessary paths to the
> "config.rktd" for the installation.

I=E2=80=99m not sure I follow the details and I=E2=80=99m glad you have a p=
lan.
Finally having a Racket importer would be sweet!

Thanks!

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#47180; Package guix-patches. Full text available.

Message received at 47180 <at> debbugs.gnu.org:


Received: (at 47180) by debbugs.gnu.org; 12 Apr 2021 12:55:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Apr 12 08:55:51 2021
Received: from localhost ([127.0.0.1]:56822 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lVw6Y-0006Na-Ib
	for submit <at> debbugs.gnu.org; Mon, 12 Apr 2021 08:55:51 -0400
Received: from eggs.gnu.org ([209.51.188.92]:60326)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1lVw6W-0006NL-W7
 for 47180 <at> debbugs.gnu.org; Mon, 12 Apr 2021 08:55:49 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:53860)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <ludo@HIDDEN>)
 id 1lVw6R-0000YW-CK; Mon, 12 Apr 2021 08:55:43 -0400
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=48058 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1lVw5s-0007Jm-2a; Mon, 12 Apr 2021 08:55:27 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Philip McGrath <philip@HIDDEN>
Subject: Re: bug#47180: [PATCH] gnu: racket: Don't inject store paths into
 Racket files.
References: <20210316025632.9767-1-philip@HIDDEN>
 <87wnt9zwix.fsf@HIDDEN>
 <f56d2244-070f-69fb-9c20-dbb89ebd8cd6@HIDDEN>
X-URL: http://www.fdn.fr/~lcourtes/
X-Revolutionary-Date: 23 Germinal an 229 de la =?utf-8?Q?R=C3=A9volution?=
X-PGP-Key-ID: 0x090B11993D9AEBB5
X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc
X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4  0CFB 090B 1199 3D9A EBB5
X-OS: x86_64-pc-linux-gnu
Date: Mon, 12 Apr 2021 14:55:06 +0200
In-Reply-To: <f56d2244-070f-69fb-9c20-dbb89ebd8cd6@HIDDEN> (Philip
 McGrath's message of "Sun, 11 Apr 2021 23:40:59 -0400")
Message-ID: <878s5npsr9.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 47180
Cc: jackhill@HIDDEN, 47180 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Hi Philip,

Philip McGrath <philip@HIDDEN> skribis:

> So there seem to be at least three bad cases:
>
>  1. The grafter can mangle .zo files so that Racket can't
>     read them at all.
>  2. The grafter can miss store references in .zo files, so Racket could
>     end up using the ungrafted versions.
>  3. With a garbage collection, Racket could try to use the ungrafted
>     versions but fail to find them at runtime.

Yes, similar to the problems observed with SBCL:

  https://issues.guix.gnu.org/33848

>> Would it be an option to instead turn off compression and keep doing
>> things as usual?
>
> In theory, this should be possible. I see two significant downsides:
>
>  1. Compiled code would be much larger=E2=80=94maybe twice as big=E2=80=
=94and, if I
>     recall correctly, load times would be worse, too. With the move to
>     Racket CS, existing Racket code moved from a world of small and
>     cheap bytecode to a world of machine code: the default compression
>     settings have been tuned to avoid an unacceptable worsening of
>     binary size and load time.

Interesting (I=E2=80=99m curious how load time can be improved by (1) readi=
ng
files in memory instead of merely mmap=E2=80=99ing, and (2) decompressing.)

[...]

> More broadly, I think the best strategy for Racket packaging will be,
> as much as possible, to use Racket's supported configuration features=20
> rather than Guix-specific hacks. This seems especially viable since
> Racket has been willing to accept unobtrusive patches upstream that
> help things go smoothly for Guix, e.g. with 8.1 we should no longer
> need any patches to the build scripts: we're all friendly,
> parentheses-loving folks.

That makes sense to me, I=E2=80=99m all for uniting with parentheses-loving
folks of the world.  :-)

> For another example, it looks like existing
> "racket-store-checksum-override.patch" fixes a previous issue
> discussed in <https://issues.guix.gnu.org/30680> caused by grafting zo
> files: I hope this change will also let us remove that patch, though
> I'd want to test more before proposing we drop it. So these problems
> aren't fundamentally new; they just have an additional symptom since
> the change to Racket CS by default in Racket 8.0. If we can fix the
> root problem of violating Racket's assumptions by patching zo files,
> we should be able to stop hunting down symptoms.

OK.

I=E2=80=99m testing v2 of the patch and will push shortly if everything goes
well.

> Rather than using "config.rktd", an alternative approach would be to
> set things up so that `dlopen` would find the foreign libraries,
> perhaps via `LD_LIBRARY_PATH`. This has some intriguing possibilities:
> I could imagine Guix providing an alternate `dlopen` implementation
> that might be useful beyond Racket.

What would that alternate dlopen do?  It still has to know where to look
for things, somehow.

> Nix apparently configures some things via `LD_LIBRARY_PATH`, but their
> approach (as I understand it) relies on generating Racket scripts
> around all Racket-generated executable, which causes other
> problems. There should be workarounds, but it seems better to avoid
> going down that road if we can.

Yeah, as a rule of thumb I=E2=80=99d say: don=E2=80=99t fiddle with LD_LIBR=
ARY_PATH.

> Finally, here's a sketch of how `guix import racket` and such might
> work. Racket's package system has a concept of "package scope", so
> that "installation" scope can coexist with narrower scopes (mostly
> per-user scope, though there are more complex possibilities). Right
> now, Guix puts installation scope in the read-only store, which
> basically corresponds to how other package managers put it in
> root-owned places, except Guix can't write to the store to install
> additional packages. I'm still at the information-gathering stage, but
> my current thinking is that the hypothetical `racket-build-system`
> should basically take the source package and turn it into what Racket
> calls a "built" package ready to be installed in `static-link` mode,
> which includes compiling the code and building the docs (which can
> involve quite a lot, e.g. ray tracing icons). Then a profile hook
> could knit together all of the Racket packages into an installation
> package scope. For packages that depend on foreign libraries, this
> would be a chance for Guix to add the necessary paths to the
> "config.rktd" for the installation.

I=E2=80=99m not sure I follow the details and I=E2=80=99m glad you have a p=
lan.
Finally having a Racket importer would be sweet!

Thanks!

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#47180; Package guix-patches. Full text available.

Message received at 47180 <at> debbugs.gnu.org:


Received: (at 47180) by debbugs.gnu.org; 12 Apr 2021 03:41:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Apr 11 23:41:09 2021
Received: from localhost ([127.0.0.1]:56147 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lVnRl-0002Qf-2Q
	for submit <at> debbugs.gnu.org; Sun, 11 Apr 2021 23:41:09 -0400
Received: from mail-qt1-f177.google.com ([209.85.160.177]:38414)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <philip@HIDDEN>) id 1lVnRj-0002QT-CQ
 for 47180 <at> debbugs.gnu.org; Sun, 11 Apr 2021 23:41:07 -0400
Received: by mail-qt1-f177.google.com with SMTP id j7so8938304qtx.5
 for <47180 <at> debbugs.gnu.org>; Sun, 11 Apr 2021 20:41:07 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=philipmcgrath.com; s=google;
 h=subject:to:cc:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=HDFDY3FmSQl/uLFZNSpJJzBH7fwGtbjjAmhaNNkZtzY=;
 b=j36APpVEpXbghDphT19yWRQ91ttFlw277sRGMrN5MfZX5GBMacwUJg4s58IYwMjy67
 Bl/g/wr93cqTC+3frqfh8sGXlTCLcGv+jsyKXiSz6bhlhOEeHEQq1J/EeUmOi57TqnXn
 7vckicV1RjA+iof0c+LrxjgJvNnS6QaPwEiseGC9V0ZAE4sIZKQ8i5hhrOC8Ur948sV/
 GST/mZEO3EN81EZpmcwkTNNe07/i0nl2GCiM9I7011cGJYAwRdsBGH220TOGnFICXFmZ
 JK+JvQX19DAL39IfvWpQAnY9LdoWpXRdECztXavWLiu45nQJp0f0nf+hk2Lb/l7QkgSY
 e2vQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:subject:to:cc:references:from:message-id:date
 :user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=HDFDY3FmSQl/uLFZNSpJJzBH7fwGtbjjAmhaNNkZtzY=;
 b=mo7oavwxIkRWM/hWwnqGx5RjUB66zgDbQp95va1w+F7U85W9LLCTSjEIQOfwv9fUHx
 +/bUoSx+kA60bZu2yDBCqovWSB/YVwMR6ODxAM6Ou8x//7+MGRE7b1GCMROwaV8HSCw6
 8IJh9a3Xho2yxjtRHpcG+ScUeWZWYHSjLUwQQtmRK3DVk3VtH337IdbkHVHITLCRYfZ4
 CztZvAH7t31vQwRWGVi54+kHtp1ULtsb+PUyFnB68ftn6hB6JPyebEjPxQPnCIRR3gD6
 mygPtAQPaV3uT+bOFDjbFeBc0XOaR4xLjeFvjnC2B33ugGCqhfGkfCDCsNQXS6CPL4pe
 /16Q==
X-Gm-Message-State: AOAM532+zxdo2HOFFwiNO4B4JC/qxNmLPeRurcaRTUaZ1ihzLn/0FAQt
 Pr7o00IVQ1+MOqQWTKSbVM5hMS4RWY6Cb73JyyA=
X-Google-Smtp-Source: ABdhPJzaX/AYaw0lA1szgwUMOth9qXKvNsmOkS30RJlYSWryMPJKVKeKanBbYzFQBrZj0LtfiQwCvA==
X-Received: by 2002:a05:622a:253:: with SMTP id
 c19mr23594462qtx.355.1618198861676; 
 Sun, 11 Apr 2021 20:41:01 -0700 (PDT)
Received: from Sapientia.local (c-73-125-89-242.hsd1.fl.comcast.net.
 [73.125.89.242])
 by smtp.gmail.com with ESMTPSA id y9sm6994653qtf.58.2021.04.11.20.41.00
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Sun, 11 Apr 2021 20:41:01 -0700 (PDT)
Subject: Re: bug#47180: [PATCH] gnu: racket: Don't inject store paths into
 Racket files.
To: =?UTF-8?Q?Ludovic_Court=c3=a8s?= <ludo@HIDDEN>
References: <20210316025632.9767-1-philip@HIDDEN>
 <87wnt9zwix.fsf@HIDDEN>
From: Philip McGrath <philip@HIDDEN>
Message-ID: <f56d2244-070f-69fb-9c20-dbb89ebd8cd6@HIDDEN>
Date: Sun, 11 Apr 2021 23:40:59 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
 Gecko/20100101 Thunderbird/78.9.0
MIME-Version: 1.0
In-Reply-To: <87wnt9zwix.fsf@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.6 (/)
X-Debbugs-Envelope-To: 47180
Cc: jackhill@HIDDEN, 47180 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.4 (/)

Hi!

On 4/10/21 4:59 PM, Ludovic Courtès wrote:
> Hi Philip,
> 
> Philip McGrath <philip@HIDDEN> skribis:
> 
>> Apparently, during grafting, Guix can somehow mangle compiled
>> Racket CS files (.zo) such that Racket will refuse to load them.
>> (Maybe it has something to do with compression?)
> 
> If those files are compressed, and if a store file name survives despite
> compression, then grafting can patch it, which could lead to checksum
> mismatches or similar.

Yes, that's what seems to be happening.

> 
> What error message does Racket produce?

The first error I heard of (and reproduced) was reported by Jack in 
<https://issues.guix.gnu.org/47064>:

```
$bytevector-uncompress: internal error uncompressing 
#"\0\0\0\0chez\310\224\206:\r()#\201\256R-d\205\233\24\363\5\20\201P\6A\v\300\0\16\f\6\31\2\f\6\f&H\275\0\1\0\362\bA\377e\0\1\0C\6A\21\3\v\300\0\201\265!\f\6\n\0\a\1\35\0\1+\0\360\27\201\375\300\0\0\0\17\205\210Z\0\0M\215\245\b\4\0\0M9fH\17\206fZ\0\0I\2...
    context...:
     body of 
"/gnu/store/mmrax3f1vx3c8ih9hhgffpvka6chk96w-racket-8.0/share/racket/pkgs/gui-lib/mred/private/wx/gtk/utils.rkt"
     body of 
"/gnu/store/mmrax3f1vx3c8ih9hhgffpvka6chk96w-racket-8.0/share/racket/pkgs/gui-lib/mred/private/wx/platform.rkt"
```

The error message is referring to an internal Chez Scheme primitive.

The report at <https://issues.guix.gnu.org/47614> seems to me to be an 
alternative manifestation of the same problem: the hexdump there is 
useful and explains why I did see some of the store path when I had 
attempted to investigate using `strings`.

So there seem to be at least three bad cases:

  1. The grafter can mangle .zo files so that Racket can't
     read them at all.
  2. The grafter can miss store references in .zo files, so Racket could
     end up using the ungrafted versions.
  3. With a garbage collection, Racket could try to use the ungrafted
     versions but fail to find them at runtime.

>> So, we stop patching Racket sources with absolute paths to store
>> files (i.e. for foreign libraries to dlopen).
>> Instead, we put them in a data file that doesn't get compiled or,
>> in one case, embed it in C.
> 
> That solves the problem for Racket itself, but wouln’t Racket libraries
> have the same issue?

Because the problems are triggered by grafting, they only affect 
packages that have been patched by Guix. For now, Guix doesn't have the 
ability to install more Racket packages. In the longer term, the 
one-sentence answer is that it's always possible we might find and 
switch to a better approach, but this seems most promising. (A bit more 
of my current thinking on that toward the end.)

> Would it be an option to instead turn off compression and keep doing
> things as usual?

In theory, this should be possible. I see two significant downsides:

  1. Compiled code would be much larger—maybe twice as big—and, if I
     recall correctly, load times would be worse, too. With the move to
     Racket CS, existing Racket code moved from a world of small and
     cheap bytecode to a world of machine code: the default compression
     settings have been tuned to avoid an unacceptable worsening of
     binary size and load time.
  2. Racket very intentionally does not specify the format of zo files,
     and indeed the details routinely change: I think there have now 
been
     14 such changes on Git since the 8.0 release in February. Continuing
     to patch zo files sets us up for future breakage, and it seems like
     it would be especially easy for maintainers of the Guix package to
     miss the implications of such changes to low-level implementation
     details (as I did!). For example, Chez Scheme seems to make
     compression options programmer-configurable even within a single
     object file: if Racket exposed such options, we could well end up
     here again.

More broadly, I think the best strategy for Racket packaging will be, as 
much as possible, to use Racket's supported configuration features 
rather than Guix-specific hacks. This seems especially viable since 
Racket has been willing to accept unobtrusive patches upstream that help 
things go smoothly for Guix, e.g. with 8.1 we should no longer need any 
patches to the build scripts: we're all friendly, parentheses-loving folks.

For another example, it looks like existing 
"racket-store-checksum-override.patch" fixes a previous issue discussed 
in <https://issues.guix.gnu.org/30680> caused by grafting zo files: I 
hope this change will also let us remove that patch, though I'd want to 
test more before proposing we drop it. So these problems aren't 
fundamentally new; they just have an additional symptom since the change 
to Racket CS by default in Racket 8.0. If we can fix the root problem of 
violating Racket's assumptions by patching zo files, we should be able 
to stop hunting down symptoms.

Rather than using "config.rktd", an alternative approach would be to set 
things up so that `dlopen` would find the foreign libraries, perhaps via 
`LD_LIBRARY_PATH`. This has some intriguing possibilities: I could 
imagine Guix providing an alternate `dlopen` implementation that might 
be useful beyond Racket.

Nix apparently configures some things via `LD_LIBRARY_PATH`, but their 
approach (as I understand it) relies on generating Racket scripts around 
all Racket-generated executable, which causes other problems. There 
should be workarounds, but it seems better to avoid going down that road 
if we can.

Finally, here's a sketch of how `guix import racket` and such might 
work. Racket's package system has a concept of "package scope", so that 
"installation" scope can coexist with narrower scopes (mostly per-user 
scope, though there are more complex possibilities). Right now, Guix 
puts installation scope in the read-only store, which basically 
corresponds to how other package managers put it in root-owned places, 
except Guix can't write to the store to install additional packages. I'm 
still at the information-gathering stage, but my current thinking is 
that the hypothetical `racket-build-system` should basically take the 
source package and turn it into what Racket calls a "built" package 
ready to be installed in `static-link` mode, which includes compiling 
the code and building the docs (which can involve quite a lot, e.g. ray 
tracing icons). Then a profile hook could knit together all of the 
Racket packages into an installation package scope. For packages that 
depend on foreign libraries, this would be a chance for Guix to add the 
necessary paths to the "config.rktd" for the installation.

-Philip




Information forwarded to guix-patches@HIDDEN:
bug#47180; Package guix-patches. Full text available.

Message received at 47180 <at> debbugs.gnu.org:


Received: (at 47180) by debbugs.gnu.org; 10 Apr 2021 20:59:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Apr 10 16:59:15 2021
Received: from localhost ([127.0.0.1]:53434 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lVKhH-0002vO-IJ
	for submit <at> debbugs.gnu.org; Sat, 10 Apr 2021 16:59:15 -0400
Received: from eggs.gnu.org ([209.51.188.92]:48022)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1lVKhG-0002vD-BT
 for 47180 <at> debbugs.gnu.org; Sat, 10 Apr 2021 16:59:14 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:50861)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <ludo@HIDDEN>)
 id 1lVKhA-00062s-O2; Sat, 10 Apr 2021 16:59:08 -0400
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=42176 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <ludo@HIDDEN>)
 id 1lVKh5-0007Ti-Ux; Sat, 10 Apr 2021 16:59:04 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Philip McGrath <philip@HIDDEN>
Subject: Re: bug#47180: [PATCH] gnu: racket: Don't inject store paths into
 Racket files.
References: <20210316025632.9767-1-philip@HIDDEN>
Date: Sat, 10 Apr 2021 22:59:02 +0200
In-Reply-To: <20210316025632.9767-1-philip@HIDDEN> (Philip
 McGrath's message of "Mon, 15 Mar 2021 22:56:32 -0400")
Message-ID: <87wnt9zwix.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 47180
Cc: jackhill@HIDDEN, 47180 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Hi Philip,

Philip McGrath <philip@HIDDEN> skribis:

> Apparently, during grafting, Guix can somehow mangle compiled
> Racket CS files (.zo) such that Racket will refuse to load them.
> (Maybe it has something to do with compression?)

If those files are compressed, and if a store file name survives despite
compression, then grafting can patch it, which could lead to checksum
mismatches or similar.

What error message does Racket produce?

> So, we stop patching Racket sources with absolute paths to store
> files (i.e. for foreign libraries to dlopen).
> Instead, we put them in a data file that doesn't get compiled or,
> in one case, embed it in C.

That solves the problem for Racket itself, but wouln=E2=80=99t Racket libra=
ries
have the same issue?

Would it be an option to instead turn off compression and keep doing
things as usual?

Thanks for looking into it, and sorry for the delay!

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#47180; Package guix-patches. Full text available.

Message received at 47180 <at> debbugs.gnu.org:


Received: (at 47180) by debbugs.gnu.org; 19 Mar 2021 02:35:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Mar 18 22:35:39 2021
Received: from localhost ([127.0.0.1]:48378 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lN4z4-0005Hf-7d
	for submit <at> debbugs.gnu.org; Thu, 18 Mar 2021 22:35:39 -0400
Received: from mail-qv1-f49.google.com ([209.85.219.49]:40569)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <philip@HIDDEN>) id 1lN4z2-0005HQ-2g
 for 47180 <at> debbugs.gnu.org; Thu, 18 Mar 2021 22:35:29 -0400
Received: by mail-qv1-f49.google.com with SMTP id d10so4324040qve.7
 for <47180 <at> debbugs.gnu.org>; Thu, 18 Mar 2021 19:35:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=philipmcgrath.com; s=google;
 h=from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding;
 bh=l+CTx4EBN+cz7gOieTPAqPlOS1Tjl4YDp92ygVUhoog=;
 b=JX+58dKoBU5oIvVotwTODQvy/KVvu9BYp2fLlh0+5H2BCMZV/0rPg3roHG1R9m5dTg
 dqhdV2FGxhhE62KZOlWB0RryDa8WGBghKnTHS1W11/4i7r0qwkEQ0Yv+wjaSm2vM8tyZ
 i+o3+krtqa3sAutWR9TCYMKDpBY8tcRRgvlwhjJeqQLJBPVyHciHg/KkAfMPXMM9fPJq
 Hrs6yNw1hSh+KhN42hkBKnLEFJu9MMvqAhDfJlSX++V/ikuZ9JLZGMwI7yn1ZTrBXhgN
 4Dh9SKYCJWY+bh6xBg1/vU1UaVEjA0M6138I4YPfbxp7690kdc1In7BIxwYMP2BspJwQ
 J1Lg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=l+CTx4EBN+cz7gOieTPAqPlOS1Tjl4YDp92ygVUhoog=;
 b=mwsafZDlaU2COB7OyLYvVwunSbhHe7mZayK3HJvyRCZU0Q5ALBVPQHrfq5w3yNeS/W
 tsc9i5DJ+V9wE/kxlSLhfbaZnm5OoSdH3sETt0z12KOhW4JKIo5fXh9bty5EQqPopJLO
 P9n9uYzMuT4QLHkqOvwiss9HZSlX+74CL6n/m5Q23nYkLYVAegoFSPfHAvfYrLRKu55r
 t2Mkejns3B9PYnLoQNkjjDHR7fwPDSgQr8bSJps2YorWDpRa2MN8qCBXKMT3hZNOrsTh
 Nzg8HHRcKPN3G/E6vyuhYT5Q6LidGkp55iKGfKUIRC/mx0nf9hrpHxUL2f1mDH54fTAH
 iJuQ==
X-Gm-Message-State: AOAM530LBdVsMk7iLSt40Zwnr+B9ceqnRunPR21Oqlhv0xKo2u+8Q6DV
 PsvuPvMCPlP/AR9RFf68du3/1YTRARUc+OvK9zY=
X-Google-Smtp-Source: ABdhPJyXQFSU0Vv0qJFuef9bvwYApCiYRcPntY6fwB17JBfJS8vORt7+4Daj9Td2VfB46N+PjwDnbw==
X-Received: by 2002:a05:6214:80a:: with SMTP id
 df10mr7444270qvb.46.1616121321851; 
 Thu, 18 Mar 2021 19:35:21 -0700 (PDT)
Received: from localhost (c-73-125-89-242.hsd1.fl.comcast.net. [73.125.89.242])
 by smtp.gmail.com with ESMTPSA id r17sm2764838qtn.25.2021.03.18.19.35.21
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Thu, 18 Mar 2021 19:35:21 -0700 (PDT)
From: Philip McGrath <philip@HIDDEN>
To: 47180 <at> debbugs.gnu.org
Subject: [PATCH v2] gnu: racket: Don't inject store paths into Racket files.
Date: Thu, 18 Mar 2021 22:34:51 -0400
Message-Id: <20210319023451.3405-1-philip@HIDDEN>
X-Mailer: git-send-email 2.21.1 (Apple Git-122.3)
In-Reply-To: <alpine.DEB.2.21.2103162312040.8138@HIDDEN>
References: <alpine.DEB.2.21.2103162312040.8138@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 2.7 (++)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  Apparently, during grafting, Guix can somehow mangle compiled
 Racket CS files (.zo) such that Racket will refuse to load them. (Maybe it
 has something to do with compression?) So, we stop patching Rac [...] 
 Content analysis details:   (2.7 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -0.0 RCVD_IN_DNSWL_NONE     RBL: Sender listed at https://www.dnswl.org/,
 no trust [209.85.219.49 listed in list.dnswl.org]
 2.0 PDS_OTHER_BAD_TLD      Untrustworthy TLDs
 [URI: ambrevar.xyz (xyz)]
 0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
 0.7 SPF_NEUTRAL            SPF: sender does not match SPF record (neutral)
 -0.0 RCVD_IN_MSPIKE_H2      RBL: Average reputation (+2)
 [209.85.219.49 listed in wl.mailspike.net]
X-Debbugs-Envelope-To: 47180
Cc: Philip McGrath <philip@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 1.7 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 
 Content preview:  Apparently, during grafting, Guix can somehow mangle compiled
    Racket CS files (.zo) such that Racket will refuse to load them. (Maybe it
    has something to do with compression?) So, we stop patching Rac [...] 
 
 Content analysis details:   (1.7 points, 10.0 required)
 
  pts rule name              description
 ---- ---------------------- --------------------------------------------------
  2.0 PDS_OTHER_BAD_TLD      Untrustworthy TLDs
                             [URI: ambrevar.xyz (xyz)]
  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record
  0.7 SPF_NEUTRAL            SPF: sender does not match SPF record (neutral)
 -1.0 MAILING_LIST_MULTI     Multiple indicators imply a widely-seen list
                             manager

Apparently, during grafting, Guix can somehow mangle compiled
Racket CS files (.zo) such that Racket will refuse to load them.
(Maybe it has something to do with compression?)
So, we stop patching Racket sources with absolute paths to store
files (i.e. for foreign libraries to dlopen).
Instead, we put them in a data file that doesn't get compiled or,
in one case, embed it in C.

Fixes https://issues.guix.gnu.org/47064

* gnu/packages/patches/racket-sh-via-rktio.patch: New file.
Adds a special case at the C level, controlled by a preprocessor macro,
to handle attempts to execute "/bin/sh".
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/scheme.scm (racket)[source](patches): Apply it.
(racket)[arguments](#:configure-flags): Add the CPP flag to enable it.
(racket)[arguments](#:modules): Use srfi-1.
(racket)[arguments](#:phases): Remove 'patch-/bin/sh and 'pre-configure.
Change 'pre-configure-minimal to just change directory.
Add 'patch-config.rktd-lib-search-dirs after 'build and before 'install
to configure Racket's "lib-search-dirs".
(racket, racket-minimal)[inputs]: Add bash-minimal as an explicit input.
(racket-minimal)[source]: Adjust to inherit patches from racket.
(racket-minimal)[arguments]: Inherit from racket: changes no longer needed.
---
 gnu/local.mk                                  |   2 +
 .../patches/racket-sh-via-rktio.patch         |  87 ++++++++
 gnu/packages/scheme.scm                       | 191 ++++++++----------
 3 files changed, 176 insertions(+), 104 deletions(-)
 create mode 100644 gnu/packages/patches/racket-sh-via-rktio.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index afd9c17f9c..1128dbd080 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -40,6 +40,7 @@
 # Copyright © 2020 Malte Frank Gerdes <mate.f.gerdes@HIDDEN>
 # Copyright © 2020 Vinicius Monego <monego@HIDDEN>
 # Copyright © 2021 Björn Höfling <bjoern.hoefling@HIDDEN>
+# Copyright © 2021 Philip McGrath <philip@HIDDEN>
 #
 # This file is part of GNU Guix.
 #
@@ -1629,6 +1630,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/ripperx-missing-file.patch		\
   %D%/packages/patches/rpcbind-CVE-2017-8779.patch		\
   %D%/packages/patches/rtags-separate-rct.patch			\
+  %D%/packages/patches/racket-sh-via-rktio.patch		\
   %D%/packages/patches/racket-store-checksum-override.patch	\
   %D%/packages/patches/remake-impure-dirs.patch			\
   %D%/packages/patches/retroarch-LIBRETRO_DIRECTORY.patch	\
diff --git a/gnu/packages/patches/racket-sh-via-rktio.patch b/gnu/packages/patches/racket-sh-via-rktio.patch
new file mode 100644
index 0000000000..b4fefd1514
--- /dev/null
+++ b/gnu/packages/patches/racket-sh-via-rktio.patch
@@ -0,0 +1,87 @@
+From 3574b567c486d264d680a37586436c3b5a8cb978 Mon Sep 17 00:00:00 2001
+From: Philip McGrath <philip@HIDDEN>
+Date: Thu, 4 Mar 2021 04:11:50 -0500
+Subject: [PATCH] patch rktio_process for "/bin/sh" on Guix
+
+Racket provides the functions `system` and `process`,
+which execute shell commands using `sh` (or `cmd` on Windows).
+Racket assumes that `sh` can be found at "/bin/sh",
+which is not necessarily true on Guix.
+
+This patch adds a special case for "/bin/sh" to `rktio_process`,
+the C function that implements the core of `system`, `process`,
+and related Racket functions.
+
+Guix should enable the special case by defining the C preprocessor
+macro `GUIX_RKTIO_PATCH_BIN_SH` with the path to `sh` in the store.
+If:
+
+    1. The `GUIX_RKTIO_PATCH_BIN_SH` macro is defined; and
+
+    2. `rktio_process` is called with the exact path "/bin/sh"; and
+
+    3. The path specified by `GUIX_RKTIO_PATCH_BIN_SH` does exists;
+
+then `rktio_process` will execute the file specified
+by `GUIX_RKTIO_PATCH_BIN_SH` instead of "/bin/sh".
+
+Compared to previous attempts to patch the Racket sources,
+making this change at the C level is both:
+
+    - More comprehensive: it catches all attempts to execute "/bin/sh",
+      without having to track down the source of every occurance; and
+
+    - Less intrusive: by guarding the special case with a C preprocessor
+      conditional and a runtime check that the file in the store exists,
+      we make it much less likely that it will "leak" out of Guix.
+---
+ src/rktio/rktio_process.c | 21 ++++++++++++++++++++-
+ 1 file changed, 20 insertions(+), 1 deletion(-)
+
+diff --git a/src/rktio/rktio_process.c b/src/rktio/rktio_process.c
+index 89202436c0..465ebdd5c5 100644
+--- a/src/rktio/rktio_process.c
++++ b/src/rktio/rktio_process.c
+@@ -1224,12 +1224,14 @@ int rktio_process_allowed_flags(rktio_t *rktio)
+ /*========================================================================*/
+ 
+ rktio_process_result_t *rktio_process(rktio_t *rktio,
+-                                      const char *command, int argc, rktio_const_string_t *argv,
++                                      /* PATCHED for Guix (next line) */
++                                      const char *_guix_orig_command, int argc, rktio_const_string_t *argv,
+                                       rktio_fd_t *stdout_fd, rktio_fd_t *stdin_fd, rktio_fd_t *stderr_fd,
+                                       rktio_process_t *group_proc,
+                                       const char *current_directory, rktio_envvars_t *envvars,
+                                       int flags)
+ {
++  const char *command; /* PATCHED for Guix */
+   rktio_process_result_t *result;
+   intptr_t to_subprocess[2], from_subprocess[2], err_subprocess[2];
+   int pid;
+@@ -1255,6 +1257,23 @@ rktio_process_result_t *rktio_process(rktio_t *rktio,
+   int i;
+ #endif
+ 
++/* BEGIN PATCH for Guix */
++#if defined(GUIX_RKTIO_PATCH_BIN_SH)
++# define GUIX_AS_a_STR_HELPER(x) #x
++# define GUIX_AS_a_STR(x) GUIX_AS_a_STR_HELPER(x)
++  /* A level of indirection makes `#` work as needed: */
++  command =
++      ((0 == strcmp(_guix_orig_command, "/bin/sh"))
++       && rktio_file_exists(rktio, GUIX_AS_a_STR(GUIX_RKTIO_PATCH_BIN_SH)))
++      ? GUIX_AS_a_STR(GUIX_RKTIO_PATCH_BIN_SH)
++      : _guix_orig_command;
++# undef GUIX_AS_a_STR
++# undef GUIX_AS_a_STR_HELPER
++#else
++  command = _guix_orig_command;
++#endif
++/* END PATCH for Guix */
++
+   /* avoid compiler warnings: */
+   to_subprocess[0] = -1;
+   to_subprocess[1] = -1;
+-- 
+2.21.1 (Apple Git-122.3)
+
diff --git a/gnu/packages/scheme.scm b/gnu/packages/scheme.scm
index 10be0aa28a..b5d526bfc3 100644
--- a/gnu/packages/scheme.scm
+++ b/gnu/packages/scheme.scm
@@ -14,6 +14,7 @@
 ;;; Copyright © 2020 Pierre Neidhardt <mail@HIDDEN>
 ;;; Copyright © 2020 Brett Gilio <brettg@HIDDEN>
 ;;; Copyright © 2020 Edouard Klein <edk@HIDDEN>
+;;; Copyright © 2021 Philip McGrath <philip@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -43,6 +44,7 @@
   #:use-module (guix build-system trivial)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages bdw-gc)
+  #:use-module (gnu packages bash)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages databases)
   #:use-module (gnu packages libevent)
@@ -411,94 +413,26 @@ implementation techniques and as an expository tool.")
                (base32
                 "047wpjblfzmf1msz7snrp2c2h0zxyzlmbsqr9bwsyvz3frcg0888"))
               (patches (search-patches
+                        "racket-sh-via-rktio.patch"
+                        ;; TODO: If we're no longer patching Racket source
+                        ;; files with store paths, we may also fix the
+                        ;; issue that necessitated the following patch:
                         "racket-store-checksum-override.patch"))))
     (build-system gnu-build-system)
     (arguments
-     '(#:configure-flags
-       '("--enable-libz"
+     `(#:configure-flags
+       `(,(string-append "CPPFLAGS=-DGUIX_RKTIO_PATCH_BIN_SH="
+                         (assoc-ref %build-inputs "sh")
+                         "/bin/sh")
+         "--enable-libz"
          "--enable-liblz4")
+       #:modules
+       ((guix build gnu-build-system)
+        (guix build utils)
+        (srfi srfi-1))
        #:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'pre-configure-minimal
-           (lambda* (#:key inputs #:allow-other-keys)
-             ;; Patch dynamically loaded libraries with their absolute paths.
-             (let* ((library-path (search-path-as-string->list
-                                   (getenv "LIBRARY_PATH")))
-                    (find-so (lambda (soname)
-                               (search-path
-                                library-path
-                                (format #f "~a.so" soname)))))
-               (substitute* "collects/db/private/sqlite3/ffi.rkt"
-                 (("ffi-lib sqlite-so")
-                  (format #f "ffi-lib \"~a\"" (find-so "libsqlite3"))))
-               (substitute* "collects/openssl/libssl.rkt"
-                 (("ffi-lib libssl-so")
-                  (format #f "ffi-lib \"~a\"" (find-so "libssl"))))
-               (substitute* "collects/openssl/libcrypto.rkt"
-                 (("ffi-lib libcrypto-so")
-                  (format #f "ffi-lib \"~a\"" (find-so "libcrypto")))))
-             (chdir "src")
-             #t))
-         (add-before 'pre-configure-minimal 'pre-configure
-           (lambda* (#:key inputs #:allow-other-keys)
-             ;; Patch dynamically loaded libraries with their absolute paths.
-             (let* ((library-path (search-path-as-string->list
-                                   (getenv "LIBRARY_PATH")))
-                    (find-so (lambda (soname)
-                               (search-path
-                                library-path
-                                (format #f "~a.so" soname))))
-                    (patch-ffi-libs (lambda (file libs)
-                                      (for-each
-                                       (lambda (lib)
-                                         (substitute* file
-                                           (((format #f "\"~a\"" lib))
-                                            (format #f "\"~a\"" (find-so lib)))))
-                                       libs))))
-               (substitute* "share/pkgs/math-lib/math/private/bigfloat/gmp.rkt"
-                 (("ffi-lib libgmp-so")
-                  (format #f "ffi-lib \"~a\"" (find-so "libgmp"))))
-               (substitute* "share/pkgs/math-lib/math/private/bigfloat/mpfr.rkt"
-                 (("ffi-lib libmpfr-so")
-                  (format #f "ffi-lib \"~a\"" (find-so "libmpfr"))))
-               (substitute* "share/pkgs/readline-lib/readline/rktrl.rkt"
-                 (("\\(getenv \"PLT_READLINE_LIB\"\\)")
-                  (format #f "\"~a\"" (find-so "libedit"))))
-               (for-each
-                (lambda (x) (apply patch-ffi-libs x))
-                '(("share/pkgs/draw-lib/racket/draw/unsafe/cairo-lib.rkt"
-                   ("libfontconfig" "libcairo"))
-                  ("share/pkgs/draw-lib/racket/draw/unsafe/glib.rkt"
-                   ("libglib-2.0" "libgmodule-2.0" "libgobject-2.0"))
-                  ("share/pkgs/draw-lib/racket/draw/unsafe/jpeg.rkt"
-                   ("libjpeg"))
-                  ("share/pkgs/draw-lib/racket/draw/unsafe/pango.rkt"
-                   ("libpango-1.0" "libpangocairo-1.0"))
-                  ("share/pkgs/draw-lib/racket/draw/unsafe/png.rkt"
-                   ("libpng"))
-                  ("share/pkgs/db-lib/db/private/odbc/ffi.rkt"
-                   ("libodbc"))
-                  ("share/pkgs/gui-lib/mred/private/wx/gtk/x11.rkt"
-                   ("libX11"))
-                  ("share/pkgs/gui-lib/mred/private/wx/gtk/gsettings.rkt"
-                   ("libgio-2.0"))
-                  ("share/pkgs/gui-lib/mred/private/wx/gtk/gtk3.rkt"
-                   ("libgdk-3" "libgtk-3"))
-                  ("share/pkgs/gui-lib/mred/private/wx/gtk/unique.rkt"
-                   ("libunique-1.0"))
-                  ("share/pkgs/gui-lib/mred/private/wx/gtk/utils.rkt"
-                   ("libgdk-x11-2.0" "libgdk_pixbuf-2.0" "libgtk-x11-2.0"))
-                  ("share/pkgs/gui-lib/mred/private/wx/gtk/gl-context.rkt"
-                   ("libGL"))
-                  ("share/pkgs/sgl/gl.rkt"
-                   ("libGL" "libGLU")))))
-             #t))
-         (add-after 'unpack 'patch-/bin/sh
-           (lambda _
-             (substitute* "collects/racket/system.rkt"
-               (("/bin/sh") (which "sh")))
-             #t))
-         (add-after 'patch-/bin/sh 'patch-chez-configure
+         (add-after 'unpack 'patch-chez-configure
            (lambda* (#:key inputs outputs #:allow-other-keys)
              (substitute* "src/cs/c/Makefile.in"
                (("/bin/sh") (which "sh")))
@@ -526,12 +460,69 @@ implementation techniques and as an expository tool.")
                  (("/bin/cp") (which "cp"))
                  (("/bin/echo") (which "echo")))
                (substitute* "makefiles/installsh"
-                 (("/bin/true") (which "true")))))))
+                 (("/bin/true") (which "true"))))
+             #t))
+         (add-before 'configure 'pre-configure-minimal
+           (lambda* (#:key inputs #:allow-other-keys)
+             (chdir "src")
+             #t))
+         (add-after 'build 'patch-config.rktd-lib-search-dirs
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             ;; We do this between the `build` and `install` phases
+             ;; so that we have racket to read and write the hash table,
+             ;; but it comes before `raco setup`, when foreign libraries
+             ;; are needed to build the documentation.
+             (define out (assoc-ref outputs "out"))
+             (apply invoke
+                    "./cs/c/racketcs"
+                    "-e"
+                    ,(format #f
+                             "~s"
+                             '(let* ((args
+                                      (vector->list
+                                       (current-command-line-arguments)))
+                                     (file (car args))
+                                     (extra-lib-search-dirs (cdr args)))
+                                (write-to-file
+                                 (hash-update
+                                  (file->value file)
+                                  'lib-search-dirs
+                                  (lambda (dirs)
+                                    (append dirs extra-lib-search-dirs))
+                                  null)
+                                 #:exists 'truncate/replace
+                                 file)))
+                    "--"
+                    "../etc/config.rktd"
+                    (filter-map (lambda (lib)
+                                  (cond
+                                   ((assoc-ref inputs lib)
+                                    => (lambda (pth)
+                                         (string-append pth "/lib")))
+                                   (else
+                                    #f)))
+                                '("cairo"
+                                  "fontconfig"
+                                  "glib"
+                                  "glu"
+                                  "gmp"
+                                  "gtk+"
+                                  "libjpeg"
+                                  "libpng"
+                                  "libx11"
+                                  "mesa"
+                                  "mpfr"
+                                  "openssl"
+                                  "pango"
+                                  "sqlite"
+                                  "unixodbc"
+                                  "libedit")))
+             #t)))
        ;; XXX: how to run them?
        #:tests? #f))
     (inputs
-     `(;; Hardcode dynamically loaded libraries for better functionality.
-       ;; sqlite and libraries for `racket/draw' are needed to build the doc.
+     `(;; sqlite and libraries for `racket/draw' are needed to build the doc.
+       ("sh" ,bash-minimal)
        ("zlib" ,zlib)
        ("zlib:static" ,zlib "static")
        ("lz4" ,lz4)
@@ -571,29 +562,21 @@ of languages such as Typed Racket, R5RS and R6RS Scheme, and Datalog.")
     (inherit racket)
     (name "racket-minimal")
     (version (package-version racket))
-    (source (origin
-              (method url-fetch)
-              (uri (list (string-append "https://mirror.racket-lang.org/installers/"
-                                        version "/racket-minimal-src.tgz")
-                         ;; this mirror seems to have broken HTTPS:
-                         (string-append
-                          "http://mirror.informatik.uni-tuebingen.de/mirror/racket/"
-                          version "/racket-minimal-src.tgz")))
-              (sha256
-               (base32
-                "0mwyffw4gcci8wmzxa3j28h03h0gsz55aard8qrk3lri8r2xyg21"))
-              (patches (search-patches
-                        "racket-store-checksum-override.patch"))))
+    (source
+     (origin
+       (inherit (package-source racket))
+       (uri (list (string-append "https://mirror.racket-lang.org/installers/"
+                                 version "/racket-minimal-src.tgz")
+                  ;; this mirror seems to have broken HTTPS:
+                  (string-append
+                   "http://mirror.informatik.uni-tuebingen.de/mirror/racket/"
+                   version "/racket-minimal-src.tgz")))
+       (sha256 "0mwyffw4gcci8wmzxa3j28h03h0gsz55aard8qrk3lri8r2xyg21")))
     (synopsis "Racket without bundled packages such as Dr. Racket")
-    (arguments
-     (substitute-keyword-arguments (package-arguments racket)
-       ((#:phases phases)
-        `(modify-phases ,phases
-           ;; Delete fix that applies to files not included in the minimal package.
-           (delete 'pre-configure)))))
     (inputs
      `(("openssl" ,openssl)
        ("sqlite" ,sqlite)
+       ("sh" ,bash-minimal)
        ("zlib" ,zlib)
        ("zlib:static" ,zlib "static")
        ("lz4" ,lz4)
-- 
2.21.1 (Apple Git-122.3)





Information forwarded to guix-patches@HIDDEN:
bug#47180; Package guix-patches. Full text available.

Message received at 47180 <at> debbugs.gnu.org:


Received: (at 47180) by debbugs.gnu.org; 17 Mar 2021 03:20:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 16 23:20:49 2021
Received: from localhost ([127.0.0.1]:41604 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lMMjo-00046X-Om
	for submit <at> debbugs.gnu.org; Tue, 16 Mar 2021 23:20:49 -0400
Received: from minsky.hcoop.net ([104.248.1.95]:41140)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <jackhill@HIDDEN>) id 1lMMjn-00046I-4w
 for 47180 <at> debbugs.gnu.org; Tue, 16 Mar 2021 23:20:47 -0400
Received: from marsh.hcoop.net ([45.55.52.66])
 by minsky.hcoop.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <jackhill@HIDDEN>)
 id 1lMMjh-0001uv-PQ; Tue, 16 Mar 2021 23:20:41 -0400
Date: Tue, 16 Mar 2021 23:20:41 -0400 (EDT)
From: Jack Hill <jackhill@HIDDEN>
X-X-Sender: jackhill@HIDDEN
To: Philip McGrath <philip@HIDDEN>
Subject: Re: [bug#47180] [PATCH] gnu: racket: Don't inject store paths into
 Racket files.
In-Reply-To: <a7e1d021-9b8e-ff99-7731-409fadf6283f@HIDDEN>
Message-ID: <alpine.DEB.2.21.2103162312040.8138@HIDDEN>
References: <20210316025632.9767-1-philip@HIDDEN>
 <alpine.DEB.2.21.2103160038330.8138@HIDDEN>
 <a7e1d021-9b8e-ff99-7731-409fadf6283f@HIDDEN>
User-Agent: Alpine 2.21 (DEB 202 2017-01-01)
MIME-Version: 1.0
Content-Type: multipart/mixed; BOUNDARY="925712948-543446750-1615950726=:8138"
Content-ID: <alpine.DEB.2.21.2103162313260.8138@HIDDEN>
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 47180
Cc: 47180 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--925712948-543446750-1615950726=:8138
Content-Type: text/plain; CHARSET=UTF-8; FORMAT=flowed
Content-Transfer-Encoding: 8BIT
Content-ID: <alpine.DEB.2.21.2103162313261.8138@HIDDEN>

On Tue, 16 Mar 2021, Philip McGrath wrote:

> Hi,
>
> On 3/16/21 1:43 AM, Jack Hill wrote:
>> I've tested applying and building this patch and it works!
>
> Glad to hear it!
>
>> (Now that DrRacket starts it appears that I may have a font issue with it. 
>> I'll investigate more an open a separate bug if so.)
>
> I realized to my chagrin when I saw your report that I hadn't actually used 
> any graphical programs via Guix, which of course would be an important thing 
> to test! I'll experiment, too, but yes, please do look for further issues.

I've opened #47204 for the fonts issue. I haven't done any investigation 
yet, and racket certainly wouldn't be the only package to run across fonts 
issues with Guix :)

[0] https://issues.guix.gnu.org/47204

I'm happy to help test things, that's what's nice about working on a 
community project.

> A good motivation for `guix import racket` is that we'll be able to run the 
> test suite, which lives in the `racket-test` package.

Indeed, and many more reasons.

>> `git am` complained about the following, but I can't spot them looking at 
>> the patch.
>
> I'm not sure what's up there … I generated it with `git send-email`. But I'm 
> not very familiar with this workflow, so it's quite possible there's 
> something I should have done/be doing differently.

I had assumed it was actually a problem with adding inadvertent whitespace 
to the patch rather than how it was sent. However, since I couldn't 
actually find the extra spaces anywhere, I'm not too worried about it. 
Other than the warnings it applied cleanly.

>>> +    3. "/bin/sh" does not exist (if it does, we don't want to change
>>> +       the expected behavior); and
>> 
>> Do we really want #3? That would have a different effect than the current 
>> patching behavior intends. /bin/sh is present by default on Guix System, 
>> and likely to be present of foreign distros. I think in generally we like 
>> to avoid this dynamic binding and instead use the sh that was included as a 
>> package input.
>
> That's a very good question.
>
> The non-obvious scenario I've been considering is that DrRacket's 
> `Racket|Create Executable…`, `raco distribute`, or the function 
> `assemble-distribution` from the `compiler/distribute` library can compile 
> your Racket program and bundle it with its runtime support into a tarball, 
> which is intended to be portable enough that you can email it to your friend 
> running some other GNU/Linux distribution and they can run it, too. One 
> implication of this feature is that a well-behaved Racket library should 
> cooperate with the compilation manager to register any foreign shared 
> libraries it may want to bring along.
>
> I don't use this feature much and it would take further testing before I'd be 
> confident that works properly on Guix, but it was definitely broken with the 
> old/current way of patching Racket source files with paths to foreign 
> libraries on the store. Configuring the `lib-search-dirs` is at least a step 
> closer to The Right Thing.
>
> This patch doesn't try to bring along "sh", and I don't think it should: the 
> relevant consideration here is that `librktio` will be bundled (IIRC as part 
> of `libracketcs.a`), so whatever version of `rktio_process` we compile ought 
> to work without Guix.
>
> That said, I think you may be right that, on Guix, using the sh that was a 
> package input may be less surprising than considering "/bin/sh" if it exists. 
> (I also think it's pretty unreasonable to put something other than a 
> POSIX-compatable shell at "/bin/sh" and expect any good to come of it.) All 
> the Racket docs[1] promise is that the relevant function "executes a shell 
> command asynchronously (using sh on Unix and Mac OS, cmd on Windows)", which 
> I take to mean that our obligation is to provide a sh, not for it to be any 
> particular sh or a user-configurable sh. (It does not consult SHELL, for 
> example.)
>
> So, if this still seems right to you, I propose to revise the patch by 
> dropping condition #3: then we'll still fall back to "/bin/sh" if the 
> built-in path doesn't exist, as presumably will be the case if we're being 
> executed in a non-Guix environment, but we'll unconditionally use the sh that 
> was a package input on Guix.
>
> Thanks for looking over this thoughtfully!
>
> -Philip
>
> [1]: 
> https://docs.racket-lang.org/reference/subprocess.html#(def._((lib._racket%2Fsystem..rkt)._process))

I hadn't considered raco distribute (I guess I'm spoiled by `guix pack`). 
Your proposed change addresses my concern.

Thanks!
Jack
--925712948-543446750-1615950726=:8138--




Information forwarded to guix-patches@HIDDEN:
bug#47180; Package guix-patches. Full text available.

Message received at 47180 <at> debbugs.gnu.org:


Received: (at 47180) by debbugs.gnu.org; 16 Mar 2021 17:37:35 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 16 13:37:34 2021
Received: from localhost ([127.0.0.1]:40942 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lMDdO-0004sO-ID
	for submit <at> debbugs.gnu.org; Tue, 16 Mar 2021 13:37:34 -0400
Received: from mail-qk1-f175.google.com ([209.85.222.175]:39756)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <philip@HIDDEN>) id 1lMDdM-0004s9-P4
 for 47180 <at> debbugs.gnu.org; Tue, 16 Mar 2021 13:37:33 -0400
Received: by mail-qk1-f175.google.com with SMTP id g185so36075130qkf.6
 for <47180 <at> debbugs.gnu.org>; Tue, 16 Mar 2021 10:37:32 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=philipmcgrath.com; s=google;
 h=subject:to:cc:references:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-language:content-transfer-encoding;
 bh=TIyW1TywtabgKqwrYD2lZH/hZz237gwlp4ZGTyex1tE=;
 b=YzlFTOX5YwId4sOaQP4Zkcj4oEA5PCLb7M5IsDDNne+nSmi+Po/39El6P9AYsfT23o
 a7C0/kEIH673Y1Vk0LSEyL8M7K2gP1FhxdEAG2UzSa4McUGR1/+DSkiUY345BZjfSvsB
 NY8u28Zdr8FKKmOB55qbNz/1nfp+QgH9Cl10A6XJvpNhebd+k9y8bF70a7yBaRpXCJql
 Vgl/0gWDGgnYDVFhrjYcdqW8zwr2MG2yXb3FfXQSk/LrFI6pD6I4TxKvWomyfLkLDdok
 qTr3Mt7zpNJ9YkbA5XEoppNzlrvlHZ83OUrFOrOnyqdQSay3YT8pdJoW0Y6q6jY9YDTG
 f7Mw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:subject:to:cc:references:from:message-id:date
 :user-agent:mime-version:in-reply-to:content-language
 :content-transfer-encoding;
 bh=TIyW1TywtabgKqwrYD2lZH/hZz237gwlp4ZGTyex1tE=;
 b=nHBbxTYYWNOf2/5tAum8dxECbNTi0nAw1D8I30yxpy8GRL9UUjzIa+URKLpR8pemxn
 eBYC12pIFaJTRQNpzqWpPDH5zHWJhF4RTIu8qgJefXH7znUixB3Te1vajYUVmm7OpxPf
 ECu//VsstzHXukxYQJNPbIXva9/P1rkWLZ7q4GmIlP8QjdHDQAjGbFoeiwuC7DurXwFw
 8VW6Aez3sh8/lELx+nlCJxH4vvBxyBc2yYrUAOKqb/PjkPE3sgPN+w6cUCIfyplgwwrp
 USlxdy0OUInLNBDVJyiVL9CybsXn5tYgbDsaQGzINDvyYf6qiuuoWmNpqkT14jwU0IeP
 nWKw==
X-Gm-Message-State: AOAM531TW06RwDb81GMBW4xtr7A57ybuXoOjHG/ebOApwyKpbryBh5ok
 uxQVOMQWw3kAMYGNu85hr9xjphdyyRYduDj/plc=
X-Google-Smtp-Source: ABdhPJyEqNDykhzjKrY1uoq7sxRs34YCqGFlicSokj8Uz1QI9gfpMSgosxmD1nYbgClLkOWxtwztHw==
X-Received: by 2002:a37:6104:: with SMTP id v4mr108922qkb.429.1615916246941;
 Tue, 16 Mar 2021 10:37:26 -0700 (PDT)
Received: from Sapientia.local (c-73-125-89-242.hsd1.fl.comcast.net.
 [73.125.89.242])
 by smtp.gmail.com with ESMTPSA id p8sm14061072qtu.8.2021.03.16.10.37.26
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Tue, 16 Mar 2021 10:37:26 -0700 (PDT)
Subject: Re: [bug#47180] [PATCH] gnu: racket: Don't inject store paths into
 Racket files.
To: Jack Hill <jackhill@HIDDEN>
References: <20210316025632.9767-1-philip@HIDDEN>
 <alpine.DEB.2.21.2103160038330.8138@HIDDEN>
From: Philip McGrath <philip@HIDDEN>
Message-ID: <a7e1d021-9b8e-ff99-7731-409fadf6283f@HIDDEN>
Date: Tue, 16 Mar 2021 13:37:25 -0400
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0)
 Gecko/20100101 Thunderbird/78.8.0
MIME-Version: 1.0
In-Reply-To: <alpine.DEB.2.21.2103160038330.8138@HIDDEN>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: 47180
Cc: 47180 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.3 (/)

Hi,

On 3/16/21 1:43 AM, Jack Hill wrote:
> I've tested applying and building this patch and it works!

Glad to hear it!

> (Now that DrRacket starts it appears that I may have a font issue with 
> it. I'll investigate more an open a separate bug if so.)

I realized to my chagrin when I saw your report that I hadn't actually 
used any graphical programs via Guix, which of course would be an 
important thing to test! I'll experiment, too, but yes, please do look 
for further issues.

A good motivation for `guix import racket` is that we'll be able to run 
the test suite, which lives in the `racket-test` package.

> `git am` complained about the following, but I can't spot them looking 
> at the patch.

I'm not sure what's up there … I generated it with `git send-email`. But 
I'm not very familiar with this workflow, so it's quite possible there's 
something I should have done/be doing differently.

>> +    3. "/bin/sh" does not exist (if it does, we don't want to change
>> +       the expected behavior); and
> 
> Do we really want #3? That would have a different effect than the 
> current patching behavior intends. /bin/sh is present by default on Guix 
> System, and likely to be present of foreign distros. I think in 
> generally we like to avoid this dynamic binding and instead use the sh 
> that was included as a package input.

That's a very good question.

The non-obvious scenario I've been considering is that DrRacket's 
`Racket|Create Executable…`, `raco distribute`, or the function 
`assemble-distribution` from the `compiler/distribute` library can 
compile your Racket program and bundle it with its runtime support into 
a tarball, which is intended to be portable enough that you can email it 
to your friend running some other GNU/Linux distribution and they can 
run it, too. One implication of this feature is that a well-behaved 
Racket library should cooperate with the compilation manager to register 
any foreign shared libraries it may want to bring along.

I don't use this feature much and it would take further testing before 
I'd be confident that works properly on Guix, but it was definitely 
broken with the old/current way of patching Racket source files with 
paths to foreign libraries on the store. Configuring the 
`lib-search-dirs` is at least a step closer to The Right Thing.

This patch doesn't try to bring along "sh", and I don't think it should: 
the relevant consideration here is that `librktio` will be bundled (IIRC 
as part of `libracketcs.a`), so whatever version of `rktio_process` we 
compile ought to work without Guix.

That said, I think you may be right that, on Guix, using the sh that was 
a package input may be less surprising than considering "/bin/sh" if it 
exists. (I also think it's pretty unreasonable to put something other 
than a POSIX-compatable shell at "/bin/sh" and expect any good to come 
of it.) All the Racket docs[1] promise is that the relevant function 
"executes a shell command asynchronously (using sh on Unix and Mac OS, 
cmd on Windows)", which I take to mean that our obligation is to provide 
a sh, not for it to be any particular sh or a user-configurable sh. (It 
does not consult SHELL, for example.)

So, if this still seems right to you, I propose to revise the patch by 
dropping condition #3: then we'll still fall back to "/bin/sh" if the 
built-in path doesn't exist, as presumably will be the case if we're 
being executed in a non-Guix environment, but we'll unconditionally use 
the sh that was a package input on Guix.

Thanks for looking over this thoughtfully!

-Philip

[1]: 
https://docs.racket-lang.org/reference/subprocess.html#(def._((lib._racket%2Fsystem..rkt)._process))




Information forwarded to guix-patches@HIDDEN:
bug#47180; Package guix-patches. Full text available.

Message received at 47180 <at> debbugs.gnu.org:


Received: (at 47180) by debbugs.gnu.org; 16 Mar 2021 05:43:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Mar 16 01:43:12 2021
Received: from localhost ([127.0.0.1]:37797 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lM2U4-0008LI-41
	for submit <at> debbugs.gnu.org; Tue, 16 Mar 2021 01:43:12 -0400
Received: from minsky.hcoop.net ([104.248.1.95]:43872)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <jackhill@HIDDEN>) id 1lM2U2-0008L3-Mn
 for 47180 <at> debbugs.gnu.org; Tue, 16 Mar 2021 01:43:11 -0400
Received: from marsh.hcoop.net ([45.55.52.66])
 by minsky.hcoop.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <jackhill@HIDDEN>)
 id 1lM2Tx-0001rq-7U; Tue, 16 Mar 2021 01:43:05 -0400
Date: Tue, 16 Mar 2021 01:43:05 -0400 (EDT)
From: Jack Hill <jackhill@HIDDEN>
X-X-Sender: jackhill@HIDDEN
To: Philip McGrath <philip@HIDDEN>
Subject: Re: [bug#47180] [PATCH] gnu: racket: Don't inject store paths into
 Racket files.
In-Reply-To: <20210316025632.9767-1-philip@HIDDEN>
Message-ID: <alpine.DEB.2.21.2103160038330.8138@HIDDEN>
References: <20210316025632.9767-1-philip@HIDDEN>
User-Agent: Alpine 2.21 (DEB 202 2017-01-01)
MIME-Version: 1.0
Content-Type: multipart/mixed; BOUNDARY="925712948-1221268349-1615870838=:8138"
Content-ID: <alpine.DEB.2.21.2103160141210.8138@HIDDEN>
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 47180
Cc: 47180 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--925712948-1221268349-1615870838=:8138
Content-Type: text/plain; CHARSET=UTF-8; FORMAT=flowed
Content-Transfer-Encoding: 8BIT
Content-ID: <alpine.DEB.2.21.2103160141211.8138@HIDDEN>

Wow, that was speedy. Thanks for the care you've taken thinking about these 
issues. I've tested applying and building this patch and it works!

(Now that DrRacket starts it appears that I may have a font issue with it. 
I'll investigate more an open a separate bug if so.)

I don't think I know enough about Guix or Racket internals to give it a 
proper review or judge whether this will be robust against future grafting 
problems, but I do have a few comments


`git am` complained about the following, but I can't spot them looking at 
the patch.

.git/rebase-apply/patch:83: trailing whitespace.

.git/rebase-apply/patch:100: trailing whitespace.

.git/rebase-apply/patch:122: trailing whitespace.
-- 
.git/rebase-apply/patch:124: new blank line at EOF.


On Mon, 15 Mar 2021, Philip McGrath wrote:

> Apparently, during grafting, Guix can somehow mangle compiled
> Racket CS files (.zo) such that Racket will refuse to load them.
> (Maybe it has something to do with compression?)
> So, we stop patching Racket sources with absolute paths to store
> files (i.e. for foreign libraries to dlopen).
> Instead, we put them in a data file that doesn't get compiled or,
> in one case, embed it in C.

[…]

> +Guix should enable the special case by defining the C preprocessor
> +macro `GUIX_RKTIO_PATCH_BIN_SH` with the path to `sh` in the store.
> +If:
> +
> +    1. The `GUIX_RKTIO_PATCH_BIN_SH` macro is defined; and
> +
> +    2. `rktio_process` is called with the exact path "/bin/sh"; and
> +
> +    3. "/bin/sh" does not exist (if it does, we don't want to change
> +       the expected behavior); and

Do we really want #3? That would have a different effect than the current 
patching behavior intends. /bin/sh is present by default on Guix System, 
and likely to be present of foreign distros. I think in generally we like 
to avoid this dynamic binding and instead use the sh that was included as 
a package input.

> +    4. The path specified by `GUIX_RKTIO_PATCH_BIN_SH` does exists;
> +
> +then `rktio_process` will execute the file specified
> +by `GUIX_RKTIO_PATCH_BIN_SH` instead of "/bin/sh".
> +
> +Compared to previous attempts to patch the Racket sources,
> +making this change at the C level is both:
> +
> +    - More comprehensive: it catches all attempts to execute "/bin/sh",
> +      without having to track down the source of every occurance; and
> +
> +    - Less intrusive: by guarding the special case with a C preprocessor
> +      conditional and a runtime check that the file in the store exists,
> +      we make it much less likely that it will "leak" out of Guix.

Again, I might be wrong by preferring to always avoid /bin/sh even when 
it's available. Hopefully someone more knowledgeable will come along.

Best,
Jack
--925712948-1221268349-1615870838=:8138--




Information forwarded to guix-patches@HIDDEN:
bug#47180; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 16 Mar 2021 02:57:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Mar 15 22:57:25 2021
Received: from localhost ([127.0.0.1]:37691 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1lLztX-0002JE-B4
	for submit <at> debbugs.gnu.org; Mon, 15 Mar 2021 22:57:25 -0400
Received: from lists.gnu.org ([209.51.188.17]:34170)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <philip@HIDDEN>) id 1lLztR-0002Iw-EE
 for submit <at> debbugs.gnu.org; Mon, 15 Mar 2021 22:57:16 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:44772)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <philip@HIDDEN>)
 id 1lLztR-00057o-5N
 for guix-patches@HIDDEN; Mon, 15 Mar 2021 22:57:13 -0400
Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]:44697)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <philip@HIDDEN>)
 id 1lLztO-0006yv-M7
 for guix-patches@HIDDEN; Mon, 15 Mar 2021 22:57:12 -0400
Received: by mail-qt1-x835.google.com with SMTP id m7so10710593qtq.11
 for <guix-patches@HIDDEN>; Mon, 15 Mar 2021 19:57:09 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=philipmcgrath.com; s=google;
 h=from:to:cc:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=uy/ygS1ATIoyg6h/5L3UYdCkKlQI23+10gmy+XxDVMk=;
 b=bnHv8nAryAUxDlGiXyn6ALF9CTAjwY2lttgaLh00nrAoexKg5gJSDD9RepX49rKhgZ
 Tuhb4A9SMl3muWBGHVec0rrdTNf68JuK2GbLuqq8wA4BP+Qft9cDsz5oYg7B6IG6yvIp
 d2WkcZpgSxzj4d3WY4UaOMNkVRX5uzf/kiScirpOcdgW20MFzTPULnF26yS2KHMbfHET
 aoLQtI/QfaPGjVdm1tyotBlLYws7PmmG0fqmrXRO3KqSfRg/bhH9qTVgJOTPmtjSxUyF
 5G4j2iI7jkaV+KwDU3AGvdFvNmF/f0aWdpepyp1kE6PdNHBd2pIw74biF4OhQ6yOBNuv
 arBQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=uy/ygS1ATIoyg6h/5L3UYdCkKlQI23+10gmy+XxDVMk=;
 b=b5ylEOmOb61ncf9ZnFtXxrOyNHjlzfOKybkO1DvPSQ01FVh6ccqnpQsZ+K1qkqhVkH
 7ecvVny5e5RglHPpuB+8VrUjw+xVt90/tbt8tPkPFeGx+ECGrAdynAiAlNEMq+jca+3X
 qFyDhy+uz+cGXcOPhNpTDipQRHbudoxsAxo2HAeEEYBug47SF2Y96xE077uooCfGQ3fk
 AN2DJ6iVJRj/GxJTcP3U5uv3Z+CVjo8o+vATYRWsOWcmJMhkNY3/QHhIoxvVHtNXPH0X
 hgsFgoeEXvXZUWx63G2r6l5KP/e5CQqwlyAyYye2mP7T9DpeUbqqy8FUH5bJYQNcGIb1
 6Utg==
X-Gm-Message-State: AOAM5302/SVM42JOZCRytOpzh6wtWWBRCkMH/W0+57Pgjh4AsQhVxaaH
 iyt30fRa2B11oXhoNbGbOCnaOMwXYhLekalHsSY=
X-Google-Smtp-Source: ABdhPJz1QrrQEBfd9lR/rMVQPbTxzuOpK0m7U5mjjPK69iGzzdzL/Q8GRXKeWhm+L2gN3kEZxHSskA==
X-Received: by 2002:ac8:1094:: with SMTP id a20mr25575261qtj.248.1615863428682; 
 Mon, 15 Mar 2021 19:57:08 -0700 (PDT)
Received: from localhost (c-73-125-89-242.hsd1.fl.comcast.net. [73.125.89.242])
 by smtp.gmail.com with ESMTPSA id t5sm10597719qkt.66.2021.03.15.19.57.07
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Mon, 15 Mar 2021 19:57:08 -0700 (PDT)
From: Philip McGrath <philip@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH] gnu: racket: Don't inject store paths into Racket files.
Date: Mon, 15 Mar 2021 22:56:32 -0400
Message-Id: <20210316025632.9767-1-philip@HIDDEN>
X-Mailer: git-send-email 2.21.1 (Apple Git-122.3)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Received-SPF: neutral client-ip=2607:f8b0:4864:20::835;
 envelope-from=philip@HIDDEN; helo=mail-qt1-x835.google.com
X-Spam_score_int: -12
X-Spam_score: -1.3
X-Spam_bar: -
X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_NEUTRAL=0.779 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: submit
Cc: jackhill@HIDDEN, Philip McGrath <philip@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.3 (/)

Apparently, during grafting, Guix can somehow mangle compiled
Racket CS files (.zo) such that Racket will refuse to load them.
(Maybe it has something to do with compression?)
So, we stop patching Racket sources with absolute paths to store
files (i.e. for foreign libraries to dlopen).
Instead, we put them in a data file that doesn't get compiled or,
in one case, embed it in C.

Fixes https://issues.guix.gnu.org/47064

* gnu/packages/patches/racket-sh-via-rktio.patch: New file.
Adds a special case at the C level, controlled by a preprocessor macro,
to handle attempts to execute "/bin/sh".
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/scheme.scm (racket)[source](patches): Apply it.
(racket)[arguments](#:configure-flags): Add the CPP flag to enable it.
(racket)[arguments](#:modules): Use srfi-1.
(racket)[arguments](#:phases): Remove 'patch-/bin/sh and 'pre-configure.
Change 'pre-configure-minimal to just change directory.
Add 'patch-config.rktd-lib-search-dirs after 'build and before 'install
to configure Racket's "lib-search-dirs".
(racket, racket-minimal)[inputs]: Add bash-minimal as an explicit input.
(racket-minimal)[source]: Adjust to inherit patches from racket.
---
 gnu/local.mk                                  |   2 +
 .../patches/racket-sh-via-rktio.patch         |  91 +++++++++
 gnu/packages/scheme.scm                       | 190 ++++++++----------
 3 files changed, 179 insertions(+), 104 deletions(-)
 create mode 100644 gnu/packages/patches/racket-sh-via-rktio.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index cf8849cf59..51dcf4e6e6 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -40,6 +40,7 @@
 # Copyright © 2020 Malte Frank Gerdes <mate.f.gerdes@HIDDEN>
 # Copyright © 2020 Vinicius Monego <monego@HIDDEN>
 # Copyright © 2021 Björn Höfling <bjoern.hoefling@HIDDEN>
+# Copyright © 2021 Philip McGrath <philip@HIDDEN>
 #
 # This file is part of GNU Guix.
 #
@@ -1629,6 +1630,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/ripperx-missing-file.patch		\
   %D%/packages/patches/rpcbind-CVE-2017-8779.patch		\
   %D%/packages/patches/rtags-separate-rct.patch			\
+  %D%/packages/patches/racket-sh-via-rktio.patch		\
   %D%/packages/patches/racket-store-checksum-override.patch	\
   %D%/packages/patches/remake-impure-dirs.patch			\
   %D%/packages/patches/retroarch-LIBRETRO_DIRECTORY.patch	\
diff --git a/gnu/packages/patches/racket-sh-via-rktio.patch b/gnu/packages/patches/racket-sh-via-rktio.patch
new file mode 100644
index 0000000000..870e8eb5f2
--- /dev/null
+++ b/gnu/packages/patches/racket-sh-via-rktio.patch
@@ -0,0 +1,91 @@
+From 34fd01842d5211e73260721b7a516487e982497c Mon Sep 17 00:00:00 2001
+From: Philip McGrath <philip@HIDDEN>
+Date: Thu, 4 Mar 2021 04:11:50 -0500
+Subject: [PATCH] patch rktio_process for "/bin/sh" on Guix
+
+Racket provides the functions `system` and `process`,
+which execute shell commands using `sh` (or `cmd` on Windows).
+Racket assumes that `sh` can be found at "/bin/sh",
+which is not necessarily true on Guix.
+
+This patch adds a special case for "/bin/sh" to `rktio_process`,
+the C function that implements the core of `system`, `process`,
+and related Racket functions.
+
+Guix should enable the special case by defining the C preprocessor
+macro `GUIX_RKTIO_PATCH_BIN_SH` with the path to `sh` in the store.
+If:
+
+    1. The `GUIX_RKTIO_PATCH_BIN_SH` macro is defined; and
+
+    2. `rktio_process` is called with the exact path "/bin/sh"; and
+
+    3. "/bin/sh" does not exist (if it does, we don't want to change
+       the expected behavior); and
+
+    4. The path specified by `GUIX_RKTIO_PATCH_BIN_SH` does exists;
+
+then `rktio_process` will execute the file specified
+by `GUIX_RKTIO_PATCH_BIN_SH` instead of "/bin/sh".
+
+Compared to previous attempts to patch the Racket sources,
+making this change at the C level is both:
+
+    - More comprehensive: it catches all attempts to execute "/bin/sh",
+      without having to track down the source of every occurance; and
+
+    - Less intrusive: by guarding the special case with a C preprocessor
+      conditional and a runtime check that the file in the store exists,
+      we make it much less likely that it will "leak" out of Guix.
+---
+ src/rktio/rktio_process.c | 22 +++++++++++++++++++++-
+ 1 file changed, 21 insertions(+), 1 deletion(-)
+
+diff --git a/src/rktio/rktio_process.c b/src/rktio/rktio_process.c
+index 89202436c0..ff65a434e2 100644
+--- a/src/rktio/rktio_process.c
++++ b/src/rktio/rktio_process.c
+@@ -1224,12 +1224,14 @@ int rktio_process_allowed_flags(rktio_t *rktio)
+ /*========================================================================*/
+ 
+ rktio_process_result_t *rktio_process(rktio_t *rktio,
+-                                      const char *command, int argc, rktio_const_string_t *argv,
++                                      /* PATCHED for Guix (next line) */
++                                      const char *_guix_orig_command, int argc, rktio_const_string_t *argv,
+                                       rktio_fd_t *stdout_fd, rktio_fd_t *stdin_fd, rktio_fd_t *stderr_fd,
+                                       rktio_process_t *group_proc,
+                                       const char *current_directory, rktio_envvars_t *envvars,
+                                       int flags)
+ {
++  const char *command; /* PATCHED for Guix */
+   rktio_process_result_t *result;
+   intptr_t to_subprocess[2], from_subprocess[2], err_subprocess[2];
+   int pid;
+@@ -1255,6 +1257,24 @@ rktio_process_result_t *rktio_process(rktio_t *rktio,
+   int i;
+ #endif
+ 
++/* BEGIN PATCH for Guix */
++#if defined(GUIX_RKTIO_PATCH_BIN_SH)
++# define GUIX_AS_a_STR_HELPER(x) #x
++# define GUIX_AS_a_STR(x) GUIX_AS_a_STR_HELPER(x)
++  /* A level of indirection makes `#` work as needed: */
++  command =
++      ((0 == strcmp(_guix_orig_command, "/bin/sh"))
++       && (! rktio_file_exists(rktio, "/bin/sh"))
++       && rktio_file_exists(rktio, GUIX_AS_a_STR(GUIX_RKTIO_PATCH_BIN_SH)))
++      ? GUIX_AS_a_STR(GUIX_RKTIO_PATCH_BIN_SH)
++      : _guix_orig_command;
++# undef GUIX_AS_a_STR
++# undef GUIX_AS_a_STR_HELPER
++#else
++  command = _guix_orig_command;
++#endif
++/* END PATCH for Guix */
++
+   /* avoid compiler warnings: */
+   to_subprocess[0] = -1;
+   to_subprocess[1] = -1;
+-- 
+2.25.1
+
diff --git a/gnu/packages/scheme.scm b/gnu/packages/scheme.scm
index 10be0aa28a..8656fef1ab 100644
--- a/gnu/packages/scheme.scm
+++ b/gnu/packages/scheme.scm
@@ -43,6 +43,7 @@
   #:use-module (guix build-system trivial)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages bdw-gc)
+  #:use-module (gnu packages bash)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages databases)
   #:use-module (gnu packages libevent)
@@ -411,94 +412,26 @@ implementation techniques and as an expository tool.")
                (base32
                 "047wpjblfzmf1msz7snrp2c2h0zxyzlmbsqr9bwsyvz3frcg0888"))
               (patches (search-patches
+                        "racket-sh-via-rktio.patch"
+                        ;; TODO: If we're no longer patching Racket source
+                        ;; files with store paths, we may also fix the
+                        ;; issue that necessitated the following patch:
                         "racket-store-checksum-override.patch"))))
     (build-system gnu-build-system)
     (arguments
-     '(#:configure-flags
-       '("--enable-libz"
+     `(#:configure-flags
+       `(,(string-append "CPPFLAGS=-DGUIX_RKTIO_PATCH_BIN_SH="
+                         (assoc-ref %build-inputs "sh")
+                         "/bin/sh")
+         "--enable-libz"
          "--enable-liblz4")
+       #:modules
+       ((guix build gnu-build-system)
+        (guix build utils)
+        (srfi srfi-1))
        #:phases
        (modify-phases %standard-phases
-         (add-before 'configure 'pre-configure-minimal
-           (lambda* (#:key inputs #:allow-other-keys)
-             ;; Patch dynamically loaded libraries with their absolute paths.
-             (let* ((library-path (search-path-as-string->list
-                                   (getenv "LIBRARY_PATH")))
-                    (find-so (lambda (soname)
-                               (search-path
-                                library-path
-                                (format #f "~a.so" soname)))))
-               (substitute* "collects/db/private/sqlite3/ffi.rkt"
-                 (("ffi-lib sqlite-so")
-                  (format #f "ffi-lib \"~a\"" (find-so "libsqlite3"))))
-               (substitute* "collects/openssl/libssl.rkt"
-                 (("ffi-lib libssl-so")
-                  (format #f "ffi-lib \"~a\"" (find-so "libssl"))))
-               (substitute* "collects/openssl/libcrypto.rkt"
-                 (("ffi-lib libcrypto-so")
-                  (format #f "ffi-lib \"~a\"" (find-so "libcrypto")))))
-             (chdir "src")
-             #t))
-         (add-before 'pre-configure-minimal 'pre-configure
-           (lambda* (#:key inputs #:allow-other-keys)
-             ;; Patch dynamically loaded libraries with their absolute paths.
-             (let* ((library-path (search-path-as-string->list
-                                   (getenv "LIBRARY_PATH")))
-                    (find-so (lambda (soname)
-                               (search-path
-                                library-path
-                                (format #f "~a.so" soname))))
-                    (patch-ffi-libs (lambda (file libs)
-                                      (for-each
-                                       (lambda (lib)
-                                         (substitute* file
-                                           (((format #f "\"~a\"" lib))
-                                            (format #f "\"~a\"" (find-so lib)))))
-                                       libs))))
-               (substitute* "share/pkgs/math-lib/math/private/bigfloat/gmp.rkt"
-                 (("ffi-lib libgmp-so")
-                  (format #f "ffi-lib \"~a\"" (find-so "libgmp"))))
-               (substitute* "share/pkgs/math-lib/math/private/bigfloat/mpfr.rkt"
-                 (("ffi-lib libmpfr-so")
-                  (format #f "ffi-lib \"~a\"" (find-so "libmpfr"))))
-               (substitute* "share/pkgs/readline-lib/readline/rktrl.rkt"
-                 (("\\(getenv \"PLT_READLINE_LIB\"\\)")
-                  (format #f "\"~a\"" (find-so "libedit"))))
-               (for-each
-                (lambda (x) (apply patch-ffi-libs x))
-                '(("share/pkgs/draw-lib/racket/draw/unsafe/cairo-lib.rkt"
-                   ("libfontconfig" "libcairo"))
-                  ("share/pkgs/draw-lib/racket/draw/unsafe/glib.rkt"
-                   ("libglib-2.0" "libgmodule-2.0" "libgobject-2.0"))
-                  ("share/pkgs/draw-lib/racket/draw/unsafe/jpeg.rkt"
-                   ("libjpeg"))
-                  ("share/pkgs/draw-lib/racket/draw/unsafe/pango.rkt"
-                   ("libpango-1.0" "libpangocairo-1.0"))
-                  ("share/pkgs/draw-lib/racket/draw/unsafe/png.rkt"
-                   ("libpng"))
-                  ("share/pkgs/db-lib/db/private/odbc/ffi.rkt"
-                   ("libodbc"))
-                  ("share/pkgs/gui-lib/mred/private/wx/gtk/x11.rkt"
-                   ("libX11"))
-                  ("share/pkgs/gui-lib/mred/private/wx/gtk/gsettings.rkt"
-                   ("libgio-2.0"))
-                  ("share/pkgs/gui-lib/mred/private/wx/gtk/gtk3.rkt"
-                   ("libgdk-3" "libgtk-3"))
-                  ("share/pkgs/gui-lib/mred/private/wx/gtk/unique.rkt"
-                   ("libunique-1.0"))
-                  ("share/pkgs/gui-lib/mred/private/wx/gtk/utils.rkt"
-                   ("libgdk-x11-2.0" "libgdk_pixbuf-2.0" "libgtk-x11-2.0"))
-                  ("share/pkgs/gui-lib/mred/private/wx/gtk/gl-context.rkt"
-                   ("libGL"))
-                  ("share/pkgs/sgl/gl.rkt"
-                   ("libGL" "libGLU")))))
-             #t))
-         (add-after 'unpack 'patch-/bin/sh
-           (lambda _
-             (substitute* "collects/racket/system.rkt"
-               (("/bin/sh") (which "sh")))
-             #t))
-         (add-after 'patch-/bin/sh 'patch-chez-configure
+         (add-after 'unpack 'patch-chez-configure
            (lambda* (#:key inputs outputs #:allow-other-keys)
              (substitute* "src/cs/c/Makefile.in"
                (("/bin/sh") (which "sh")))
@@ -526,12 +459,69 @@ implementation techniques and as an expository tool.")
                  (("/bin/cp") (which "cp"))
                  (("/bin/echo") (which "echo")))
                (substitute* "makefiles/installsh"
-                 (("/bin/true") (which "true")))))))
+                 (("/bin/true") (which "true"))))
+             #t))
+         (add-before 'configure 'pre-configure-minimal
+           (lambda* (#:key inputs #:allow-other-keys)
+             (chdir "src")
+             #t))
+         (add-after 'build 'patch-config.rktd-lib-search-dirs
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             ;; We do this between the `build` and `install` phases
+             ;; so that we have racket to read and write the hash table,
+             ;; but it comes before `raco setup`, when foreign libraries
+             ;; are needed to build the documentation.
+             (define out (assoc-ref outputs "out"))
+             (apply invoke
+                    "./cs/c/racketcs"
+                    "-e"
+                    ,(format #f
+                             "~s"
+                             '(let* ((args
+                                      (vector->list
+                                       (current-command-line-arguments)))
+                                     (file (car args))
+                                     (extra-lib-search-dirs (cdr args)))
+                                (write-to-file
+                                 (hash-update
+                                  (file->value file)
+                                  'lib-search-dirs
+                                  (lambda (dirs)
+                                    (append dirs extra-lib-search-dirs))
+                                  null)
+                                 #:exists 'truncate/replace
+                                 file)))
+                    "--"
+                    "../etc/config.rktd"
+                    (filter-map (lambda (lib)
+                                  (cond
+                                   ((assoc-ref inputs lib)
+                                    => (lambda (pth)
+                                         (string-append pth "/lib")))
+                                   (else
+                                    #f)))
+                                '("cairo"
+                                  "fontconfig"
+                                  "glib"
+                                  "glu"
+                                  "gmp"
+                                  "gtk+"
+                                  "libjpeg"
+                                  "libpng"
+                                  "libx11"
+                                  "mesa"
+                                  "mpfr"
+                                  "openssl"
+                                  "pango"
+                                  "sqlite"
+                                  "unixodbc"
+                                  "libedit")))
+             #t)))
        ;; XXX: how to run them?
        #:tests? #f))
     (inputs
-     `(;; Hardcode dynamically loaded libraries for better functionality.
-       ;; sqlite and libraries for `racket/draw' are needed to build the doc.
+     `(;; sqlite and libraries for `racket/draw' are needed to build the doc.
+       ("sh" ,bash-minimal)
        ("zlib" ,zlib)
        ("zlib:static" ,zlib "static")
        ("lz4" ,lz4)
@@ -571,29 +561,21 @@ of languages such as Typed Racket, R5RS and R6RS Scheme, and Datalog.")
     (inherit racket)
     (name "racket-minimal")
     (version (package-version racket))
-    (source (origin
-              (method url-fetch)
-              (uri (list (string-append "https://mirror.racket-lang.org/installers/"
-                                        version "/racket-minimal-src.tgz")
-                         ;; this mirror seems to have broken HTTPS:
-                         (string-append
-                          "http://mirror.informatik.uni-tuebingen.de/mirror/racket/"
-                          version "/racket-minimal-src.tgz")))
-              (sha256
-               (base32
-                "0mwyffw4gcci8wmzxa3j28h03h0gsz55aard8qrk3lri8r2xyg21"))
-              (patches (search-patches
-                        "racket-store-checksum-override.patch"))))
+    (source
+     (origin
+       (inherit (package-source racket))
+       (uri (list (string-append "https://mirror.racket-lang.org/installers/"
+                                 version "/racket-minimal-src.tgz")
+                  ;; this mirror seems to have broken HTTPS:
+                  (string-append
+                   "http://mirror.informatik.uni-tuebingen.de/mirror/racket/"
+                   version "/racket-minimal-src.tgz")))
+       (sha256 "0mwyffw4gcci8wmzxa3j28h03h0gsz55aard8qrk3lri8r2xyg21")))
     (synopsis "Racket without bundled packages such as Dr. Racket")
-    (arguments
-     (substitute-keyword-arguments (package-arguments racket)
-       ((#:phases phases)
-        `(modify-phases ,phases
-           ;; Delete fix that applies to files not included in the minimal package.
-           (delete 'pre-configure)))))
     (inputs
      `(("openssl" ,openssl)
        ("sqlite" ,sqlite)
+       ("sh" ,bash-minimal)
        ("zlib" ,zlib)
        ("zlib:static" ,zlib "static")
        ("lz4" ,lz4)
-- 
2.21.1 (Apple Git-122.3)





Acknowledgement sent to Philip McGrath <philip@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#47180; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 16 Apr 2021 20:15:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.