From owner-freebsd-bugs Wed Oct 6 10:31:26 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 6134314D34 for ; Wed, 6 Oct 1999 10:31:22 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id KAA34740; Wed, 6 Oct 1999 10:30:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) 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 To: FreeBSD-gnats-submit@freebsd.org Subject: bin/14167: make(1) always considers libraries as out-of-date + fix Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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