mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 22:10:10 +01:00
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 <currojerez@riseup.net>
This commit is contained in:
parent
6f1538f8b4
commit
aa1c734b3c
2 changed files with 40 additions and 9 deletions
|
|
@ -28,10 +28,17 @@
|
||||||
#include <clang/CodeGen/CodeGenAction.h>
|
#include <clang/CodeGen/CodeGenAction.h>
|
||||||
#include <llvm/Bitcode/BitstreamWriter.h>
|
#include <llvm/Bitcode/BitstreamWriter.h>
|
||||||
#include <llvm/Bitcode/ReaderWriter.h>
|
#include <llvm/Bitcode/ReaderWriter.h>
|
||||||
#include <llvm/DerivedTypes.h>
|
|
||||||
#include <llvm/Linker.h>
|
#include <llvm/Linker.h>
|
||||||
|
#if HAVE_LLVM < 0x0303
|
||||||
|
#include <llvm/DerivedTypes.h>
|
||||||
#include <llvm/LLVMContext.h>
|
#include <llvm/LLVMContext.h>
|
||||||
#include <llvm/Module.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/PassManager.h>
|
||||||
#include <llvm/Support/TargetSelect.h>
|
#include <llvm/Support/TargetSelect.h>
|
||||||
#include <llvm/Support/MemoryBuffer.h>
|
#include <llvm/Support/MemoryBuffer.h>
|
||||||
|
|
@ -41,8 +48,10 @@
|
||||||
|
|
||||||
#if HAVE_LLVM < 0x0302
|
#if HAVE_LLVM < 0x0302
|
||||||
#include <llvm/Target/TargetData.h>
|
#include <llvm/Target/TargetData.h>
|
||||||
#else
|
#elif HAVE_LLVM < 0x0303
|
||||||
#include <llvm/DataLayout.h>
|
#include <llvm/DataLayout.h>
|
||||||
|
#else
|
||||||
|
#include <llvm/IR/DataLayout.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "pipe/p_state.h"
|
#include "pipe/p_state.h"
|
||||||
|
|
@ -151,7 +160,11 @@ namespace {
|
||||||
// Add libclc generic search path
|
// Add libclc generic search path
|
||||||
c.getHeaderSearchOpts().AddPath(LIBCLC_INCLUDEDIR,
|
c.getHeaderSearchOpts().AddPath(LIBCLC_INCLUDEDIR,
|
||||||
clang::frontend::Angled,
|
clang::frontend::Angled,
|
||||||
false, false, false);
|
false, false
|
||||||
|
#if HAVE_LLVM < 0x0303
|
||||||
|
, false
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
|
||||||
// Add libclc include
|
// Add libclc include
|
||||||
c.getPreprocessorOpts().Includes.push_back("clc/clc.h");
|
c.getPreprocessorOpts().Includes.push_back("clc/clc.h");
|
||||||
|
|
@ -167,8 +180,12 @@ namespace {
|
||||||
c.getInvocation().setLangDefaults(c.getLangOpts(), clang::IK_OpenCL,
|
c.getInvocation().setLangDefaults(c.getLangOpts(), clang::IK_OpenCL,
|
||||||
clang::LangStandard::lang_opencl11);
|
clang::LangStandard::lang_opencl11);
|
||||||
#endif
|
#endif
|
||||||
c.createDiagnostics(0, NULL, new clang::TextDiagnosticPrinter(
|
c.createDiagnostics(
|
||||||
s_log,
|
#if HAVE_LLVM < 0x0303
|
||||||
|
0, NULL,
|
||||||
|
#endif
|
||||||
|
new clang::TextDiagnosticPrinter(
|
||||||
|
s_log,
|
||||||
#if HAVE_LLVM <= 0x0301
|
#if HAVE_LLVM <= 0x0301
|
||||||
c.getDiagnosticOpts()));
|
c.getDiagnosticOpts()));
|
||||||
#else
|
#else
|
||||||
|
|
@ -201,12 +218,26 @@ namespace {
|
||||||
|
|
||||||
llvm::PassManager PM;
|
llvm::PassManager PM;
|
||||||
llvm::PassManagerBuilder Builder;
|
llvm::PassManagerBuilder Builder;
|
||||||
bool isNative;
|
llvm::sys::Path libclc_path =
|
||||||
llvm::Linker linker("clover", mod);
|
llvm::sys::Path(LIBCLC_LIBEXECDIR + triple + ".bc");
|
||||||
|
|
||||||
// Link the kernel with libclc
|
// 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();
|
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.
|
// Add a function internalizer pass.
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@ libOpenCL_la_LIBADD = \
|
||||||
-lclangSema \
|
-lclangSema \
|
||||||
-lclangAnalysis \
|
-lclangAnalysis \
|
||||||
-lclangAST \
|
-lclangAST \
|
||||||
|
-lclangEdit \
|
||||||
-lclangLex \
|
-lclangLex \
|
||||||
-lclangBasic \
|
-lclangBasic \
|
||||||
-lclangEdit \
|
|
||||||
$(LLVM_LIBS)
|
$(LLVM_LIBS)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue