From owner-svn-src-all@FreeBSD.ORG Tue May 22 12:47:48 2012 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D14B8106566C; Tue, 22 May 2012 12:47:48 +0000 (UTC) (envelope-from Hartmut.Brandt@dlr.de) Received: from mailhost.dlr.de (mailhost.dlr.de [129.247.252.32]) by mx1.freebsd.org (Postfix) with ESMTP id 3879D8FC1D; Tue, 22 May 2012 12:47:48 +0000 (UTC) Received: from DLREXHUB01.intra.dlr.de (172.21.152.130) by dlrexedge01.dlr.de (172.21.163.100) with Microsoft SMTP Server (TLS) id 14.2.298.4; Tue, 22 May 2012 14:45:54 +0200 Received: from KNOP-BEAGLE.kn.op.dlr.de (129.247.178.136) by smtp.dlr.de (172.21.152.151) with Microsoft SMTP Server (TLS) id 14.2.298.4; Tue, 22 May 2012 14:45:55 +0200 Date: Tue, 22 May 2012 14:46:01 +0200 From: Hartmut Brandt X-X-Sender: brandt_h@KNOP-BEAGLE.kn.op.dlr.de To: Bruce Evans In-Reply-To: <20120522212307.V1971@besplex.bde.org> Message-ID: References: <201205220723.q4M7Ng2I091715@svn.freebsd.org> <20120522212307.V1971@besplex.bde.org> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [129.247.178.136] Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Hartmut Brandt Subject: Re: svn commit: r235777 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 May 2012 12:47:49 -0000 On Tue, 22 May 2012, Bruce Evans wrote: BE>On Tue, 22 May 2012, Hartmut Brandt wrote: BE> BE>> Log: BE>> Make dumptid non-static. It is used by libkvm to detect whether BE>> this is a VNET-kernel or not. gcc used to put the static symbol into BE>> the symbol table, clang does not. This fixes the 'netstat: no namelist' BE>> error seen on clang+VNET systems. BE>> BE>> Modified: BE>> head/sys/kern/kern_shutdown.c BE> BE>That would be a bug in clang if it were done for static symbols generally, BE>but here the bug seems to be that the symbol is not declared as __used. I don't get this. Why should a symbol declared static be in the symbol table (except for debugging purposes) ? It has internal linkage and so has a meaning only in the given file. What is the linker supposed to do with several static symbols with the same name from several object files? If several files declared static dumptids, which one would kldsym be supposed to return? harti BE> BE>gcc does the same for a file containing only "static int x;", but it BE>is apparently confused by dumptid being initialized non-statically, BE>although the initialization has no side effects. If dumptid were a BE>local variable, then clang would probably warn about the variable being BE>unused, but gcc-4.2.1 never detects such unused variables (thus code BE>that compiles with gcc -Wunused -Werror often fails with clang). Here BE>the initialization is to curthread->td_tid, so it isn't clear if the BE>compiler can tell if it has no side effects. curthread() is actually BE>__curthread(). __curthread() is now declared as __pure2, but that BE>never worked for me with older compilers (its result wasn't cached). BE>If the compilers can tell that the expression has no side effects, BE>then it is another bug that they don't warn about it having no effect BE>when it is only assigned to the apparently-unused variable dumptid. BE> BE>> Modified: head/sys/kern/kern_shutdown.c BE>> ============================================================================== BE>> --- head/sys/kern/kern_shutdown.c Tue May 22 07:04:23 2012 BE>> (r235776) BE>> +++ head/sys/kern/kern_shutdown.c Tue May 22 07:23:41 2012 BE>> (r235777) BE>> @@ -151,7 +151,7 @@ static struct dumperinfo dumper; /* our BE>> BE>> /* Context information for dump-debuggers. */ BE>> static struct pcb dumppcb; /* Registers. */ BE>> -static lwpid_t dumptid; /* Thread ID. */ BE>> +lwpid_t dumptid; /* Thread ID. */ BE>> BE>> static void poweroff_wait(void *, int); BE>> static void shutdown_halt(void *junk, int howto); BE> BE>Now there are 3 bugs instead of 1: BE>- the variable is declared (implicit) extern instead of static BE>- the extern declaration is in a section for static declaration BE>- the variable is still not declared as __used. If the compiler did BE> a more extensive usage analysis, that looked at all object files but BE> not at the libkvm API, then it should remove this variable anyway BE> when it is not declared as __used. BE> BE>Bruce BE> BE>