Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Sep 2020 15:58:15 +0100
From:      Bob Eager <rde@tavi.co.uk>
To:        freebsd-ports@freebsd.org
Subject:   Re: pkg-fallout: duplicate symbols?
Message-ID:  <20200902155815.62588c0d@raksha.tavi.co.uk>
In-Reply-To: <slrnrkvbuk.1lm.naddy@lorvorc.mips.inka.de>
References:  <slrnrk29h7.2oqq.naddy@lorvorc.mips.inka.de> <9A44A7E3-B911-4D40-B34F-FC1A9E844D31@FreeBSD.org> <slrnrkvbuk.1lm.naddy@lorvorc.mips.inka.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 2 Sep 2020 14:44:36 -0000 (UTC)
Christian Weisgerber <naddy@mips.inka.de> wrote:

> On 2020-08-22, Dimitry Andric <dim@FreeBSD.org> wrote:
> 
> > It can be worked around by adding -fcommon to the compilation
> > flags, but in most cases it should not be too difficult to get rid
> > of the multiply defined symbols.  
> 
> Right.
> In C, a global is _defined_ in one object file and _declared_ when
> it is referenced from elsewhere.  See Kernighan & Ritchie.  Commons
> are a linker artifact that was never part of the C language, as far
> as I can tell.
> 
> Most instances turned up by -fno-common are accidental double
> definitions of the same global, so you only need to turn the extra
> definitions into declarations.  However, in some cases they were
> actually intended as separate variables and have been merged by
> accident.  In those cases, they should be renamed or made local
> with "static".

In some cases, it is deliberate. An initialised, but declared, global
is used as a 'weak' global that can be overridden by checking its value.

I maintain one port that does this!



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20200902155815.62588c0d>