void-packages/srcpkgs/lightspark/patches/llvm32-targetdata.patch

78 lines
2.6 KiB
Diff

diff --git a/conf/FindLLVM.cmake b/conf/FindLLVM.cmake
index 19a3934..7bd52e2 100644
--- a/conf/FindLLVM.cmake
+++ b/conf/FindLLVM.cmake
@@ -165,6 +165,14 @@ else (LLVM_INCLUDE_DIR)
IF(HAVE_IRBUILDER_H)
ADD_DEFINITIONS(-DHAVE_IRBUILDER_H)
ENDIF(HAVE_IRBUILDER_H)
+
+ set(CMAKE_REQUIRED_INCLUDES ${LLVM_INCLUDE_DIR})
+ check_include_file_cxx("llvm/DataLayout.h" HAVE_DATALAYOUT_H)
+ unset(CMAKE_REQUIRED_INCLUDES)
+ MESSAGE(STATUS "HAVE_DATALAYOUT_H: " ${HAVE_DATALAYOUT_H})
+ IF(HAVE_DATALAYOUT_H)
+ ADD_DEFINITIONS(-DHAVE_DATALAYOUT_H)
+ ENDIF(HAVE_DATALAYOUT_H)
exec_program(${LLVM_CONFIG_EXECUTABLE} ARGS --cxxflags OUTPUT_VARIABLE LLVM_COMPILE_FLAGS )
MESSAGE(STATUS "LLVM CXX flags: " ${LLVM_COMPILE_FLAGS})
diff --git a/src/scripting/abc.cpp b/src/scripting/abc.cpp
index 710eaec..a0546cb 100644
--- a/src/scripting/abc.cpp
+++ b/src/scripting/abc.cpp
@@ -28,7 +28,11 @@
#include <llvm/ExecutionEngine/JIT.h>
#include <llvm/PassManager.h>
#include <llvm/LLVMContext.h>
-#include <llvm/Target/TargetData.h>
+#ifdef HAVE_DATALAYOUT_H
+# include <llvm/DataLayout.h>
+#else
+# include <llvm/Target/TargetData.h>
+#endif
#ifdef HAVE_SUPPORT_TARGETSELECT_H
#include <llvm/Support/TargetSelect.h>
#else
@@ -1456,7 +1460,11 @@ void ABCVm::Run(ABCVm* th)
assert_and_throw(th->ex);
th->FPM=new llvm::FunctionPassManager(th->module);
+#ifdef HAVE_DATALAYOUT_H
+ th->FPM->add(new llvm::DataLayout(*th->ex->getDataLayout()));
+#else
th->FPM->add(new llvm::TargetData(*th->ex->getTargetData()));
+#endif
#ifdef EXPENSIVE_DEBUG
//This is pretty heavy, do not enable in release
th->FPM->add(llvm::createVerifierPass());
diff --git a/src/scripting/abc_codesynt.cpp b/src/scripting/abc_codesynt.cpp
index 2648bbf..83c1d5f 100644
--- a/src/scripting/abc_codesynt.cpp
+++ b/src/scripting/abc_codesynt.cpp
@@ -36,7 +36,11 @@
# include <llvm/Support/IRBuilder.h>
#endif
#include <llvm/LLVMContext.h>
-#include <llvm/Target/TargetData.h>
+#ifdef HAVE_DATALAYOUT_H
+# include <llvm/DataLayout.h>
+#else
+# include <llvm/Target/TargetData.h>
+#endif
#include <sstream>
#include "scripting/abc.h"
#include "swftypes.h"
@@ -275,7 +279,11 @@ void ABCVm::registerFunctions()
llvm::FunctionType* FT=NULL;
//Create types
+#ifdef HAVE_DATALAYOUT_H
+ ptr_type=ex->getDataLayout()->getIntPtrType(llvm_context());
+#else
ptr_type=ex->getTargetData()->getIntPtrType(llvm_context());
+#endif
//Pointer to 8 bit type, needed for pointer arithmetic
voidptr_type=llvm::IntegerType::get(getVm()->llvm_context(),8)->getPointerTo();
number_type=llvm::Type::getDoubleTy(llvm_context());