Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 06 Oct 1999 19:25:32 +0200
From:      Sebastian Lederer <lederer@bonn-online.com>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/14167: make(1) always considers libraries as out-of-date + fix
Message-ID:  <37FB860C.86480D6A@bonn-online.com>

next in thread | raw e-mail | index | archive | help

>Number:         14167
>Category:       bin
>Synopsis:       make(1) always considers libraries as out-of-date + fix
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct  6 10:30:01 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     Sebastian Lederer
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
none
>Environment:

FreeBSD rain 4.0-CURRENT FreeBSD 4.0-CURRENT #18: Sat Sep 18 21:12:21
CEST 1999     root@rain:/usr/src/sys/compile/RAIN  i386

The bug probably exists on all FreeBSD ELF systems.

>Description:

When you have static libraries as targets in makefiles, make always
thinks they
are out of date and rebuilds them.

>How-To-Repeat:

Create the following Makefile:
--- Makefile ---------------------------
libtest.a: test.o
	ar rv $@ test.o
	ranlib $@
----------------------------------------
and a file 'test.c':
---- test.c ----------------------------
void test()
{
}
----------------------------------------

Then, type 'make' multiple times. The library libtest.a is always
rebuilt.
Using 'make -dm' shows:
------------------------------------------------------
$ make -dm
Examining test.c...modified 23:17:03 Oct 05, 1999...up-to-date.
Examining test.o...modified 23:17:40 Oct 05, 1999...up-to-date.
Examining libtest.a...modified 18:52:12 Oct 06, 1999...library...No
t.o.c....out-of-date.
								  ^^^^^^^^
ar rv libtest.a test.o
r - test.o
ranlib libtest.a
update time: 18:52:14 Oct 06, 1999
-------------------------------------------------------

It appears that make fails to read the global symbol table of the
archive file,
making it think that the library needs to be rebuilt (see the 'No
t.o.c.'
part).

>Fix:

The problem is in the file /usr/src/usr.bin/make/arch.c in line 809,
ArchFindMember(). The code is trying to remove path name components from
the
file names in the archive, by skipping everything up to the last '/'
character.
With ELF style linking, the global symbol table is named '/' in the
archive,
and the code at line 809 messes it up, so the symbol table is never
found.

Apply the following patch in /usr/src/usr.bin/make :
---------------------------------------------------
--- arch.c.orig	Tue Oct  5 22:45:25 1999
+++ arch.c	Wed Oct  6 12:02:29 1999
@@ -807,7 +807,7 @@
      * the comparisons easier...
      */
     cp = strrchr (member, '/');
-    if (cp != (char *) NULL) {
+    if ((cp != NULL) && (strcmp(member, RANLIBMAG) != 0)) {
 	member = cp + 1;
     }
     len = tlen = strlen (member);

---------------------------------------------------


The same code fragment (with the special case added) already exists at
line 479
in ArchStatMember(), which calls ArchFindMember(). I have copied it from
there,
so it is probably safe to assume that this patch does not break
anything. And
it corrects the problem, too. With the patch applied, 'make -dm'
produces:
--------------------------------
$ /usr/obj/usr/src/usr.bin/make/make -dm
Examining test.c...modified 23:17:03 Oct 05, 1999...up-to-date.
Examining test.o...modified 23:17:40 Oct 05, 1999...up-to-date.
Examining libtest.a...modified 18:52:14 Oct 06, 1999...library.../
modified 18:52:14 Oct 06, 1999...up-to-date.
`libtest.a' is up to date.
--------------------------------

-- 
Sebastian Lederer
lederer@bonn-online.com

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?37FB860C.86480D6A>