From owner-freebsd-stable@FreeBSD.ORG  Wed Dec 28 00:03:47 2011
Return-Path: <owner-freebsd-stable@FreeBSD.ORG>
Delivered-To: freebsd-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5CACC1065676
	for <freebsd-stable@freebsd.org>; Wed, 28 Dec 2011 00:03:47 +0000 (UTC)
	(envelope-from dim@FreeBSD.org)
Received: from tensor.andric.com (cl-327.ede-01.nl.sixxs.net
	[IPv6:2001:7b8:2ff:146::2])
	by mx1.freebsd.org (Postfix) with ESMTP id 19A468FC14
	for <freebsd-stable@freebsd.org>; Wed, 28 Dec 2011 00:03:47 +0000 (UTC)
Received: from [IPv6:2001:7b8:3a7:0:2838:1eb:929f:da87] (unknown
	[IPv6:2001:7b8:3a7:0:2838:1eb:929f:da87])
	(using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits))
	(No client certificate requested)
	by tensor.andric.com (Postfix) with ESMTPSA id 6B3F65C37;
	Wed, 28 Dec 2011 01:03:46 +0100 (CET)
Message-ID: <4EFA5CE0.6040203@FreeBSD.org>
Date: Wed, 28 Dec 2011 01:03:44 +0100
From: Dimitry Andric <dim@FreeBSD.org>
Organization: The FreeBSD Project
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64;
	rv:9.0) Gecko/20111222 Thunderbird/9.0.1
MIME-Version: 1.0
To: Volodymyr Kostyrko <c.kworr@gmail.com>
References: <4EF88D7B.4040600@gmail.com>
	<CAE-mSOJx51E+cMGy_UytDtDBdujnzM2ZEXBBqFRTgC2VCaucng@mail.gmail.com>
	<4EF8E21E.10401@gmail.com> <4EF92639.8070903@FreeBSD.org>
	<4EF99F93.9000405@gmail.com>
In-Reply-To: <4EF99F93.9000405@gmail.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Cc: freebsd-stable@freebsd.org
Subject: Re: minor regression after patching
X-BeenThere: freebsd-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: Production branch of FreeBSD source code <freebsd-stable.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-stable>, 
	<mailto:freebsd-stable-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-stable>
List-Post: <mailto:freebsd-stable@freebsd.org>
List-Help: <mailto:freebsd-stable-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/freebsd-stable>,
	<mailto:freebsd-stable-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Wed, 28 Dec 2011 00:03:47 -0000

On 2011-12-27 11:36, Volodymyr Kostyrko wrote:
...
> Yes. I have set up a chrooted environment to retest. Config files are:
>
> === /etc/make.conf
> # vim:set ft=make:
>
> #CPUTYPE?=native
> INSTALL:=install -C
> KERNCONF?=MINIMAL
> NO_CLEAN:=yes
> WITHOUT_NOUVEAU:=yes
> WRKDIRPREFIX=/tmp/ports
>
> .if (empty(.CURDIR:N*/usr/src/*) || empty(.CURDIR:N*/usr/obj/*))&&
> !defined(NOCCACHE)

The problem is this test, it doesn't return true when you are exactly in
/usr/src.  The result is that clang doesn't get built in the cross-tools
stage, and /usr/bin/clang is used instead for the rest of the world.

This clang will include files from /usr/include, and link with libs from
/usr/lib, causing the problem you are seeing.

You could write the test as follows instead:

   .if ${.CURDIR:M/usr/src} || ${.CURDIR:M/usr/src/*} || ${.CURDIR:M/usr/obj} || ${.CURDIR:M/usr/obj/*}

or if you insist on using empty():

   .if !empty(.CURDIR:M/usr/src) || !empty(.CURDIR:M/usr/src/*) || !empty(.CURDIR:M/usr/obj) || !empty(.CURDIR:M/usr/obj/*)

or any other form which includes /usr/src and /usr/obj 'top level' in
addition to /usr/src/* and /usr/obj/*.  If you don't care about
strictness, you could just use:

   .if ${.CURDIR:M/usr/src*} || ${.CURDIR:M/usr/obj*}


...
>     CC:=${CC:C,^cc$,clang,1}
>     CXX:=${CXX:C,^c\+\+$,clang++,1}
>     CPP:=${CPP:C,^cpp$,clang -E,}
>     NO_WERROR:=
>     WERROR:=

Here, it is better to use the idiom mentioned on:

   http://wiki.freebsd.org/BuildingFreeBSDWithClang

e.g.:

   .if !defined(CC) || ${CC} == "cc"
   CC=clang
   .endif
   .if !defined(CXX) || ${CXX} == "c++"
   CXX=clang++
   .endif
   .if !defined(CPP) || ${CPP} == "cpp"
   CPP=clang-cpp
   .endif

I know it looks ugly, but it is required for stable/9, because I was not
given permission to MFC r227120 yet, which fixes this, so you can just
use:

   CC=clang
   CXX=clang++
   CPP=clang-cpp

instead.