Browse Source

HPCC-15106 Remove use of binutils library

Remove dependency on binutils, which has proved less portable than we hoped...

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 9 năm trước cách đây
mục cha
commit
763ef7f1e5

+ 0 - 64
cmake_modules/FindBINUTILS.cmake

@@ -1,64 +0,0 @@
-################################################################################
-#    HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
-#
-#    Licensed under the Apache License, Version 2.0 (the "License");
-#    you may not use this file except in compliance with the License.
-#    You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-#    Unless required by applicable law or agreed to in writing, software
-#    distributed under the License is distributed on an "AS IS" BASIS,
-#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#    See the License for the specific language governing permissions and
-#    limitations under the License.
-################################################################################
-
-
-# - Try to find the BinUtils development library Once done this will define
-#
-#  BINUTILS_FOUND - system has the BinUtils library BINUTILS_INCLUDE_DIR - the BinUtils include directory BINUTILS_LIBRARIES - The libraries needed 
-#  to use BinUtils
-IF (NOT BINUTILS_FOUND)
-  IF (NOT "${EXTERNALS_DIRECTORY}" STREQUAL "")
-    IF (${ARCH64BIT} EQUAL 1)
-      SET (osdir "linux64_gcc4.1.1")
-    ELSE()
-      SET (osdir "linux32_gcc4.1.1")
-    ENDIF()
-    FIND_PATH (BINUTILS_INCLUDE_DIR NAMES bfd.h PATHS "${EXTERNALS_DIRECTORY}/binutils/${osdir}/include" NO_DEFAULT_PATH)
-    FIND_LIBRARY (BINUTILS_LIBRARIES NAMES bfd PATHS "${EXTERNALS_DIRECTORY}/binutils/${osdir}/lib" NO_DEFAULT_PATH)
-    # We also need libiberty - but that is complicated by the fact that some distros ship libibery_pic that you have to use in .so's, while on others libiberty.a is PIC-friendly
-    FIND_LIBRARY (IBERTY_LIBRARIES NAMES iberty_pic PATHS "${EXTERNALS_DIRECTORY}/binutils/${osdir}/lib" NO_DEFAULT_PATH)
-    FIND_LIBRARY (IBERTY_LIBRARIES NAMES iberty PATHS "${EXTERNALS_DIRECTORY}/binutils/${osdir}/lib" NO_DEFAULT_PATH)
-  ENDIF()
-  # if we didn't find in externals, look in system include path
-  if (USE_NATIVE_LIBRARIES)
-    FIND_PATH (BINUTILS_INCLUDE_DIR NAMES bfd.h)
-    FIND_LIBRARY (BINUTILS_LIBRARIES NAMES bfd)
-    if ( NOT APPLE )
-      FIND_LIBRARY (IBERTY_LIBRARIES NAMES iberty_pic)
-      FIND_LIBRARY (IBERTY_LIBRARIES NAMES iberty)
-    endif ( NOT APPLE )
-  endif()
-  include(FindPackageHandleStandardArgs)
-  if ( NOT APPLE )
-    find_package_handle_standard_args(BinUtils DEFAULT_MSG
-      BINUTILS_LIBRARIES
-      BINUTILS_INCLUDE_DIR
-      IBERTY_LIBRARIES
-    )
-    IF (BINUTILS_FOUND)
-      set (BINUTILS_LIBRARIES ${BINUTILS_LIBRARIES} ${IBERTY_LIBRARIES} )
-    ENDIF()
-  else ( NOT APPLE )
-    find_package_handle_standard_args(BinUtils DEFAULT_MSG
-      BINUTILS_LIBRARIES
-      BINUTILS_INCLUDE_DIR
-    )
-    IF (BINUTILS_FOUND)
-      set (BINUTILS_LIBRARIES ${BINUTILS_LIBRARIES} )
-    ENDIF()
-  endif ( NOT APPLE )
-  MARK_AS_ADVANCED(BINUTILS_INCLUDE_DIR BINUTILS_LIBRARIES)
-ENDIF()

+ 0 - 14
cmake_modules/commonSetup.cmake

@@ -52,11 +52,6 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
   option(PLUGIN "Enable building of a plugin" OFF)
   option(USE_SHLIBDEPS "Enable the use of dpkg-shlibdeps on ubuntu packagin" OFF)
 
-  if (APPLE OR WIN32)
-    option(USE_BINUTILS "Enable use of binutils to embed workunit info into shared objects" OFF)
-  else()
-    option(USE_BINUTILS "Enable use of binutils to embed workunit info into shared objects" ON)
-  endif()
   option(USE_CPPUNIT "Enable unit tests (requires cppunit)" OFF)
   option(USE_OPENLDAP "Enable OpenLDAP support (requires OpenLDAP)" ON)
   option(USE_ICU "Enable unicode support (requires ICU)" ON)
@@ -665,15 +660,6 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
   ENDIF(MAKE_DOCS)
 
   IF ( NOT MAKE_DOCS_ONLY )
-      IF (USE_BINUTILS AND NOT WIN32 AND NOT APPLE)
-        find_package(BINUTILS)
-        IF (BINUTILS_FOUND)
-          add_definitions (-D_USE_BINUTILS)
-        ELSE()
-          message(FATAL_ERROR "BINUTILS requested but package not found")
-        ENDIF()
-      ENDIF()
-
       IF (USE_OPENLDAP)
         find_package(OPENLDAP)
         IF (OPENLDAP_FOUND)

+ 3 - 45
common/dllserver/thorplugin.cpp

@@ -23,11 +23,7 @@
 #include "jdebug.hpp"
 #include "jlzw.hpp"
 #include "eclrtl.hpp"
-#ifdef _USE_BINUTILS
-#define PACKAGE "hpcc-system"
-#define PACKAGE_VERSION "1.0"
-#include "bfd.h"
-#elif defined(__APPLE__)
+#if defined(__APPLE__)
 #include <mach-o/getsect.h>
 #include <sys/mman.h>
 #include <sys/stat.h>
@@ -228,33 +224,9 @@ bool HelperDll::getResource(size32_t & len, const void * & data, const char * ty
 #endif
 }
 
-#ifdef _USE_BINUTILS
-struct SecScanParam
-{
-    MemoryBuffer &result;
-    const char *sectionName;
-    SecScanParam(MemoryBuffer &_result, const char *_sectionName) 
-        : result(_result), sectionName(_sectionName)
-    {
-    }
-};
-
-static void secscan (bfd *file, sec_ptr sec, void *userParam)
-{
-    SecScanParam *param = (SecScanParam *) userParam;
-    if (strcmp(param->sectionName, bfd_section_name (file, sec))==0)
-    {
-        bfd_size_type size = bfd_section_size (file, sec);
-        void *data = (void *) param->result.reserve(size);
-        bfd_get_section_contents(file, sec, data, 0, size);
-    }
-}
-static CriticalSection bfdCs;
-#endif
-
 static bool getResourceFromMappedFile(const char * filename, const byte * start_addr, MemoryBuffer &data, const char * type, unsigned id)
 {
-#if defined(_WIN32) || defined (_USE_BINUTILS)
+#if defined(_WIN32)
     throwUnexpected();
 #elif defined(__APPLE__)
     VStringBuffer sectname("%s_%u", type, id);
@@ -270,7 +242,7 @@ static bool getResourceFromMappedFile(const char * filename, const byte * start_
     unsigned char *data2 = getsectiondata(mh, "__TEXT", sectname.str(), &len);
     data.append(len, data2);
     return true;
-#elif defined (__64bit__)
+#elif defined (__64BIT__)
     // The first bytes are the ELF header
     const Elf64_Ehdr * hdr = (const Elf64_Ehdr *) start_addr;
     if (memcmp(hdr->e_ident, ELFMAG, SELFMAG) != 0)
@@ -372,20 +344,6 @@ extern bool getResourceFromFile(const char *filename, MemoryBuffer &data, const
     data.append(len, rdata);
     FreeLibrary(dllHandle);
     return true;
-#elif defined (_USE_BINUTILS)
-    CriticalBlock block(bfdCs);
-    bfd_init ();
-    bfd *file = bfd_openr(filename, NULL);
-    if (file)
-    {
-        StringBuffer sectionName;
-        sectionName.append(type).append("_").append(id).append(".data");
-        SecScanParam param(data, sectionName.str());
-        if (bfd_check_format (file, bfd_object))
-            bfd_map_over_sections (file, secscan, &param);
-        bfd_close (file);
-   }
-   return data.length() != 0;
 #else
     struct stat stat_buf;
     VStringBuffer sectname("%s_%u", type, id);

+ 0 - 84
ecl/hqlcpp/hqlres.cpp

@@ -23,11 +23,6 @@
 #include "jexcept.hpp"
 #include "hqlcerrors.hpp"
 #include "thorplugin.hpp"
-#ifdef _USE_BINUTILS
-#define PACKAGE "hpcc-system"
-#define PACKAGE_VERSION "1.0"
-#include "bfd.h"
-#endif
 
 #define BIGSTRING_BASE 101
 #define MANIFEST_BASE 1000
@@ -462,85 +457,6 @@ bool ResourceManager::flush(StringBuffer &filename, const char *basename, bool f
             putbytes(h, "\x00\x00\x00",4-(totalbytes & 3));
     }
     _close(h);
-#elif defined(_USE_BINUTILS)
-    filename.append(basename).append(".res.o");
-    asymbol **syms = NULL;
-    bfd *file = NULL;
-    StringArray names;  // need to make sure that the strings we use in symbol table have appropriate lifetime 
-    try 
-    {
-        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
-        verifyex(file);
-        verifyex(bfd_set_arch_mach(file, temp_arch_info->arch, temp_arch_info->mach));
-        verifyex(bfd_set_start_address(file, 0));
-        verifyex(bfd_set_format(file, bfd_object));
-        syms = new asymbol *[resources.length()*2+1];
-        ForEachItemIn(idx, resources)
-        {
-            ResourceItem&s = (ResourceItem&)resources.item(idx);
-            unsigned len = (unsigned)s.data.length();
-            unsigned id = s.id;
-            StringBuffer baseName;
-            baseName.append(s.type).append("_").append(id);
-            StringBuffer str;
-            str.clear().append(baseName).append(".data");
-            names.append(str);
-            sec_ptr osection = bfd_make_section_anyway_with_flags (file, names.tos(), SEC_HAS_CONTENTS|SEC_ALLOC|SEC_LOAD|SEC_DATA|SEC_READONLY);
-            verifyex(osection);
-            verifyex(bfd_set_section_size(file, osection, len));
-            verifyex(bfd_set_section_vma(file, osection, 0));
-            bfd_set_reloc (file, osection, NULL, 0);
-            osection->lma=0;
-            osection->entsize=0;
-            syms[idx*2] = bfd_make_empty_symbol(file);
-            syms[idx*2]->flags = BSF_GLOBAL;
-            syms[idx*2]->section = osection;
-            names.append(str.clear().append(baseName).append("_txt_start"));
-            syms[idx*2]->name = names.tos();
-            syms[idx*2]->value = 0;
-            syms[idx*2+1] = bfd_make_empty_symbol(file);
-            syms[idx*2+1]->flags = BSF_GLOBAL;
-            syms[idx*2+1]->section = bfd_abs_section_ptr;
-            names.append(str.clear().append(baseName).append("_txt_size"));
-            syms[idx*2+1]->name = names.tos();
-            syms[idx*2+1]->value = len;
-        }
-        syms[resources.length()*2] = NULL;
-        bfd_set_symtab (file, syms, resources.length()*2);
-        // experience suggests symtab need to be in place before setting contents
-        ForEachItemIn(idx2, resources)
-        {
-            ResourceItem &s = (ResourceItem&)resources.item(idx2);
-            verifyex(bfd_set_section_contents(file, syms[idx2*2]->section, s.data.get(), 0, s.data.length()));
-        }
-        verifyex(bfd_close(file));
-        delete [] syms;
-    }
-    catch (IException *E)
-    {
-        E->Release();
-        //translate the assert exceptions into something else...
-        StringBuffer msg;
-        msg.appendf("%s: %s", filename.str(), bfd_errmsg(bfd_get_error()));
-        delete syms;
-        if (file)
-            bfd_close_all_done(file); // allow bfd to clean up memory
-        throwError1(HQLERR_ResourceCreateFailed, msg.str());
-    }
 #else
     isObjectFile = false;
     filename.append(basename).append(".res.s");

+ 0 - 2
system/jlib/jcomp.cpp

@@ -734,8 +734,6 @@ void CppCompiler::removeTemporaries()
             remove(temp.clear().append(targetDir).append(coreName).append(".lib").str());
 #ifdef _WIN32
             remove(temp.clear().append(targetDir).append(coreName).append(".res").str());
-#elif defined (_USE_BINUTILS)
-            remove(temp.clear().append(targetDir).append(coreName).append(".res.o").str());
 #else
             temp.clear().append(coreName).append(".res.s*");
             DBGLOG("Remove %s%s",targetDir.str(), temp.str());