NetBSD Problem Report #48303
From www@NetBSD.org Sat Oct 12 10:03:30 2013
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 7945F7263E
for <gnats-bugs@gnats.NetBSD.org>; Sat, 12 Oct 2013 10:03:30 +0000 (UTC)
Message-Id: <20131012100329.3750A72642@mollari.NetBSD.org>
Date: Sat, 12 Oct 2013 10:03:29 +0000 (UTC)
From: justin@specialbusservice.com
Reply-To: justin@specialbusservice.com
To: gnats-bugs@NetBSD.org
Subject: Linux cross build fails on ppc
X-Send-Pr-Version: www-1.0
>Number: 48303
>Category: toolchain
>Synopsis: Linux cross build fails on ppc
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: toolchain-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Oct 12 10:05:01 +0000 2013
>Last-Modified: Mon Oct 28 13:10:01 +0000 2013
>Originator: Justin Cormack
>Release: cvs head
>Organization:
>Environment:
Linux pike 3.6.7-4.fc17.ppc64 #1 SMP Thu Dec 6 06:41:58 MST 2012 ppc64 ppc64 ppc64 GNU/Linux
>Description:
I am trying to cross build NetBSD on ppc:
./build.sh -m evbppc build
This fails with
# compile compat/raise_default_signal.lo
cc -O -I. -I./include -I/home/justin/src/tools/compat -I/home/justin/src/tools/compat/sys -DHAVE_NBTOOL_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D__DBINTERFACE_PRIVATE -c -o raise_default_signal.lo.o /home/justin/src/tools/compat/../../lib/libutil/raise_default_signal.c
In file included from /usr/include/signal.h:359:0,
from /home/justin/src/tools/compat/../../lib/libutil/raise_default_signal.c:42:
/usr/include/sys/ucontext.h:101:16: error: expected identifier or '(' before '[' token
*** Failed target: raise_default_signal.lo
The issue in that that Linux header has a field called __unused:
typedef struct {
unsigned long __unused[4];
(which Linux does quite a bit); however __unused has been #defined to an empty string so it will not compile.
>How-To-Repeat:
Cross build from recent ppc linux.
>Fix:
I would be surprised if this hasnt been worked around elsewhere, as Linux uses __unused a fair amount in headers. It would seem best to use something else to avoid collisions.
>Release-Note:
>Audit-Trail:
From: Justin Cormack <justin@specialbusservice.com>
To: gnats-bugs@netbsd.org, tech-toolchain@netbsd.org
Cc:
Subject: Re: install/48303: Linux cross build fails on ppc
Date: Mon, 28 Oct 2013 10:32:54 +0000
I looked at where this was being redefined and it is in compat_defs.h
and the following patch fixes this issue, which makes it somewhat
simpler than I thought to fix. The only question is whether undefining
__unused is necessary on some other platform, in which case the
#define __unused could be wrapped eg in #ifndef __linux__ which should
be safe.
cvs diff -u tools/compat/compat_defs.h
Index: tools/compat/compat_defs.h
===================================================================
RCS file: /cvsroot/src/tools/compat/compat_defs.h,v
retrieving revision 1.93
diff -u -r1.93 compat_defs.h
--- tools/compat/compat_defs.h 24 Oct 2013 13:59:47 -0000 1.93
+++ tools/compat/compat_defs.h 28 Oct 2013 10:26:16 -0000
@@ -130,7 +130,6 @@
#undef __restrict
#define __restrict
#undef __unused
-#define __unused
#undef __arraycount
#define __arraycount(__x) (sizeof(__x) / sizeof(__x[0]))
#undef __USE
On Sat, Oct 12, 2013 at 11:05 AM, <gnats-admin@netbsd.org> wrote:
> Thank you very much for your problem report.
> It has the internal identification `install/48303'.
> The individual assigned to look at your
> report is: install-manager.
>
>>Category: install
>>Responsible: install-manager
>>Synopsis: Linux cross build fails on ppc
>>Arrival-Date: Sat Oct 12 10:05:01 +0000 2013
>
Responsible-Changed-From-To: install-manager->toolchain-manager
Responsible-Changed-By: martin@NetBSD.org
Responsible-Changed-When: Mon, 28 Oct 2013 10:49:09 +0000
Responsible-Changed-Why:
Not an installer issue
From: Alan Barrett <apb@cequrux.com>
To: gnats-bugs@netbsd.org
Cc:
Subject: Re: install/48303: Linux cross build fails on ppc
Date: Mon, 28 Oct 2013 14:57:38 +0200
On Mon, 28 Oct 2013, Justin Cormack wrote:
>I looked at where this was being redefined and it is in compat_defs.h
>and the following patch fixes this issue, which makes it somewhat
>simpler than I thought to fix. The only question is whether undefining
>__unused is necessary on some other platform, in which case the
>#define __unused could be wrapped eg in #ifndef __linux__ which should
>be safe.
Is the Linux use of "__unused" as a struct member name something new?
Did you test a complete build with your patch? The reason for the
"#define __unused", which has been in compat_defs.h since 2006-10-12, is
to deal with code that uses __unused in the NetBSD way, like
sometype varname __unused;
and if __unused is not defined then such code would cause a syntax
error. There seems to be such code in src/usr.sbin/makefs, which would
be built from src/tools/makefs. There might also be more uses of
__unused in the tools build.
--apb (Alan Barrett)
From: Justin Cormack <justin@specialbusservice.com>
To: gnats-bugs@netbsd.org
Cc: toolchain-manager@netbsd.org, gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org
Subject: Re: install/48303: Linux cross build fails on ppc
Date: Mon, 28 Oct 2013 13:07:39 +0000
On Mon, Oct 28, 2013 at 1:00 PM, Alan Barrett <apb@cequrux.com> wrote:
> The following reply was made to PR toolchain/48303; it has been noted by GNATS.
>
> From: Alan Barrett <apb@cequrux.com>
> To: gnats-bugs@netbsd.org
> Cc:
> Subject: Re: install/48303: Linux cross build fails on ppc
> Date: Mon, 28 Oct 2013 14:57:38 +0200
>
> On Mon, 28 Oct 2013, Justin Cormack wrote:
> >I looked at where this was being redefined and it is in compat_defs.h
> >and the following patch fixes this issue, which makes it somewhat
> >simpler than I thought to fix. The only question is whether undefining
> >__unused is necessary on some other platform, in which case the
> >#define __unused could be wrapped eg in #ifndef __linux__ which should
> >be safe.
>
> Is the Linux use of "__unused" as a struct member name something new?
It is generally only found in non-x86 architectures, although it is
also in some versions of struct stat on x86.
> Did you test a complete build with your patch? The reason for the
> "#define __unused", which has been in compat_defs.h since 2006-10-12, is
> to deal with code that uses __unused in the NetBSD way, like
>
> sometype varname __unused;
>
> and if __unused is not defined then such code would cause a syntax
> error. There seems to be such code in src/usr.sbin/makefs, which would
> be built from src/tools/makefs. There might also be more uses of
> __unused in the tools build.
Yes, apologies this patch will not work, the build eventually fails.
I have filed a patch against glibc
https://sourceware.org/ml/libc-alpha/2013-10/msg00870.html not sure if
they will respond. It will still take a few years to filter to end
user machines, so perhaps at least a note on the README in the compat
directory could be helpful if there is really no way to fix this.
Justin
>Unformatted:
(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.