svn commit: r213643 - head/usr.bin/ar

Bruce Evans brde at optusnet.com.au
Sat Oct 9 22:12:06 UTC 2010


On Sat, 9 Oct 2010, Erik Cederstrand wrote:

> Den 09/10/2010 kl. 07.43 skrev Ben Kaduk:
>
>> On Sat, Oct 9, 2010 at 1:31 AM, Tim Kientzle <kientzle at freebsd.org> wrote:
>>> Log:
>>>  Add -D (deterministic) option to ar.
>>>  When set, it forces all timestamps and owners to zero and
>>>  modes to 0644.  Useful for producing libraries that are
>>>  bitwise identical across multiple build runs.
>>
>> Thanks!  Has anyone looked at the feasibility of setting AR?=ar -D in
>> sys.mk?  I will probably try this when I get my scratch box up again.

I hope not.  The default behaviour should not be changed by default.

> I'm looking into this now, as I needed the patch to do binary diffs on builds. One problem is that ARFLAGS is overridden a lot of places in contrib/ code:
>
> contrib/cvs/lib/Makefile.in:67:ARFLAGS=cru
> contrib/cvs/diff/Makefile.in:45:ARFLAGS=cru
> contrib/ntp/libntp/Makefile.in:55:ARFLAGS=cru
> contrib/ntp/libparse/Makefile.in:55:ARFLAGS=cru
> contrib/ntp/arlib/Makefile.in:54:ARFLAGS=cru
> contrib/ntp/ntpd/Makefile.in:61:ARFLAGS=cru
> contrib/tcp_wrappers/Makefile:95:ARFLAGS=rv
> contrib/tcp_wrappers/Makefile:101:ARFLAGS=rv
> [...]
> contrib/tcp_wrappers/Makefile:404:ARFLAGS=rv
> contrib/bind9/configure.in:73:ARFLAGS=cruv
> contrib/gcclibs/libcpp/Makefile.in:30:ARFLAGS=cru
> contrib/gcclibs/libdecnumber/Makefile.in:30:ARFLAGS=cru
> contrib/dtc/Makefile:49:ARFLAGS=rc
> crypto/heimdal/appl/ftp/common/Makefile.in:93:ARFLAGS=cru
> crypto/heimdal/appl/telnet/libtelnet/Makefile.in:93:ARFLAGS=cru
> crypto/heimdal/lib/45/Makefile.in:101:ARFLAGS=cru
> crypto/openssl/Makefile.org:66:ARFLAGS=
> crypto/openssl/Makefile:68:ARFLAGS=

Something like this seems to be needed, since the default flags in sys.mk
of:

> share/mk/sys.mk:36:ARFLAGS?=-rv
> share/mk/sys.mk:38:ARFLAGS?=rl
> usr.bin/make/PSD.doc/tutorial.ms:2968:ARFLAGS?=crl

are almost as bad as -D there.  -rv is for the %POSIX case.  The -v
in it makes it wrong for most uses, especially when make output is
supposed to be quieted by -s.  At least it uses the newfangled option
syntax (starting with a '-').  rl is for the usual case.  The `l' flag
is bogus since it was documented as accepted but not used.  Now it
seems to be undocumented, but still accepted but not used.  The `r'
flag is normally wanted, but most places also want 'c' and possibly
'u'.

Having anything in the default ARFLAGS is bad since (except in the
%POSIX case) its contents is undocumented so it is hard to tell what
precautions should be taken to avoid bad things in it.  There seems
to be no way to cancel bad things in it by adding to it, so makefiles
wanting to use the default would have to use something like
substitutions in it.  E.g.:

%%%
ARFLAGS:=	${ARFLAGS:S/l//}	# remove nonsense flag 'l'
ARFLAGS:=	${ARFLAGS:S/D//}	# remove unwanted flag 'v'
foo:
 	echo ${ARFLAGS}
%%%

But it is easier to blow away the garbage using ARFLAGS=cru.  There were
few or no flags like -D that could reasonably set outside of sys.mk,
according to user or system preferences, so that no Makefile should touch
them.  Perhaps -v is another one -- setting this wouldn't change the
created archives, but might be useful for debugging.

The primary user of ${AR} for FreeBSD builds, namely bsd.lib.mk, doesn't
even use ${ARFLAGS}, so it is missing from the above list.  It uses the
literal `cq' whenever it uses the non-literal ${AR}.  Perhaps ar is often
spelled `ar' too.

Bruce


More information about the svn-src-all mailing list