Subject: bin/3482: [dM] make botches library OODness
To: None <>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: netbsd-bugs
Date: 04/13/1997 09:39:24
>Number:         3482
>Category:       bin
>Synopsis:       [dM] make botches library OODness
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 13 06:50:04 1997
>Originator:     der Mouse
>Release:        1.2_BETA, partially present in -current
	Any (noticed on a Sun-3/260)
	make(1) (incorrectly) thinks that any .a archive file without a
	table-of-contents is out of date.  In some releases, any .a
	file is assumed to be an archive.
	Extract this sharchive, creating a subdirectory maketest.  Then

	% cd maketest
	% make lib.a			# This run is correct
	cc -O  -c foo.c
	cc -O  -c bar.c
	ar rv lib.a foo.o bar.o
	ar: creating archive lib.a
	a - foo.o
	a - bar.o
	% make lib.a			# This run demonstrates the bug
	ar rv lib.a foo.o bar.o
	ar: creating archive lib.a
	a - foo.o
	a - bar.o

	Redoing the make commands with "-d m" indicates where the bug
	is; make decides lib.a is an archive library, looks for a
	table-of-contents, doesn't find it, and incorrectly decides
	that the archive is therefore out-of-date.

	In 1.2_BETA, make appears to be basing its decision that lib.a
	is an archive library on the name alone.  Changing the Makefile
	command from "ar rv lib.a foo.o bar.o" to "cat foo.o bar.o >
	lib.a" does not affect the misbehavior.  In -current, this is
	not true; make behaves correctly when lib.a is not an archive

	#! /bin/sh
	# Shar: Shell Archiver
	# This archive created Sun Apr 13 09:17:26 1997
	# Run this through sh to create:
	#	maketest/
	#	maketest/Makefile
	#	maketest/foo.c
	#	maketest/bar.c
	mkdir maketest>/dev/null 2>&1
	echo x - maketest/Makefile \(44 characters\)
	sed 's/^X//' > maketest/Makefile << \EOF
	Xlib.a: foo.o bar.o
	X	ar rv lib.a foo.o bar.o
	if test 44 -ne "`wc -c < maketest/Makefile`"
	echo shar: error transmitting maketest/Makefile \(should have been 44 characters\)
	echo x - maketest/foo.c \(16 characters\)
	sed 's/^X//' > maketest/foo.c << \EOF
	Xint foovar = 1;
	if test 16 -ne "`wc -c < maketest/foo.c`"
	echo shar: error transmitting maketest/foo.c \(should have been 16 characters\)
	echo x - maketest/bar.c \(16 characters\)
	sed 's/^X//' > maketest/bar.c << \EOF
	Xint barvar = 1;
	if test 16 -ne "`wc -c < maketest/bar.c`"
	echo shar: error transmitting maketest/bar.c \(should have been 16 characters\)
	exit 0
	# end of shell archive

	Presumably, yank the code that gratuitously (and incorrectly)
	assumes that any archive without a table of contents is
	out-of-date! In arch.c, Arch_LibOODate, there is code which
	specifically declares that an archive library with no TOC is
	out of date.  I claim this code should be yanked; a missing TOC
	is not the same as an out-of-date TOC - and I'm not sure even
	the latter is reason to consider a library out-of-date for
	make's purposes.  IMO make should be basing its actions on what
	is declared in the Makefile (and related files, eg,,
	not on assumptions about how the files named therein are being
	used (eg, "this is an archive library, therefore we will assume
	it is being used to archive .o files and needs a TOC").

					der Mouse

		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B