From owner-freebsd-bugs@FreeBSD.ORG Thu Jun 30 02:50:09 2011 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 476791065670 for ; Thu, 30 Jun 2011 02:50:09 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 1CD0A8FC13 for ; Thu, 30 Jun 2011 02:50:09 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id p5U2o88x093994 for ; Thu, 30 Jun 2011 02:50:08 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id p5U2o8Ll093993; Thu, 30 Jun 2011 02:50:08 GMT (envelope-from gnats) Date: Thu, 30 Jun 2011 02:50:08 GMT Message-Id: <201106300250.p5U2o8Ll093993@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Bruce Evans Cc: Subject: Re: misc/158418: /usr/include librarys broken by unnecessary extra macro indirection. X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Bruce Evans List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Jun 2011 02:50:09 -0000 The following reply was made to PR kern/158418; it has been noted by GNATS. From: Bruce Evans To: Alan Larson Cc: FreeBSD-gnats-submit@freebsd.org, freebsd-bugs@freebsd.org Subject: Re: misc/158418: /usr/include librarys broken by unnecessary extra macro indirection. Date: Thu, 30 Jun 2011 09:55:47 +1000 (EST) On Tue, 28 Jun 2011, Alan Larson wrote: >> Description: > > The macro __aligned(x) is used several places in files in /usr/include, but is only > defined if using a sufficiently new version of GCC, or an Intel compiler. > The definitions are inside an #if __GNUC_PREREQ__(2, 7) and #if defined(__INTEL_COMPILER) > > This breaks things when compiled with PCC or TCC. ( http://pcc.ludd.ltu.se/jira/browse/PCC-18 ) Unfortunately, breaking is the correct behaviour since the ABI depends on the struct layout, so only compilers that support packing and alignment can work. Structs should be layed out more carefully so that packing and alignment directives are never needed, but this is sometimes impossible. >> How-To-Repeat: > > Attempt to compile something that has an #include with TCC (or presumably, PCC). > > Inspection of the code indicates that the same problem is true for __packed . > > Other values are also redefined in those same conditionals, and they probably have > the same problems. The problem outside the kernel doesn't seem to affect much more than , though relatively recently it has spread to some networking headers, especially ipv6 ones. >> Fix: > > > Two likely fixes come to mind: > > 1. Don't use these macro shortcuts, use the __attribute__ form directly. > Many of the files in /usr/include do this, so fixing the remaining ones > would simplify things. It should only take a few minutes to fix them. > There are still lots of places using the __attribute__ form, so this > is a proven safe and reasonable solution. That would enlarge the bug. Doing it for an old version of tcc -Ysystem gives: % "/usr/include/machine/signal.h", line 122: Error: % [Syntax]: Parse error before '__attribute__'. % [Syntax]: Can't recover from this error. since old versions of tcc don't support __attribute__ any more than they support the newer types of attributes like the one for alignment. > 2. If you absolutely must include macros for this, define the macro all the > time. > But seriously, you should take solution #1. The macros are not just shortcuts, but exist primarily to avoid hard-coding gccisms like __attribute__ in lots of places. Bruce