From owner-svn-src-all@FreeBSD.ORG  Sun May 22 20:22:58 2011
Return-Path: <owner-svn-src-all@FreeBSD.ORG>
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 404CA106566B;
	Sun, 22 May 2011 20:22:58 +0000 (UTC)
	(envelope-from rdivacky@vlakno.cz)
Received: from vlakno.cz (lev.vlakno.cz [46.28.110.116])
	by mx1.freebsd.org (Postfix) with ESMTP id 03E508FC13;
	Sun, 22 May 2011 20:22:57 +0000 (UTC)
Received: by vlakno.cz (Postfix, from userid 1002)
	id 67D737F382E; Sun, 22 May 2011 22:22:56 +0200 (CEST)
Date: Sun, 22 May 2011 22:22:56 +0200
From: Roman Divacky <rdivacky@freebsd.org>
To: Dimitry Andric <dim@FreeBSD.org>
Message-ID: <20110522202256.GA43412@freebsd.org>
References: <201105221632.p4MGWjUb081825@svn.freebsd.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <201105221632.p4MGWjUb081825@svn.freebsd.org>
User-Agent: Mutt/1.4.2.3i
Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org,
	src-committers@freebsd.org
Subject: Re: svn commit: r222183 - head/lib/clang
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 &quot;
	user&quot; and &quot; projects&quot; \)" <svn-src-all.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-all>,
	<mailto:svn-src-all-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-all>
List-Post: <mailto:svn-src-all@freebsd.org>
List-Help: <mailto:svn-src-all-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-all>,
	<mailto:svn-src-all-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Sun, 22 May 2011 20:22:58 -0000

The problem here is deeper in my opinion. What FreeBSD calls
amd64 the rest of the world (ie. linux) calls x86_64, I think
that instead of this we should teach llvm/clang about "amd64".
Maybe as a FreeBSD-only diff.

The machine part of the triple is used in more places and this
hack only is not the complete solution imho.

On Sun, May 22, 2011 at 04:32:45PM +0000, Dimitry Andric wrote:
> Author: dim
> Date: Sun May 22 16:32:44 2011
> New Revision: 222183
> URL: http://svn.freebsd.org/changeset/base/222183
> 
> Log:
>   On amd64, change clang's default triple to 'x86_64-unknown-freebsd9.0',
>   similar to what we do for binutils.  When clang's default triple starts
>   with 'amd64-', it does not pass a proper -target-cpu option to its
>   first stage.
>   
>   This can lead to problems, for example when structs are memcpy'd, and
>   clang erroneously assumes they are 16-byte aligned.  It will then use
>   the 'movaps' SSE instruction to implement the copy, which results in a
>   bus error if the struct is really 8-byte aligned.
>   
>   I encountered this issue when gcc's /usr/libexec/cc1 started crashing
>   with SIGBUS, after rebuilding world with clang ToT, but it also affects
>   the version of clang that we have in the tree.  We were just lucky until
>   now, apparently. :)
> 
> Modified:
>   head/lib/clang/clang.build.mk
> 
> Modified: head/lib/clang/clang.build.mk
> ==============================================================================
> --- head/lib/clang/clang.build.mk	Sun May 22 15:24:56 2011	(r222182)
> +++ head/lib/clang/clang.build.mk	Sun May 22 16:32:44 2011	(r222183)
> @@ -15,7 +15,7 @@ CFLAGS+= -O1
>  
>  TARGET_ARCH?=	${MACHINE_ARCH}
>  # XXX: 8.0, to keep __FreeBSD_cc_version happy
> -CFLAGS+=-DLLVM_HOSTTRIPLE=\"${TARGET_ARCH}-undermydesk-freebsd9.0\"
> +CFLAGS+=-DLLVM_HOSTTRIPLE=\"${TARGET_ARCH:C/amd64/x86_64/}-unknown-freebsd9.0\"
>  
>  .ifndef LLVM_REQUIRES_EH
>  CXXFLAGS+=-fno-exceptions