From aa1c734b3ca445b5af743b9bad6a48ca7ba21f3c Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Fri, 22 Feb 2013 19:19:14 +0100 Subject: [PATCH] clover: Fix build with LLVM 3.3 v2 v2: - Fix order that the clang libraries are passed to the linker to avoid missing symbol errors. Acked-by: Francisco Jerez --- .../state_trackers/clover/llvm/invocation.cpp | 47 +++++++++++++++---- src/gallium/targets/opencl/Makefile.am | 2 +- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/gallium/state_trackers/clover/llvm/invocation.cpp b/src/gallium/state_trackers/clover/llvm/invocation.cpp index 0bd8e22f8eb..2785d10310a 100644 --- a/src/gallium/state_trackers/clover/llvm/invocation.cpp +++ b/src/gallium/state_trackers/clover/llvm/invocation.cpp @@ -28,10 +28,17 @@ #include #include #include -#include #include +#if HAVE_LLVM < 0x0303 +#include #include #include +#else +#include +#include +#include +#include +#endif #include #include #include @@ -41,8 +48,10 @@ #if HAVE_LLVM < 0x0302 #include -#else +#elif HAVE_LLVM < 0x0303 #include +#else +#include #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. // diff --git a/src/gallium/targets/opencl/Makefile.am b/src/gallium/targets/opencl/Makefile.am index c5c30030cad..389eecc9d93 100644 --- a/src/gallium/targets/opencl/Makefile.am +++ b/src/gallium/targets/opencl/Makefile.am @@ -21,9 +21,9 @@ libOpenCL_la_LIBADD = \ -lclangSema \ -lclangAnalysis \ -lclangAST \ + -lclangEdit \ -lclangLex \ -lclangBasic \ - -lclangEdit \ $(LLVM_LIBS) -- 2.30.2