NetBSD Problem Report #42381

From martin@aprisoft.de  Thu Nov 26 11:33:28 2009
Return-Path: <martin@aprisoft.de>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id B031563B8B4
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 26 Nov 2009 11:33:28 +0000 (UTC)
Message-Id: <20091126113321.3FA3AAF5827@emmas.aprisoft.de>
Date: Thu, 26 Nov 2009 12:33:21 +0100 (CET)
From: martin@NetBSD.org
Reply-To: martin@NetBSD.org
To: gnats-bugs@gnats.NetBSD.org
Subject: LD_ADD.$name does not work as expected
X-Send-Pr-Version: 3.95

>Number:         42381
>Category:       bin
>Synopsis:       LD_ADD.$name does not work as expected
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Nov 26 11:35:00 +0000 2009
>Last-Modified:  Mon Dec 14 02:05:02 +0000 2009
>Originator:     Martin Husemann
>Release:        NetBSD 5.99.22
>Organization:
The NetBSD Foundation, Inc.
>Environment:
System: NetBSD nelly.aprisoft.de 5.99.22 NetBSD 5.99.22 (NELLY.MP) #86: Tue Nov 24 10:38:02 CET 2009 martin@emmas.aprisoft.de:/nelly/usr/src/sys/arch/sparc64/compile/NELLY.MP sparc64
Architecture: sparc64
Machine: sparc64
>Description:

Investigating why the t_lwpctl test fails for me I found that it happens
because the test is linked against libpthread and libpthread already uses
_lwp_ctl(2) for it's own purposes.

Looking at the makefile it seems there is no good reason for this test
linking against libpthread, as the author tried to only add pthreads for
a single test.

This change fixes the build for t_lwpctl and makes the test succeed, but
of course is not the right thing to do:

Index: Makefile
===================================================================
RCS file: /cvsroot/src/tests/kernel/Makefile,v
retrieving revision 1.2
diff -u -r1.2 Makefile
--- Makefile	8 Sep 2009 20:37:45 -0000	1.2
+++ Makefile	26 Nov 2009 11:33:06 -0000
@@ -21,7 +21,7 @@

 TESTS_SH=	t_umount

-LDADD.t_rnd+=  -lrumpvfs -lrumpdev_rnd -lrumpdev -lrump -lrumpuser -lpthread
+# LDADD.t_rnd+=  -lrumpvfs -lrumpdev_rnd -lrumpdev -lrump -lrumpuser -lpthread

 .PATH:			${NETBSDSRCDIR}/sys/kern
 TESTS_C+=		t_extent


>How-To-Repeat:

cd  /usr/src/tests/kernel && make
Watch the command line for t_lwpctl.

>Fix:
n/a

>Audit-Trail:
From: Alan Barrett <apb@cequrux.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/42381: LD_ADD.$name does not work as expected
Date: Thu, 26 Nov 2009 12:33:50 +0000

 Most of the bsd.*.mk files are written with the assumption that
 each program will be built from a separate source directory.
 However, src/tests/kernel/Makefile attempts to build several programs
 from the same source directory.  That ends up in trouble when line
 268 of bsd.prog.mk does this:

 LDADD+=     ${LDADD.${_P}}

 which it will repeat once for each program.  The intent is to append
 LDADD.t_rnd to LDADD while building the t_rnd program, but the
 effect is to append LDADD.t_rnd to LDADD while building other
 programs in the src/tests/kernel directory.

 bsd.prog.mk also does this:

 _LDADD.${_P}=           ${LDADD}    ${LDADD.${_P}}

 and I believe that the fix would be to remove the "LDADD+=${LDADD.${_P}}"
 and rewrite relevant rules in terms of ${_LDADD.${_P}} (note the
 underline) instead of ${LDADD}.  Similarly for several other variables in
 bsd.prog.mk.

 --apb (Alan Barrett)

From: Masao Uebayashi <uebayasi@tombi.co.jp>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, martin@NetBSD.org
Subject: Re: bin/42381: LD_ADD.$name does not work as expected
Date: Thu, 26 Nov 2009 21:50:23 +0900

 > bsd.prog.mk also does this:
 >
 > _LDADD.${_P}=           ${LDADD}    ${LDADD.${_P}}
 >
 > and I believe that the fix would be to remove the "LDADD+=${LDADD.${_P}}"
 > and rewrite relevant rules in terms of ${_LDADD.${_P}} (note the
 > underline) instead of ${LDADD}.  Similarly for several other variables in
 > bsd.prog.mk.

 I've never liked these .for loops handling multiple PROGS / LIBS in bsd.prog.mk
 / bsd.lib.mk.  Because of them these files are almost impossible to maintain.

 I wonder if it's possible to put multiple makefiles in a single directory
 (not one Makefile with PROGS=foo bar, but foo.mk and bar.mk.)

 Masao

 -- 
 Masao Uebayashi / Tombi Inc. / Tel: +81-90-9141-4635

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/42381: LD_ADD.$name does not work as expected
Date: Mon, 14 Dec 2009 02:01:49 +0000

 On Thu, Nov 26, 2009 at 12:55:02PM +0000, Masao Uebayashi wrote:
  > I've never liked these .for loops handling multiple PROGS / LIBS
  > in bsd.prog.mk / bsd.lib.mk.  Because of them these files are
  > almost impossible to maintain.

 Me either.

 In other (smaller) situations where I've wanted this functionality
 I've generally set up separate "prog.mk" and "progs.mk" (or
 "manyprogs.mk" or whatever) make fragments with the common stuff
 shared under the covers. But refitting our stuff to work this way
 would be a fairly miserable job I think.

  >  I wonder if it's possible to put multiple makefiles in a single directory
  >  (not one Makefile with PROGS=foo bar, but foo.mk and bar.mk.)

 It's probably better just to make more directories. :-/

 -- 
 David A. Holland
 dholland@netbsd.org

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.