public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: Jon Turney <jon.turney@dronecode.org.uk>
Cc: cygwin-patches@cygwin.com
Subject: Re: [PATCH] Add initial support for SOURCE_DATE_EPOCH
Date: Fri, 8 Sep 2023 16:09:24 +0200	[thread overview]
Message-ID: <ZPsrFKgcmt2qrH34@calimero.vinschen.de> (raw)
In-Reply-To: <a1890367-b100-2321-aca4-17eec98ebba7@t-online.de>

Jon,

you did all the latest work in terms of the build machinery.
Would you mind to review this patch, please?


Thanks,
Corinna

On Sep  5 19:01, Christian Franke wrote:
> This patch enables reproducible builds of cygwin package in conjunction with
> this cygport patch:
> https://sourceware.org/pipermail/cygwin-apps/2023-August/043108.html
> 
> cygwin.cygport was enhanced for the test as described in the above post.
> 
> If the same build path, SOURCE_DATE_EPOCH and toolchain are used, rebuilds
> with cygport produce identical distribution tarballs. Adding proper
> -fmacro-prefix-map gcc options (or remove all usages of __FILE__) could
> possibly make this independent from the build path.
> 
> Note that 'u' (replace with newer objects only) flag needed to be removed
> from ar commands because it is incompatible with 'D' (deterministic
> archive). I don't expect any negative effect because existing .a files are
> always removed before ar is run.
> 
> Not yet tested with different machines or different users accounts.
> 
> Patch would be much simpler (mkvers.sh only) if binutils would support
> SOURCE_DATE_EPOCH directly.
> 
> -- 
> Regards,
> Christian
> 

> From b877330d53b95a88f1aef0fa3d14e97910d9dd2a Mon Sep 17 00:00:00 2001
> From: Christian Franke <christian.franke@t-online.de>
> Date: Tue, 5 Sep 2023 18:32:49 +0200
> Subject: [PATCH] Add initial support for SOURCE_DATE_EPOCH
> 
> If specified, set version timestamp to this value.
> Enable deterministic archives for ar and ranlib.
> Set cygwin1.dll PE and export table header timestamps
> to zero.
> 
> Signed-off-by: Christian Franke <christian.franke@t-online.de>
> ---
>  winsup/cygwin/Makefile.am       | 6 ++++++
>  winsup/cygwin/scripts/mkimport  | 6 +++++-
>  winsup/cygwin/scripts/mkvers.sh | 4 ++--
>  winsup/cygwin/scripts/speclib   | 6 +++++-
>  4 files changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/winsup/cygwin/Makefile.am b/winsup/cygwin/Makefile.am
> index 9912b5399..64b252a22 100644
> --- a/winsup/cygwin/Makefile.am
> +++ b/winsup/cygwin/Makefile.am
> @@ -572,6 +572,10 @@ toollib_DATA = \
>  libgmon_a_SOURCES = $(GMON_FILES)
>  libgmon_a_LIBADD =
>  
> +# Enable deterministic archives for reproducible builds.
> +ARFLAGS = cr$${SOURCE_DATE_EPOCH:+D}
> +override RANLIB := $(RANLIB)$${SOURCE_DATE_EPOCH:+ -D}
> +
>  # cygserver library
>  cygserver_blddir = ${target_builddir}/winsup/cygserver
>  LIBSERVER = $(cygserver_blddir)/libcygserver.a
> @@ -589,12 +593,14 @@ $(LDSCRIPT): $(LDSCRIPT).in
>  	$(AM_V_GEN)$(CC) -E - -P < $^ -o $@
>  
>  # cygwin dll
> +# Set PE and export table header timestamps to zero for reproducible builds.
>  $(NEW_DLL_NAME): $(LDSCRIPT) libdll.a $(VERSION_OFILES) $(LIBSERVER)\
>  		  $(newlib_build)/libm.a $(newlib_build)/libc.a
>  	$(AM_V_CXXLD)$(CXX) $(CXXFLAGS) \
>  	-mno-use-libstdc-wrappers \
>  	-Wl,--gc-sections -nostdlib -Wl,-T$(LDSCRIPT) \
>  	-Wl,--dynamicbase -static \
> +	$${SOURCE_DATE_EPOCH:+-Wl,--no-insert-timestamp} \
>  	-Wl,--heap=0 -Wl,--out-implib,cygdll.a -shared -o $@ \
>  	-e @DLL_ENTRY@ $(DEF_FILE) \
>  	-Wl,-whole-archive libdll.a -Wl,-no-whole-archive \
> diff --git a/winsup/cygwin/scripts/mkimport b/winsup/cygwin/scripts/mkimport
> index 7684a8f0e..9517c4e9e 100755
> --- a/winsup/cygwin/scripts/mkimport
> +++ b/winsup/cygwin/scripts/mkimport
> @@ -92,8 +92,12 @@ for my $f (keys %text) {
>      }
>  }
>  
> +# Enable deterministic archives for reproducible builds.
> +my $opts = 'crs';
> +$opts .= 'D' if ($ENV{'SOURCE_DATE_EPOCH'} != '');
> +
>  unlink $libdll;
> -system $ar, 'crus', $libdll, glob('*.o'), @ARGV;
> +system $ar, $opts, $libdll, glob('*.o'), @ARGV;
>  unlink glob('*.o');
>  exit 1 if $?;
>  
> diff --git a/winsup/cygwin/scripts/mkvers.sh b/winsup/cygwin/scripts/mkvers.sh
> index 96af936ec..38f439cd0 100755
> --- a/winsup/cygwin/scripts/mkvers.sh
> +++ b/winsup/cygwin/scripts/mkvers.sh
> @@ -56,9 +56,9 @@ parse_preproc_flags $CC
>  
>  
>  #
> -# Load the current date so we can work on individual fields
> +# Load the current date (or SOURCE_DATE_EPOCH) so we can work on individual fields
>  #
> -set -$- $(date -u +"%m %d %Y %H:%M")
> +set -$- $(date ${SOURCE_DATE_EPOCH:+-d @}${SOURCE_DATE_EPOCH} -u +"%m %d %Y %H:%M")
>  m=$1 d=$2 y=$3 hhmm=$4
>  #
>  # Set date into YYYY-MM-DD HH:MM:SS format
> diff --git a/winsup/cygwin/scripts/speclib b/winsup/cygwin/scripts/speclib
> index e6d4d8e94..41a3a8e13 100755
> --- a/winsup/cygwin/scripts/speclib
> +++ b/winsup/cygwin/scripts/speclib
> @@ -74,7 +74,11 @@ EOF
>  close $as_fd or exit 1;
>  system $objcopy, '-j', '.idata$7', $iname_o;
>  
> -$res = system $ar, 'crus', $lib, sort keys %extract;
> +# Enable deterministic archives for reproducible builds.
> +my $opts = 'crs';
> +$opts .= 'D' if ($ENV{'SOURCE_DATE_EPOCH'} != '');
> +
> +$res = system $ar, $opts, $lib, sort keys %extract;
>  unlink keys %extract;
>  die "$0: ar creation of $lib exited with non-zero status\n" if $res;
>  exit 0;
> -- 
> 2.39.0
> 


  reply	other threads:[~2023-09-08 14:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-05 17:01 Christian Franke
2023-09-08 14:09 ` Corinna Vinschen [this message]
2023-09-10 14:41   ` Jon Turney
2023-09-10 17:32     ` Christian Franke

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=ZPsrFKgcmt2qrH34@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin-patches@cygwin.com \
    --cc=jon.turney@dronecode.org.uk \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).