On Sat, May 16, 2015 at 10:24:46PM +0000, Brandon Mercer wrote:
> [...]
> What is the plan for llvm? We should be able to use the llvm in
> ports in the long term,

I will try to explain the current status of rust with LLVM.

I am agreed that I would be very good thing that rust could be able to
using llvm in ports, and not rebuild an embedded llvm version.

> but it's my understanding that they have some patches applied to llvm
> to satisfy their needs?

I don't have followed exactly what is the *current* status of LLVM
version embedded with rust. So I have asked on #rust-internals channel (on
irc.mozilla.org).

>> semarie: where can I found information about minimal LLVM version for
>>      building rust ?
>> cmr: I think 3.5 right now
>> doener: 3.5 in theory, in practice we lack some version check to actually 
>> make
>>      it work I think (e.g. the assume intrinsic is used unconditionally)

So a LLVM 3.5 should be suffisent to build rust (but dev aren't sure).

So I have redo some tests to build with devel/llvm.


I have first tried to build it with clang (from devel/llvm), by adding
--llvm-root="/usr/local" --enable-clang to configure stage.

After that, testing just the compilation of rustllvm part is:
$ env VERBOSE=1 gmake x86_64-unknown-openbsd/rt/librustllvm.a


First, some paths for includes are wrong. But it could be just be done
by patching. devel/llvm announce it self as 3.5, but the version is
something between 3.4 and 3.5.

After that, I have several errors that seems due to c++11.
I am not sure to understand exactly the errors, but:

- building without specific options: error because use of specific c++11
  extensions in rust (src/rustllvm/).

- building with CFLAGS="-std=c++11": errors in llvm includes, because
  use of c++11 without c++11 std library (from my interpretation).

- building with CFLAGS="-std=c++11 -stdlib=libc++": error in llvm
  includes, because lake of headers.

It seems building with clang would need libc++.




Second try, by building with gcc 4.8. The problems seems to be
differences between what rust expects to find in llvm headers, and what
gcc found in it:

- error: no matching function for call to 'llvm::MemoryBuffer::getFile(cons t 
char*&, int, bool)'
- error: 'class llvm::AttrBuilder' has no member named 'addDereferenceableAttr'
- ...

Here the problems seems to be that devel/llvm version isn't a "true" 3.5. 

I have checked the lib/Support/MemoryBuffer.cpp in devel/llvm and
llvm.org (3.5 and 3.6). In devel/llvm the return is error_code, and in
llvm.org, the return is ErrorOr<std::unique_ptr<MemoryBuffer>>.

So I am not sure that using devel/llvm with rust would be possible, without 
rewriting rustllvm part (and it is a moving target), or backport several
others parts of llvm 3.5 in devel/llvm.




Another possibility would be to have another version of llvm in ports,
installed under a subdirectory of ${LOCALBASE} in order to not conflict
with devel/llvm. (/usr/local/llvm3.6, or /usr/local/llvmorg for
examples). The building of this new port would require lang/gcc/4.8 (as
gcc in base lake of c++11 support).

In the rust perspective, it would just permit to not rebuild the llvm
part each time a new version of rust come (every six weeks), and it
wouldn't be more ressource consuming than now (as we build llvm when 
we build rust).


I am not sure which direction should be taken. Please comment. 


Thanks.
-- 
Sébastien Marie

Reply via email to