Add a MKARZERO flag, which invokes ar(1) with the new D flag when it

is set to "yes" -- defaults to "no" except for build.sh builds. This
results in a deterministic .a file rather than one that reflects
timestamps and permissions on the source files.

Also, clean up the ar flags we're using, and remove a redundant use of
ranlib that on a modern POSIX ar can be done with the "s" flag.

Discussed on tech-toolchain
This commit is contained in:
perry 2009-03-13 16:23:31 +00:00
parent 6f8f12ad37
commit 1fd3f53afd
3 changed files with 29 additions and 7 deletions

View File

@ -1,5 +1,5 @@
#! /usr/bin/env sh
# $NetBSD: build.sh,v 1.205 2009/03/09 06:25:51 apb Exp $
# $NetBSD: build.sh,v 1.206 2009/03/13 16:23:31 perry Exp $
#
# Copyright (c) 2001-2009 The NetBSD Foundation, Inc.
# All rights reserved.
@ -271,6 +271,10 @@ initdefaults()
#
setmakeenv BUILDSEED "NetBSD-$(${HOST_SH} ${TOP}/sys/conf/osrelease.sh -m)"
# Set MKARZERO to "yes"
#
setmakeenv MKARZERO "yes"
# Set various environment variables to known defaults,
# to minimize (cross-)build problems observed "in the field".
#
@ -1213,7 +1217,7 @@ createmakewrapper()
eval cat <<EOF ${makewrapout}
#! ${HOST_SH}
# Set proper variables to allow easy "make" building of a NetBSD subtree.
# Generated from: \$NetBSD: build.sh,v 1.205 2009/03/09 06:25:51 apb Exp $
# Generated from: \$NetBSD: build.sh,v 1.206 2009/03/13 16:23:31 perry Exp $
# with these arguments: ${_args}
#

View File

@ -1,4 +1,4 @@
# $NetBSD: bsd.README,v 1.247 2009/02/25 20:36:45 sketch Exp $
# $NetBSD: bsd.README,v 1.248 2009/03/13 16:23:31 perry Exp $
# @(#)bsd.README 8.2 (Berkeley) 4/2/94
This is the README file for the make "include" files for the NetBSD
@ -938,6 +938,15 @@ LIB The name of the library to build.
LIBDIR Target directory for libraries.
MKARZERO Normally, ar(1) sets the timestamps, uid, gid and
permissions in files inside its archives to those of
the file it was fed. This leads to non-reproduceable
builds. If MKARZERO is set to "yes" (default is "no")
then the "D" flag is passed to ar, causing the
timestamp, uid and gid to be zeroed and the file
permissions to be set to 644. This allows .a files
from different builds to be bit identical.
SHLIBINSTALLDIR Target directory for shared libraries if ${USE_SHLIBDIR}
is not "no".

View File

@ -1,4 +1,4 @@
# $NetBSD: bsd.lib.mk,v 1.295 2009/01/17 12:09:58 he Exp $
# $NetBSD: bsd.lib.mk,v 1.296 2009/03/13 16:23:31 perry Exp $
# @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94
.include <bsd.init.mk>
@ -438,21 +438,30 @@ _YLSRCS= ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
realall: ${SRCS} ${ALLOBJS:O} ${_LIBS}
MKARZERO?=no
.if ${MKARZERO} == "yes"
_ARFL=crsD
_INSTRANLIB=
.else
_ARFL=crs
_INSTRANLIB=${empty(PRESERVE):?-a "${RANLIB} -t":}
.endif
# If you change this, please consider reflecting the change in
# the override in sys/rump/Makefile.rump.
.if !target(__archivebuild)
__archivebuild: .USE
${_MKTARGET_BUILD}
rm -f ${.TARGET}
${AR} cq ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
${RANLIB} ${.TARGET}
${AR} ${_ARFL} ${.TARGET} `NM=${NM} ${LORDER} ${.ALLSRC:M*o} | ${TSORT}`
.endif
.if !target(__archiveinstall)
__archiveinstall: .USE
${_MKTARGET_INSTALL}
${INSTALL_FILE} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
${empty(PRESERVE):?-a "${RANLIB} -t":} ${.ALLSRC} ${.TARGET}
${_INSTRANLIB} ${.ALLSRC} ${.TARGET}
.endif
__archivesymlinkpic: .USE