Subject: Re: bug#44835: gnu/ci.go: Embeds build path, breaking reproducible builds

From: Vagrant Cascadian <[email-masked]>
Date: Fri, 27 Nov 2020 12:25:05 -0800

On 2020-11-26, Ludovic Courtès wrote:
> Vagrant Cascadian <[email-masked]> skribis:
>> My *wild* guess is it maybe has something to do with the use of
>> canonicalize-path:
>>
>>   (define (find-current-checkout arguments)
>>   "Find the first checkout of ARGUMENTS that provided the current file.
>> Return #f if no such checkout is found."
>>   (let ((current-root
>>          (canonicalize-path
>>           (string-append (dirname (current-filename)) "/.."))))
>>     (find (lambda (argument)
>>             (and=> (assq-ref argument 'file-name)
>>                    (lambda (name)
>>                      (string=? name current-root)))) arguments)))
>
> ‘canonicalize-path’ is called at run time, so that’s fine.  However,
> ‘current-filename’ is a macro that captures the source file name at
> build time, so it’s the likely culprit here.
>
> I was going to go with something like:
>
> diff --git a/gnu/ci.scm b/gnu/ci.scm
> index 5548d9560e..0bacfbe025 100644
> --- a/gnu/ci.scm
> +++ b/gnu/ci.scm
> @@ -488,7 +488,8 @@ valid."
>  Return #f if no such checkout is found."
>    (let ((current-root
>           (canonicalize-path
> -          (string-append (dirname (current-filename)) "/.."))))
> +          (string-append (dirname (search-path %load-path "gnu/ci.scm"))
> +                         "/.."))))
>      (find (lambda (argument)
>              (and=> (assq-ref argument 'file-name)
>                     (lambda (name)
>
> … but I don’t think we can assume that the checkout is in the
> ‘%load-path’ when this code is executed.  WDYT, Mathieu?
>
> Looking at f71b0a0012d46bd30ead1a14ed58fd59647415e2, which introduced
> this, there might be other options too.

This does resolve the reproducibility issues after some "quick" testing;
no idea if it breaks anything, though I didn't see any new test suite
failures (though my builds are patched to skip many tests)...

live well,
  vagrant