Re: FreeBSD 10.0-CURRENT: CLANG and port/clang weirdness!

From: Stefan Esser <se_at_freebsd.org>
Date: Sat, 08 Sep 2012 14:15:09 +0200
Am 08.09.2012 10:35, schrieb O. Hartmann:
> On 09/07/12 19:07, Brooks Davis wrote:
>> On Fri, Sep 07, 2012 at 05:46:02PM +0200, O. Hartmann wrote:
>>> On 09/07/12 17:09, Dimitry Andric wrote:
>>>> On 2012-09-07 11:41, O. Hartmann wrote:
>>>>> Building ports not explicitely enabling USE_GCC=4.6+ are
>>>>> considered using the system's LLVM/CLANG, which is clang
>>>>> 3.2 in our installation (FreeBSD 10.0-CURRENT #0 r240164),
>>>>> but since some ports require the special ports devel/llvm
>>>>> and lang/clang, LLVM 3.1 and clang 3.1 get installed and
>>>>> 3.1 is used instead the system's 3.2 whenever "clang", 
>>>>> "clang++" is invoked.
>>>> 
>>>> Maybe a solution would be to use the same approach as with
>>>> the gcc ports, namely installing the clang 3.1 executables
>>>> into /usr/local/bin as clang-3.1, clang++-3.1 and
>>>> clang-cpp-3.1.  Then you could simply set
>>>> 
>>>> CC=clang-3.1 CXX=clang++-3.1 CPP=clang-cpp-3.1
>>>> 
>>>> for the targets that require it.  Brooks? :)
>>> 
>>> I would appreciate such an approach, since it would be
>>> consistent with with GCC, as you stated.
>> 
>> I'd like to do this, but it doesn't look like it will be easy.
>> There appears to be no support in the llvm build system for it.
>> :(
>> 
>>>>> Following the WIKI at
>>>>> http://wiki.freebsd.org/BuildingFreeBSDWithClang introduces
>>>>> the usage of
>>>>> 
>>>>> CC=clang instead of CC=/usr/bin/clang CXX=clang++ instead
>>>>> of CXX=/usr/bin/clang++ CPP=clang-ccp instead of
>>>>> CPP=/usr/bin/clang-ccp
>>>>> 
>>>>> Is this intended?
>>>> 
>>>> Yes.  During buildworld, in the cross-tools stage, a new
>>>> compiler is built, and it is placed under ${WORLDTMP},
>>>> usually /usr/obj/usr/src/tmp. Afterwards, in the rest of the
>>>> stages, the PATH is changed so executables from ${WORLDTMP}
>>>> are preferred above those in the system directories.
>>>> 
>>>> Therefore, if you set CC/CXX/CPP with an explicit path, this
>>>> logic will not work, and your buildworld may have all kinds
>>>> of trouble.  I think there are several patches floating
>>>> around to fix this, in various different ways.
>>> 
>>> Understood.
>> 
>> FWIW, picking up clang etc from /usr/local should be mostly
>> harmless during the early build stage.  You're actual world will
>> be built with the cross clang.
> 
> 
> ... means, the resulting WORLD and KERNEL is then build by the 
> LLVM/CLANG that is residing in /usr/obj/...?
> 
> But what is with PORTS I build later? They definitely pick up the 
> "wrong" clang/clang++.
> 
> I was suggested to deinstall (or not to install) the port's version
> of LLVM/CLANG, but this happens automatically for some ports -
> like LibreOffice.

Simple solution:

If /usr/local/bin must be in front of /usr/bin and the port version of
CLANG is thus found in preference of the system version, you may still
put another directory with symbolic links to system binaries in front
of /usr/local/bin. E.g.:

PATH=/usr/pref_bin:/usr/local/bin:/usr/bin

Directory /usr/pref_bin contains symbolic links to binaries in /usr/bin,
e.g. /usr/pref_bin/clang -> /usr/bin/clang.

Regards, STefan
Received on Sat Sep 08 2012 - 10:15:20 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:30 UTC