[Mesa-dev] [PATCH] clover: Fix build with LLVM 3.3

Aaron Watry awatry at gmail.com
Thu Feb 21 09:46:02 PST 2013


On Thu, Feb 21, 2013 at 10:06 AM, Tom Stellard <tom at stellard.net> wrote:

> On Thu, Feb 21, 2013 at 10:02:34AM -0600, Aaron Watry wrote:
> > On Thu, Feb 21, 2013 at 8:33 AM, Tom Stellard <tom at stellard.net> wrote:
> >
> > > On Thu, Feb 21, 2013 at 08:25:20AM -0600, Aaron Watry wrote:
> > > > Hi Tom,
> > > >
> > > > Mesa+Clover does indeed build against master llvm/clang, but I'm
> having
> > > > trouble building against it when I try to do a clean build of Piglit.
> > > >
> > > > Error received:
> > > >
> > > > [ 18%] Built target piglitutil_cl
> > > > Linking C executable ../../../../../bin/cl-custom-run-simple-kernel
> > > > /usr/local/lib/libOpenCL.so: undefined reference to
> > > >
> > >
> `clang::PPConditionalDirectiveRecord::rangeIntersectsConditionalDirective(clang::SourceRange)
> > > > const'
> > > > /usr/local/lib/libOpenCL.so: undefined reference to
> > > >
> > >
> `clang::PPConditionalDirectiveRecord::findConditionalDirectiveRegionLoc(clang::SourceLocation)
> > > > const'
> > > > collect2: error: ld returned 1 exit status
> > > > make[2]: *** [bin/cl-custom-run-simple-kernel] Error 1
> > > > make[1]: ***
> > > >
> > >
> [target_api/cl/tests/cl/custom/CMakeFiles/cl-custom-run-simple-kernel.dir/all]
> > > > Error 2
> > > > make: *** [all] Error 2
> > > >
> > > > Maybe I've done something wrong, but I've tested this on two
> machines now
> > > > and both times I've wiped my llvm/clang/mesa/clover installs in
> > > /usr/local
> > > > and rebuilt from scratch.
> > > >
> > >
> > > Which revisions of Clang and LLVM are you using?
> > >
> > >
> > I'm not at home at the moment, so I don't have access to those machines,
> > but from memory:
> >
> > LLVM was git master as of sometime around 6-8pm CST last night.  One such
> > revision would be
> > commit ffbe432595c78ba28c8a9d200bf92996eed5e5d9
> > git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17571891177308-0d3
> >
> >
> > Clang was somewhere between 3bc7b6bef96 and dc84cd5efdd3430efb.
> >
> > I just retested on another machine with the following versions:
> > LLVM: git: 0514595b9b20c9d80, svn: 175739
> > Clang: 7d81281fc39f6d, svn: 175741
> > Mesa: b63b3012c91 with your clover patch
> >
> > Result:
> > Linking C executable ../../../../../bin/cl-custom-run-simple-kernel
> > /usr/local/lib/libOpenCL.so: undefined reference to
> >
> `clang::PPConditionalDirectiveRecord::rangeIntersectsConditionalDirective(clang::SourceRange)
> > const'
> > /usr/local/lib/libOpenCL.so: undefined reference to
> >
> `clang::PPConditionalDirectiveRecord::findConditionalDirectiveRegionLoc(clang::SourceLocation)
> > const'
> > collect2: error: ld returned 1 exit status
> > make[2]: *** [bin/cl-custom-run-simple-kernel] Error 1
> > make[1]: ***
> >
> [target_api/cl/tests/cl/custom/CMakeFiles/cl-custom-run-simple-kernel.dir/all]
> > Error 2
> > make: *** [all] Error 2
> >
>
> Did you re-configure and run make clean for piglit?
>
>
I did a full git clean -fdx on LLVM, Clang, libclc, Mesa, and Piglit after
removing all existing LLVM/Clang/Mesa includes/libraries from /usr/local.
I also did a full search for other copies of libclang on my system and the
only copies were in /usr/local/lib.

Note: libclc's prepare-builtins.cpp needed to be updated for LLVM 3.3 as
well (moving 4 headers into <llvm/IR/*.h>.

I then did a clean configure/make/make install on LLVM/libclc/Mesa, and
then a clean rebuild of piglit.

LLVM Configure: CC=gcc CXX=g++ ./configure --enable-optimized
--enable-assertions=no --enable-experimental-
targets=R600 --enable-targets=x86 --enable-shared --prefix=/usr/local

Mesa Configure: ./configure --with-dri-drivers=radeon
--with-gallium-drivers=r600 --enable-texture-float --enable-opencl

Piglit was rebuilt clean with only the CL tests enabled. No GL, GLX ,
Waffle, etc.

libOpenCL is linked against the 3.3 build of LLVM, but I did notice that
there's no linking to clang.. I did notice that while LLVM builds a shared
library, clang only installs a static archive. Are we statically linking
Clang into Mesa while using the shared libLLVM?

ldd /usr/local/lib/libOpenCL.so:
    linux-vdso.so.1 =>  (0x00007ffffdce1000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0
(0x00007effa3e21000)
    libxcb-dri2.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-dri2.so.0
(0x00007effa3c1c000)
    libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1
(0x00007effa39fd000)
    libdrm.so.2 => /usr/local/lib/libdrm.so.2 (0x00007effa37f1000)
    libudev.so.0 => /lib/x86_64-linux-gnu/libudev.so.0 (0x00007effa35e4000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007effa33db000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007effa31d7000)
    libLLVM-3.3svn.so => /usr/local/lib/libLLVM-3.3svn.so(0x00007effa22d8000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(0x00007effa1fd4000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007effa1cd8000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007effa1919000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1
(0x00007effa1702000)
    /lib64/ld-linux-x86-64.so.2 (0x00007effa511b000)
    libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6
(0x00007effa14fe000)
    libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6
(0x00007effa12f8000)


--Aaron



>  -Tom
> >
> >
> > > -Tom
> > >
> > > > --Aaron
> > > >
> > > > On Wed, Feb 20, 2013 at 4:27 PM, Tom Stellard <tom at stellard.net>
> wrote:
> > > >
> > > > > From: Tom Stellard <thomas.stellard at amd.com>
> > > > >
> > > > > ---
> > > > >  .../state_trackers/clover/llvm/invocation.cpp      |   47
> > > > > ++++++++++++++++---
> > > > >  1 files changed, 39 insertions(+), 8 deletions(-)
> > > > >
> > > > > diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp
> > > > > b/src/gallium/state_trackers/clover/llvm/invocation.cpp
> > > > > index 0bd8e22..2785d10 100644
> > > > > --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp
> > > > > +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp
> > > > > @@ -28,10 +28,17 @@
> > > > >  #include <clang/CodeGen/CodeGenAction.h>
> > > > >  #include <llvm/Bitcode/BitstreamWriter.h>
> > > > >  #include <llvm/Bitcode/ReaderWriter.h>
> > > > > -#include <llvm/DerivedTypes.h>
> > > > >  #include <llvm/Linker.h>
> > > > > +#if HAVE_LLVM < 0x0303
> > > > > +#include <llvm/DerivedTypes.h>
> > > > >  #include <llvm/LLVMContext.h>
> > > > >  #include <llvm/Module.h>
> > > > > +#else
> > > > > +#include <llvm/IR/DerivedTypes.h>
> > > > > +#include <llvm/IR/LLVMContext.h>
> > > > > +#include <llvm/IR/Module.h>
> > > > > +#include <llvm/Support/IRReader.h>
> > > > > +#endif
> > > > >  #include <llvm/PassManager.h>
> > > > >  #include <llvm/Support/TargetSelect.h>
> > > > >  #include <llvm/Support/MemoryBuffer.h>
> > > > > @@ -41,8 +48,10 @@
> > > > >
> > > > >  #if HAVE_LLVM < 0x0302
> > > > >  #include <llvm/Target/TargetData.h>
> > > > > -#else
> > > > > +#elif HAVE_LLVM < 0x0303
> > > > >  #include <llvm/DataLayout.h>
> > > > > +#else
> > > > > +#include <llvm/IR/DataLayout.h>
> > > > >  #endif
> > > > >
> > > > >  #include "pipe/p_state.h"
> > > > > @@ -151,7 +160,11 @@ namespace {
> > > > >        // Add libclc generic search path
> > > > >        c.getHeaderSearchOpts().AddPath(LIBCLC_INCLUDEDIR,
> > > > >                                        clang::frontend::Angled,
> > > > > -                                      false, false, false);
> > > > > +                                      false, false
> > > > > +#if HAVE_LLVM < 0x0303
> > > > > +                                      , false
> > > > > +#endif
> > > > > +                                      );
> > > > >
> > > > >        // Add libclc include
> > > > >        c.getPreprocessorOpts().Includes.push_back("clc/clc.h");
> > > > > @@ -167,8 +180,12 @@ namespace {
> > > > >        c.getInvocation().setLangDefaults(c.getLangOpts(),
> > > clang::IK_OpenCL,
> > > > >
> > > > >  clang::LangStandard::lang_opencl11);
> > > > >  #endif
> > > > > -      c.createDiagnostics(0, NULL, new
> clang::TextDiagnosticPrinter(
> > > > > -                          s_log,
> > > > > +      c.createDiagnostics(
> > > > > +#if HAVE_LLVM < 0x0303
> > > > > +                          0, NULL,
> > > > > +#endif
> > > > > +                          new clang::TextDiagnosticPrinter(
> > > > > +                                 s_log,
> > > > >  #if HAVE_LLVM <= 0x0301
> > > > >                                   c.getDiagnosticOpts()));
> > > > >  #else
> > > > > @@ -201,12 +218,26 @@ namespace {
> > > > >
> > > > >        llvm::PassManager PM;
> > > > >        llvm::PassManagerBuilder Builder;
> > > > > -      bool isNative;
> > > > > -      llvm::Linker linker("clover", mod);
> > > > > +      llvm::sys::Path libclc_path =
> > > > > +                            llvm::sys::Path(LIBCLC_LIBEXECDIR +
> > > triple +
> > > > > ".bc");
> > > > >
> > > > >        // Link the kernel with libclc
> > > > > -      linker.LinkInFile(llvm::sys::Path(LIBCLC_LIBEXECDIR +
> triple +
> > > > > ".bc"), isNative);
> > > > > +#if HAVE_LLVM < 0x0303
> > > > > +      bool isNative;
> > > > > +      llvm::Linker linker("clover", mod);
> > > > > +      linker.LinkInFile(libclc_path, isNative);
> > > > >        mod = linker.releaseModule();
> > > > > +#else
> > > > > +      std::string err_str;
> > > > > +      llvm::SMDiagnostic err;
> > > > > +      llvm::Module *libclc_mod =
> llvm::ParseIRFile(libclc_path.str(),
> > > err,
> > > > > +
> mod->getContext());
> > > > > +      if (llvm::Linker::LinkModules(mod, libclc_mod,
> > > > > +                                    llvm::Linker::DestroySource,
> > > > > +                                    &err_str)) {
> > > > > +         throw build_error(err_str);
> > > > > +      }
> > > > > +#endif
> > > > >
> > > > >        // Add a function internalizer pass.
> > > > >        //
> > > > > --
> > > > > 1.7.8.6
> > > > >
> > > > > _______________________________________________
> > > > > mesa-dev mailing list
> > > > > mesa-dev at lists.freedesktop.org
> > > > > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> > > > >
> > >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20130221/408baa17/attachment-0001.html>


More information about the mesa-dev mailing list