Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 07 Mar 2014 17:12:53 +0100
From:      =?ISO-8859-1?Q?Jean-S=E9bastien_P=E9dron?= <dumbbell@FreeBSD.org>
To:        Dimitry Andric <dim@FreeBSD.org>
Cc:        freebsd-toolchain@freebsd.org
Subject:   Re: Various issues with Clang and libc++ while playing with OpenCL (FYI)
Message-ID:  <5319F005.50300@FreeBSD.org>
In-Reply-To: <08932FE2-8FB5-4EAA-A673-07A3A54721C0@FreeBSD.org>
References:  <53170AD1.4090506@FreeBSD.org> <08932FE2-8FB5-4EAA-A673-07A3A54721C0@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
On 05.03.2014 21:28, Dimitry Andric wrote:
>> 2. Mesa's configure script is looking for stddef.h here:
>>   /usr/local/llvm34/lib/clang/3.4/include
>>
>>   LLVM/Clang ports don't install this file. I just added a symlink to
>>   /usr/include/stddef.h and Mesa was happy. I still need to check how
>>   it goes if I remove the check and the symlink. But perhaps Mesa is
>>   right to expect this header (and maybe other) in this directory, I
>>   don't know.
> 
> (...)
> 
> On the other hand, I don't really understand why Mesa wants to know
> *where* a header is exactly located.  Normally, in configure scripts or
> similar, you are only interested in whether the compiler can find it or
> not.

I removed the check for stddef.h and everything build fine. It could be
a test tailored for some Linux distributions.

>> 3. Our base libc++ has a bug in the <functional> header. I posted a PR
>>   on Mesa bug tracker here, before I found out it was a problem with
>>   libc++:
>>   https://bugs.freedesktop.org/show_bug.cgi?id=75505
> 
> I applied that fix to head in r262805, and I will MFC it after 3 days.

I rebuild world and confirm that I don't need to modify <functional>
anymore.

>> 4. At runtime, any OpenCL program segfaults in libc++ (I don't have the
>>   stack trace at hand and can't remember what it was... Something with
>>   basic_string).
>>
>> When using libc++ from ports (devel/libc++, r200683) and the work around
>> for problem #1, Clover builds and OpenCL programs run fine.
> 
> Hm, this is unfortunate.  I'm interested in where the difference comes
> from, and I would ideally like to fix any problem with libc++ in base.

I reproduced the crash but can't restore a working state now. It's on a
different computer (newer 11-CURRENT, same libclc/Mesa/OpenCL program)
and the crash is a bus error, not a segfault.

Here's the backtrace:
http://people.freebsd.org/~dumbbell/radeonkms/opencl-crash-1.txt

> Can you point me (privately if you like) to some info on how to build
> and reproduce?

On a computer with WITH_NEW_XORG enabled and a Intel or Radeon GPU (HD
5000+), driven by i915kms/radeonkms (though I didn't try on Intel hardware):

1. You need libdevq:
     git clone https://github.com/freebsd/libdevq.git

   It uses autotools:
     autoreconf -vif
     ./configure --prefix=$PREFIX
     make
     make install

   (I use the same $PREFIX in the following commands)

2. You need libclc:
     git clone http://llvm.org/git/libclc.git

   You can configure it like this:
     python ./configure.py \
      --with-llvm-config=/usr/local/bin/llvm-config34 \
      --prefix=$PREFIX
     gmake
     gmake install

   Now is a good time to present you another problem I have with clang
   3.4: it eats 100% CPU when building utils/prepare-builtins.cpp and
   never return. I couldn't reproduce the problem when I wrote my
   original mail (the only time it worked), that's why I didn't mention
   it. But now, it's back.

   Here, I use an older commit and clang 3.3:
     git checkout c002f62bf03f093521c52e2816e4881afc49ef40
     python ./configure.py \
      --with-llvm-config=/usr/local/bin/llvm-config33 \
      --prefix=$PREFIX

3. You need Mesa:
     git clone -b mesa-10.1-rc2-freebsd \
      https://github.com/dumbbell/mesa.git

   To build Mesa, you'll need several ports, some of them comes from
   the xorg-dev ports tree:
     svn co https://trillian.chruetertee.ch/svn/ports/trunk

   Unfortunately, I don't have a ports list at hand... Try to run
   Mesa's configure script and install ports as required. And install
   them from xorg-dev first; if the port isn't in xorg-dev, take the
   one from /usr/ports.

   Here the configure line I use:
     (in checkout dir)
     autoreconf -vif

     (in checkout dir or separate build dir)
     /path/to/configure LLVM_CONFIG=/usr/local/bin/llvm-config34 \
      PKG_CONFIG_PATH=$PREFIX/share/pkgconfig:$PREFIX/lib/pkgconfig \
      --enable-texture-float --enable-gles2 --enable-osmesa \
      --enable-egl --enable-vdpau --enable-shared-glapi \
      --enable-glx-tls --enable-gallium-llvm --with-llvm-shared-libs \
      --enable-dri --enable-gbm --enable-r600-llvm-compiler \
      --with-egl-platforms=x11,drm \
      --with-gallium-drivers=radeonsi,swrast,r600,r300,nouveau \
      --enable-opencl --prefix=$PREFIX CFLAGS="-g -O0" CXXFLAGS="-g -O0"

     gmake
     gmake install

4. And some OpenCL programs:
     svn co http://opencl-book-samples.googlecode.com/svn/trunk

     (in a separate build dir)
     cmake -DOPENCL_LIBRARIES=$PREFIX/lib/libOpenCL.so.1 \
      -DOPENCL_INCLUDE_DIRS=$PREFIX/include -DCMAKE_BUILD_TYPE=Debug \
      /path/to/svn-checkout
     gmake

5. Run an OpenCL program:
     cd src/Chapter_2/HelloWorld
     DISPLAY=:0 ./HelloWorld

   An OpenCL requires a running X server, because only the server is
   allowed to access the CPU (without an X server, the program will
   fail with Permission denied).

I hope I didn't forgot something. I'm available on IRC (as dumbbell or
dumbbell-) in any case. My laptop is currently on stable/9; I could
setup an account for you once rebooted on -CURRENT, if you don't want to
bother with this awful procedure.

-- 
Jean-Sébastien Pédron


[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (FreeBSD)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJTGfAMAAoJEDnpl2Gl/ZTMj60QAOWH/xukDMpPgBQirLgoqro+
UvUhfR4NtqRU4Q6JV3EZcThXe1pQL0CJ2VuTLwqB9EzAo0vJF4DeLMQ726tJytJ6
3l4AhS9RDEhKskbDG9FRmifD9S+jCY5BuMCM2TAfGSsWhbldPETm2/NXcspPjPZu
WHlUL92y5+Rk/h6MBQ3L7HYAgnWtZFg10Vof2QYMaeRakU5diVL4s7bt9bd5fgSX
LlAODIyPI7zF9DZzrCcLRaAEl68D0CQe8mQLsCemiADoP2N6ryKS5eTLd7RTiQ4W
pdTjL7HiVVekR1xXzJeEJ0WJWqnY/6VYwUYc6z8k8Lm/SytYe/cU/BLn3NsrT91G
jVHJiop3lIOZLj5B2cwJBq3qvFwgNB8XOTwt6BP1C8Snd21ORgeRNzTGQzd6uc9e
inyQlu6DHNAVhg7cDEg+xFP1rsnT+ESdVfnGc7wnHKjnjxzfDdJ210kj/uMax+Ml
/9HYfPSkHMHlXbWE+H1wewIPyseINLLo+86gSHX1TJWsSUtZ8Aab6iiqsm1Q0ptv
NcmwVBf5qvnN+XWVH03530m2xrrIrNq/5jMHRq9JFFZOEJoFKb0bQcpPDiftShm6
nilJcpPlUftyLQh3gK1pjEnLiqoAZXrs3id7WVXuMvfn4FucD4GRiOmKQh/kTQ37
6/prrzuB+/T4ghAJYBez
=FPGj
-----END PGP SIGNATURE-----

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5319F005.50300>