NetBSD Problem Report #45098

From stix@stix.id.au  Thu Jun 23 15:43:47 2011
Return-Path: <stix@stix.id.au>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id E796563C4CA
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 23 Jun 2011 15:43:46 +0000 (UTC)
Message-Id: <20110623141934.8502B68982@stix.id.au>
Date: Fri, 24 Jun 2011 00:19:34 +1000 (EST)
From: stix@stix.id.au
Reply-To: stixpjr@gmail.com
To: gnats-bugs@gnats.NetBSD.org
Subject: Cross build on Mac OS X 10.7.0 fails
X-Send-Pr-Version: 3.95

>Number:         45098
>Category:       toolchain
>Synopsis:       Cross build on Mac OS X 10.7.0 fails
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    toolchain-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jun 23 15:45:00 +0000 2011
>Closed-Date:    Wed Nov 13 18:07:53 +0000 2019
>Last-Modified:  Wed Nov 13 18:07:53 +0000 2019
>Originator:     Paul Ripke
>Release:        Darwin 10.7.0
>Organization:
Paul Ripke
I love deadlines. I like the whooshing sound they make as they fly by.
-- Douglas Adams
>Environment:
Darwin stix-macbookair.local 10.7.0 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386
Host compiler is:
bash$ gcc -v
Using built-in specs.
Target: i686-apple-darwin10
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2335.15~13/src/configure --disable-checking --enable-werror --prefix=/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin10 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2335.15~13/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin10- --host=x86_64-apple-darwin10 --target=i686-apple-darwin10 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)

Architecture: i386
Machine: i386
>Description:
Attempting to cross-build a NetBSD release (i386 at least, probably any target),
results in a SEGV running the toolchain lint1. Debugging, this is due to the
union assignment in:

src/usr.bin/xlint/lint1/tree.c: getcnode():
        n->tn_val->v_ansiu = v->v_ansiu;
        n->tn_val->v_u = v->v_u;        /* crash */
        free(v);

The host compiler generates a pair of movaps instructions, which require 16
byte alignment, the code defaults to an 8 byte alignment.

>How-To-Repeat:
Attempt to build NetBSD on Mac OS X 10.7.0.
>Fix:
Following hacky patch works:

Index: usr.bin/xlint/lint1/lint1.h
===================================================================
RCS file: /Volumes/netbsd/cvsroot/src/usr.bin/xlint/lint1/lint1.h,v
retrieving revision 1.24
diff -u -d -r1.24 lint1.h
--- usr.bin/xlint/lint1/lint1.h 2 Oct 2009 19:01:14 -0000       1.24
+++ usr.bin/xlint/lint1/lint1.h 23 Jun 2011 07:35:01 -0000
@@ -40,6 +40,11 @@
 #define ALIGN(x) (((x) + 7) & ~7)
 #endif

+#ifdef __APPLE__
+#undef ALIGN
+#define ALIGN(x) (((x) + 15) & ~15)
+#endif
+
 /*
  * Describes the position of a declaration or anything else.
  */

>Release-Note:

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: toolchain/45098: Cross build on Mac OS X 10.7.0 fails
Date: Fri, 24 Jun 2011 10:20:29 +0200

 The ifdef should not trigger on __APPLE__, as there is nothing apple related
 in here. The alignement is wrong for every arch where sizeof(ldbl_t) is
 larger than 8. But for a simpler fix, I would suggest to just change it
 to 16, unconditionally, and adding a commpile time assert.

 Martin

From: Paul Ripke <stixpjr@gmail.com>
To: gnats-bugs@netbsd.org
Cc: toolchain-manager@netbsd.org, gnats-admin@netbsd.org, 
	netbsd-bugs@netbsd.org
Subject: Re: toolchain/45098: Cross build on Mac OS X 10.7.0 fails
Date: Fri, 24 Jun 2011 19:53:23 +1000

 --0016368e2b7f25fc8504a6722c1f
 Content-Type: text/plain; charset=ISO-8859-1

 I guess you could always do:

 #undef ALIGN
 #define ALIGN(x) (((x) + sizeof(ldbl_t) - 1) & ~(sizeof(ldbl_t) - 1))

 but there's probably some crazy architecture with 6 byte long doubles.
 Yes, you could round up to a power of two... but really, why bother?
 So, just go with the following?

 #undef ALIGN
 #define ALIGN(x) (((x) + 15) & ~15)

 -- 
 Paul Ripke
 Ubi dubium ibi libertas

 --0016368e2b7f25fc8504a6722c1f
 Content-Type: text/html; charset=ISO-8859-1
 Content-Transfer-Encoding: quoted-printable

 I guess you could always do:<div><br></div><div><div><div>#undef ALIGN</div=
 ><div>#define ALIGN(x) (((x) + sizeof(ldbl_t) - 1) &amp; ~(sizeof(ldbl_t) -=
  1))<br clear=3D"all"></div></div></div><div><br></div><div>but there&#39;s=
  probably some crazy architecture with 6 byte long doubles.</div>
 <div>Yes, you could round up to a power of two... but really, why bother?</=
 div><div>So, just go with the following?</div><div><br></div><div><div>#und=
 ef ALIGN</div><div>#define ALIGN(x) (((x) + 15) &amp; ~15)<br clear=3D"all"=
 >
 </div></div><div><br></div><div>--=A0</div><div>Paul Ripke<br>Ubi dubium ib=
 i libertas<br>
 </div>

 --0016368e2b7f25fc8504a6722c1f--

State-Changed-From-To: open->closed
State-Changed-By: maya@NetBSD.org
State-Changed-When: Wed, 13 Nov 2019 18:07:53 +0000
State-Changed-Why:
Should be fixed. Most likely by this:
user:        christos <christos@NetBSD.org>
date:        Fri Jun 24 01:10:31 2011 +0000
summary:     Always use our own align macro and explain a bit more why this is bogus.



>Unformatted:

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.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.