Browse Source

HPCC-13727 Add support for power8

Signed-off-by: Gavin Halliday <gavin.halliday@lexisnexis.com>
Gavin Halliday 10 years ago
parent
commit
4aab37c91a
4 changed files with 44 additions and 11 deletions
  1. 2 0
      common/dllserver/thorplugin.cpp
  2. 6 0
      ecl/hql/hqlstack.hpp
  3. 29 10
      ecl/hqlcpp/hqlres.cpp
  4. 7 1
      system/include/platform.h

+ 2 - 0
common/dllserver/thorplugin.cpp

@@ -24,6 +24,8 @@
 #include "jlzw.hpp"
 #include "eclrtl.hpp"
 #ifdef _USE_BINUTILS
+#define PACKAGE "hpcc-system"
+#define PACKAGE_VERSION "1.0"
 #include "bfd.h"
 #elif defined(__APPLE__)
 #include <mach-o/getsect.h>

+ 6 - 0
ecl/hql/hqlstack.hpp

@@ -38,6 +38,12 @@
 #elif defined (_ARCH_X86_)
  #define ALIGNMENT 4
  #define REGSIZE 4
+#elif defined (_ARCH_PPC64EL_)
+ #define ALIGNMENT 8
+ #define REGSIZE 8
+ #define MAXFPREGS 8
+ #define REGPARAMS 6
+ #define EVEN_STACK_ALIGNMENT
 #elif defined (_ARCH_ARM64_)
  #define ALIGNMENT 8
  #define ALIGN_USES_ELEMENTSIZE

+ 29 - 10
ecl/hqlcpp/hqlres.cpp

@@ -24,6 +24,8 @@
 #include "hqlcerrors.hpp"
 #include "thorplugin.hpp"
 #ifdef _USE_BINUTILS
+#define PACKAGE "hpcc-system"
+#define PACKAGE_VERSION "1.0"
 #include "bfd.h"
 #endif
 
@@ -469,9 +471,16 @@ bool ResourceManager::flush(StringBuffer &filename, const char *basename, bool f
     {
         bfd_init ();
         bfd_set_default_target(target64bit ? "x86_64-unknown-linux-gnu" : "x86_32-unknown-linux-gnu");
+#ifdef _ARCH_PPC64EL_
+        const bfd_arch_info_type *temp_arch_info = bfd_scan_arch ("powerpc");
+#else
         const bfd_arch_info_type *temp_arch_info = bfd_scan_arch ("i386");
+#endif
+
 #if defined __APPLE__
         file = bfd_openw(filename, NULL);//MORE: Quick fix to get working on OSX
+#elif defined _ARCH_PPC64EL_
+        file = bfd_openw(filename, "elf64-powerpcle");
 #else
         file = bfd_openw(filename, target64bit ? "elf64-x86-64" : NULL);//MORE: Test on 64 bit to see if we can always pass NULL
 #endif
@@ -538,6 +547,13 @@ bool ResourceManager::flush(StringBuffer &filename, const char *basename, bool f
     FILE *f = fopen(filename, "wt");
     if (!f)
         throwError1(HQLERR_ResourceCreateFailed, filename.str());
+
+    //MORE: This should really use targetCompiler instead
+#if defined(__APPLE__)
+    bool generateClang = true;
+#else
+    bool generateClang = false;
+#endif
     ForEachItemIn(idx, resources)
     {
         ResourceItem &s = (ResourceItem &) resources.item(idx);
@@ -545,16 +561,19 @@ bool ResourceManager::flush(StringBuffer &filename, const char *basename, bool f
         unsigned id = s.id;
         VStringBuffer binfile("%s_%s_%u.bin", filename.str(), type, id);
         VStringBuffer label("%s_%u_txt_start", type, id);
-#if defined(__APPLE__)
-        fprintf(f, " .section __TEXT,%s_%u\n", type, id);
-        fprintf(f, " .global _%s\n", label.str());  // For some reason apple needs a leading underbar and linux does not
-        fprintf(f, "_%s:\n", label.str());
-#else
-        fprintf(f, " .section %s_%u,\"a\"\n", type, id);
-        fprintf(f, " .global %s\n", label.str());
-        fprintf(f, " .type %s,STT_OBJECT\n", label.str());
-        fprintf(f, "%s:\n", label.str());
-#endif
+        if (generateClang)
+        {
+            fprintf(f, " .section __TEXT,%s_%u\n", type, id);
+            fprintf(f, " .global _%s\n", label.str());  // For some reason apple needs a leading underbar and linux does not
+            fprintf(f, "_%s:\n", label.str());
+        }
+        else
+        {
+            fprintf(f, " .section %s_%u,\"a\"\n", type, id);
+            fprintf(f, " .global %s\n", label.str());
+            fprintf(f, " .type %s,STT_OBJECT\n", label.str());
+            fprintf(f, "%s:\n", label.str());
+        }
         fprintf(f, " .incbin \"%s\"\n", binfile.str());
         FILE *bin = fopen(binfile, "wb");
         if (!bin)

+ 7 - 1
system/include/platform.h

@@ -37,6 +37,12 @@
 #define _ARCH_ARM64_
 #endif
 
+// Identify all possible flags that mean ppc64el
+#if defined(__powerpc__) || defined(__powerpc64__) \
+ || defined(__ppc__) || defined(__ppc64__) || defined(__ppc64el__)
+#define _ARCH_PPC64EL_
+#endif
+
 // Identify all possible flags that mean x86_64
 #if defined(__amd64__) || defined(__x86_64__) \
  || defined(_M_X64) || defined(_M_AMD64)
@@ -50,7 +56,7 @@
 
 // **** START OF X-PLATFORM SECTION ****
 
-#if defined(_ARCH_X86_64_) || defined(_ARCH_ARM64_) || __WORDSIZE==64
+#if defined(_ARCH_X86_64_) || defined(_ARCH_ARM64_) || defined(_ARCH_PPC64EL_) || __WORDSIZE==64
 #define __64BIT__
 #endif