<div dir="ltr"><div><div><div>Hi Tom,<br><br></div>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.<br><br></div>Error received:<br>
<br>[ 18%] Built target piglitutil_cl<br>Linking C executable ../../../../../bin/cl-custom-run-simple-kernel<br>/usr/local/lib/libOpenCL.so: undefined reference to `clang::PPConditionalDirectiveRecord::rangeIntersectsConditionalDirective(clang::SourceRange) const'<br>
/usr/local/lib/libOpenCL.so: undefined reference to `clang::PPConditionalDirectiveRecord::findConditionalDirectiveRegionLoc(clang::SourceLocation) const'<br>collect2: error: ld returned 1 exit status<br>make[2]: *** [bin/cl-custom-run-simple-kernel] Error 1<br>
make[1]: *** [target_api/cl/tests/cl/custom/CMakeFiles/cl-custom-run-simple-kernel.dir/all] Error 2<br>make: *** [all] Error 2<br><br></div>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.<br>
<div><div><br></div><div>--Aaron<br></div><div><br>On Wed, Feb 20, 2013 at 4:27 PM, Tom Stellard <span dir="ltr"><<a href="mailto:tom@stellard.net" target="_blank">tom@stellard.net</a>></span> wrote:<br><div><div><div class="gmail_extra">
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Tom Stellard <<a href="mailto:thomas.stellard@amd.com">thomas.stellard@amd.com</a>><br>
<br>
---<br>
.../state_trackers/clover/llvm/invocation.cpp | 47 ++++++++++++++++---<br>
1 files changed, 39 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp<br>
index 0bd8e22..2785d10 100644<br>
--- a/src/gallium/state_trackers/clover/llvm/invocation.cpp<br>
+++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp<br>
@@ -28,10 +28,17 @@<br>
#include <clang/CodeGen/CodeGenAction.h><br>
#include <llvm/Bitcode/BitstreamWriter.h><br>
#include <llvm/Bitcode/ReaderWriter.h><br>
-#include <llvm/DerivedTypes.h><br>
#include <llvm/Linker.h><br>
+#if HAVE_LLVM < 0x0303<br>
+#include <llvm/DerivedTypes.h><br>
#include <llvm/LLVMContext.h><br>
#include <llvm/Module.h><br>
+#else<br>
+#include <llvm/IR/DerivedTypes.h><br>
+#include <llvm/IR/LLVMContext.h><br>
+#include <llvm/IR/Module.h><br>
+#include <llvm/Support/IRReader.h><br>
+#endif<br>
#include <llvm/PassManager.h><br>
#include <llvm/Support/TargetSelect.h><br>
#include <llvm/Support/MemoryBuffer.h><br>
@@ -41,8 +48,10 @@<br>
<br>
#if HAVE_LLVM < 0x0302<br>
#include <llvm/Target/TargetData.h><br>
-#else<br>
+#elif HAVE_LLVM < 0x0303<br>
#include <llvm/DataLayout.h><br>
+#else<br>
+#include <llvm/IR/DataLayout.h><br>
#endif<br>
<br>
#include "pipe/p_state.h"<br>
@@ -151,7 +160,11 @@ namespace {<br>
// Add libclc generic search path<br>
c.getHeaderSearchOpts().AddPath(LIBCLC_INCLUDEDIR,<br>
clang::frontend::Angled,<br>
- false, false, false);<br>
+ false, false<br>
+#if HAVE_LLVM < 0x0303<br>
+ , false<br>
+#endif<br>
+ );<br>
<br>
// Add libclc include<br>
c.getPreprocessorOpts().Includes.push_back("clc/clc.h");<br>
@@ -167,8 +180,12 @@ namespace {<br>
c.getInvocation().setLangDefaults(c.getLangOpts(), clang::IK_OpenCL,<br>
clang::LangStandard::lang_opencl11);<br>
#endif<br>
- c.createDiagnostics(0, NULL, new clang::TextDiagnosticPrinter(<br>
- s_log,<br>
+ c.createDiagnostics(<br>
+#if HAVE_LLVM < 0x0303<br>
+ 0, NULL,<br>
+#endif<br>
+ new clang::TextDiagnosticPrinter(<br>
+ s_log,<br>
#if HAVE_LLVM <= 0x0301<br>
c.getDiagnosticOpts()));<br>
#else<br>
@@ -201,12 +218,26 @@ namespace {<br>
<br>
llvm::PassManager PM;<br>
llvm::PassManagerBuilder Builder;<br>
- bool isNative;<br>
- llvm::Linker linker("clover", mod);<br>
+ llvm::sys::Path libclc_path =<br>
+ llvm::sys::Path(LIBCLC_LIBEXECDIR + triple + ".bc");<br>
<br>
// Link the kernel with libclc<br>
- linker.LinkInFile(llvm::sys::Path(LIBCLC_LIBEXECDIR + triple + ".bc"), isNative);<br>
+#if HAVE_LLVM < 0x0303<br>
+ bool isNative;<br>
+ llvm::Linker linker("clover", mod);<br>
+ linker.LinkInFile(libclc_path, isNative);<br>
mod = linker.releaseModule();<br>
+#else<br>
+ std::string err_str;<br>
+ llvm::SMDiagnostic err;<br>
+ llvm::Module *libclc_mod = llvm::ParseIRFile(libclc_path.str(), err,<br>
+ mod->getContext());<br>
+ if (llvm::Linker::LinkModules(mod, libclc_mod,<br>
+ llvm::Linker::DestroySource,<br>
+ &err_str)) {<br>
+ throw build_error(err_str);<br>
+ }<br>
+#endif<br>
<br>
// Add a function internalizer pass.<br>
//<br>
<span class=""><font color="#888888">--<br>
1.7.8.6<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div></div></div></div></div>