From lederer@bonn-online.com Wed Oct 6 10:28:15 1999 Return-Path: Received: from circe.tops.net (circe.tops.net [194.162.222.100]) by hub.freebsd.org (Postfix) with ESMTP id 4EF8214CEF for ; Wed, 6 Oct 1999 10:28:10 -0700 (PDT) (envelope-from lederer@bonn-online.com) Received: from bonn-online.com (ppp148.dialin.bonn-online.com [194.162.223.148]) by circe.tops.net (8.9.3/8.9.3) with ESMTP id TAA22721 for ; Wed, 6 Oct 1999 19:25:37 +0200 Message-Id: <37FB860C.86480D6A@bonn-online.com> Date: Wed, 06 Oct 1999 19:25:32 +0200 From: Sebastian Lederer Sender: lederer@bonn-online.com To: FreeBSD-gnats-submit@freebsd.org Subject: make(1) always considers libraries as out-of-date + fix >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: closed >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Oct 6 10:30:01 PDT 1999 >Closed-Date: Sun Oct 10 13:33:29 PDT 1999 >Last-Modified: Sun Oct 10 13:49:41 PDT 1999 >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: State-Changed-From-To: open->closed State-Changed-By: julian State-Changed-When: Sun Oct 10 13:33:29 PDT 1999 State-Changed-Why: patch applied to 4.x and 3.x >Unformatted: A