Subject: Re: bug#79082: [emacs-bug] bug#79082: 30.1; [reproducibility] sysinfo call during profile dump

From: Eli Zaretskii <[email-masked]>
Date: Tue, 29 Jul 2025 14:26:43 +0300

> Date: Tue, 29 Jul 2025 10:57:21 +0200
> From: "Dr. Werner Fink" <[email-masked]>
> Cc: [email-masked], [email-masked], [email-masked]
> 
> I know as this was derived from master for 30.1.  In the attachment I've
> skipped that and moved from will_dump_p() to !build_details, switched from
> secure_getnev() to getenv(), and add a comment about SOURCE_DATE_EPOCH.
> 
> > > --- src/timefns.c
> > > +++ src/timefns.c	2025-07-11 07:32:33.928031852 +0000
> > > @@ -600,6 +600,40 @@ make_lisp_time (struct timespec t)
> > >  Lisp_Object
> > >  timespec_to_lisp (struct timespec t)
> > >  {
> > > +  if (will_dump_p())	/* Use provided epoch at dump to get reproducible pdmp images */
> > > +    {
> > > +      char *epoch;
> > > +      epoch = secure_getenv("SOURCE_DATE_EPOCH");
> > 
> > secure_getenv is specific to glibc.  If we want to use it on other
> > platforms, we need to import the Gnulib secure_getenv module.
> > 
> > We should also make sure this change doesn't interfere with the build,
> > since we do have code in Emacs that manipulates time and is used
> > during the build.
> 
> That is the reason to use timespec_to_lisp() as these seems to be called
> only once at start of the internal lisp engine.

I'm not sure we can rely on that.  Some future change might call it
more than once, in which case it will return the same value and could
break something.

So I would prefer making such changes where the time value is used in
a way that it makes the build not reproducible, instead of changing a
low-level function that can be used in other context.

> In my spec file I use the line
> 
>  SOURCE_DATE_EPOCH="$(sed -n '/^----/n;s/ - .*$//;p;q' emacs.changes| date -u -f - +%%s)"
>  export SOURCE_DATE_EPOCH
> 
> with the changelog which gets added to the spec file.

Isn't this completely unportable?