SOURCES: kdelibs-kill_la_loader.patch (NEW) - kill .la loader, use...

pluto pluto at pld-linux.org
Fri Dec 15 23:19:53 CET 2006


Author: pluto                        Date: Fri Dec 15 22:19:53 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- kill .la loader, use classic dlopen() and remove .la files
  from package. with this change we can avoid silly libtool
  deps for e.g. xorg-*-devel in kde apps/plugins.

---- Files affected:
SOURCES:
   kdelibs-kill_la_loader.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/kdelibs-kill_la_loader.patch
diff -u /dev/null SOURCES/kdelibs-kill_la_loader.patch:1.1
--- /dev/null	Fri Dec 15 23:19:53 2006
+++ SOURCES/kdelibs-kill_la_loader.patch	Fri Dec 15 23:19:48 2006
@@ -0,0 +1,469 @@
+
+ kdecore/klibloader.cpp |   58 +++++++----------------------
+ kinit/kinit.cpp        |   95 ++++++++-----------------------------------------
+ kinit/kioslave.cpp     |   31 ++++-----------
+ kio/kio/kimageio.cpp   |   21 +++-------
+ 4 files changed, 46 insertions(+), 159 deletions(-)
+
+--- kdelibs-3.5.5/kdecore/klibloader.cpp.orig	2006-01-19 18:06:18.000000000 +0100
++++ kdelibs-3.5.5/kdecore/klibloader.cpp	2006-12-15 22:55:01.190507250 +0100
+@@ -31,28 +31,11 @@
+ #include "kdebug.h"
+ #include "klocale.h"
+ 
+-#include "ltdl.h"
+-
+ template class QAsciiDict<KLibrary>;
+ 
+ #include <stdlib.h> //getenv
+ 
+-
+-#if HAVE_DLFCN_H
+-#  include <dlfcn.h>
+-#endif
+-
+-#ifdef RTLD_GLOBAL
+-#  define LT_GLOBAL             RTLD_GLOBAL
+-#else
+-#  ifdef DL_GLOBAL
+-#    define LT_GLOBAL           DL_GLOBAL
+-#  endif
+-#endif /* !RTLD_GLOBAL */
+-#ifndef LT_GLOBAL
+-#  define LT_GLOBAL             0
+-#endif /* !LT_GLOBAL */
+-
++#include <dlfcn.h>
+ 
+ class KLibLoaderPrivate
+ {
+@@ -178,10 +161,10 @@
+ 
+ void* KLibrary::symbol( const char* symname ) const
+ {
+-    void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname );
++    void* sym = dlsym( m_handle, symname );
+     if ( !sym )
+     {
+-        KLibLoader::self()->d->errorMessage = "KLibrary: " + QString::fromLocal8Bit( lt_dlerror() );
++        KLibLoader::self()->d->errorMessage = "KLibrary: " + QString::fromLocal8Bit( dlerror() );
+         kdWarning(150) << KLibLoader::self()->d->errorMessage << endl;
+         return 0;
+     }
+@@ -191,7 +174,7 @@
+ 
+ bool KLibrary::hasSymbol( const char* symname ) const
+ {
+-    void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname );
++    void* sym = dlsym( m_handle, symname );
+     return (sym != 0L );
+ }
+ 
+@@ -261,24 +244,24 @@
+ class KLibWrapPrivate
+ {
+ public:
+-    KLibWrapPrivate(KLibrary *l, lt_dlhandle h);
++    KLibWrapPrivate(KLibrary *l, void* h);
+ 
+     KLibrary *lib;
+     enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode;
+     int ref_count;
+-    lt_dlhandle handle;
++    void* handle;
+     QString name;
+     QString filename;
+ };
+ 
+-KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, lt_dlhandle h)
++KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, void* h)
+  : lib(l), ref_count(1), handle(h), name(l->name()), filename(l->fileName())
+ {
+     unload_mode = UNKNOWN;
+-    if (lt_dlsym(handle, "__kde_do_not_unload") != 0) {
++    if (dlsym(handle, "__kde_do_not_unload") != 0) {
+ //        kdDebug(150) << "Will not unload " << name << endl;
+         unload_mode = DONT_UNLOAD;
+-    } else if (lt_dlsym(handle, "__kde_do_unload") != 0) {
++    } else if (dlsym(handle, "__kde_do_unload") != 0) {
+         unload_mode = UNLOAD;
+     }
+ }
+@@ -304,7 +287,6 @@
+ {
+     s_self = this;
+     d = new KLibLoaderPrivate;
+-    lt_dlinit();
+     d->unload_mode = KLibLoaderPrivate::UNKNOWN;
+     if (getenv("KDE_NOUNLOAD") != 0)
+         d->unload_mode = KLibLoaderPrivate::DONT_UNLOAD;
+@@ -341,7 +323,7 @@
+     if (pos < 0)
+       pos = 0;
+     if (libname.find('.', pos) < 0)
+-      libname += ".la";
++      libname += ".so";
+     return libname;
+ }
+ 
+@@ -373,17 +355,8 @@
+ 
+ KLibrary* KLibLoader::globalLibrary( const char *name )
+ {
+-KLibrary *tmp;
+-int olt_dlopen_flag = lt_dlopen_flag;
+-
+-   lt_dlopen_flag |= LT_GLOBAL;
+-   kdDebug(150) << "Loading the next library global with flag "
+-                << lt_dlopen_flag
+-                << "." << endl;
+-   tmp = library(name);
+-   lt_dlopen_flag = olt_dlopen_flag;
+-
+-return tmp;
++   KLibrary *tmp = library(name);
++   return tmp;
+ }
+ 
+ 
+@@ -425,11 +398,10 @@
+         d->errorMessage = i18n("Library files for \"%1\" not found in paths.").arg(libname);
+         return 0;
+       }
+-
+-      lt_dlhandle handle = lt_dlopen( QFile::encodeName(libfile) );
++      void* handle = dlopen( QFile::encodeName( libfile ), RTLD_LAZY | RTLD_GLOBAL );
+       if ( !handle )
+       {
+-        const char* errmsg = lt_dlerror();
++        const char* errmsg = dlerror();
+         if(errmsg)
+             d->errorMessage = QString::fromLocal8Bit(errmsg);
+         else
+@@ -564,7 +536,7 @@
+     }
+ 
+     deleted_one = true;
+-    lt_dlclose(wrap->handle);
++    dlclose(wrap->handle);
+     d->pending_close.removeRef(wrap);
+     /* loaded_stack is AutoDelete, so wrap is freed */
+     d->loaded_stack.remove();
+--- kdelibs-3.5.5/kinit/kinit.cpp.orig	2006-10-01 19:33:32.000000000 +0200
++++ kdelibs-3.5.5/kinit/kinit.cpp	2006-12-15 23:01:50.227996500 +0100
+@@ -73,7 +73,6 @@
+ 
+ #include <kdeversion.h>
+ 
+-#include "ltdl.h"
+ #include "klauncher_cmds.h"
+ 
+ //#if defined Q_WS_X11 && ! defined K_WS_QTONLY
+@@ -83,19 +82,7 @@
+ #include <X11/Xatom.h>
+ #endif
+ 
+-#ifdef HAVE_DLFCN_H
+-# include <dlfcn.h>
+-#endif
+-
+-#ifdef RTLD_GLOBAL
+-# define LTDL_GLOBAL	RTLD_GLOBAL
+-#else
+-# ifdef DL_GLOBAL
+-#  define LTDL_GLOBAL	DL_GLOBAL
+-# else
+-#  define LTDL_GLOBAL	0
+-# endif
+-#endif
++#include <dlfcn.h>
+ 
+ #if defined(KDEINIT_USE_XFT) && defined(KDEINIT_USE_FONTCONFIG)
+ #include <X11/Xft/Xft.h>
+@@ -105,7 +92,6 @@
+ 
+ extern char **environ;
+ 
+-extern int lt_dlopen_flag;
+ //#if defined Q_WS_X11 && ! defined K_WS_QTONLY
+ #ifdef Q_WS_X11
+ static int X11fd = -1;
+@@ -146,13 +132,12 @@
+   pid_t launcher_pid;
+   pid_t my_pid;
+   int n;
+-  lt_dlhandle handle;
+-  lt_ptr sym;
++  void* handle;
++  void* sym;
+   char **argv;
+   int (*func)(int, char *[]);
+   int (*launcher_func)(int);
+   bool debug_wait;
+-  int lt_dlopen_flag;
+   QCString errorMsg;
+   bool launcher_ok;
+   bool suicide;
+@@ -447,7 +432,7 @@
+   {
+      /* Relative name without '.la' */
+      name = _name;
+-     lib = name + ".la";
++     lib = name + ".so";
+      exec = name;
+      libpath = QFile::encodeName(KLibLoader::findLibrary( lib, s_instance ));
+      execpath = execpath_avoid_loops( exec, envc, envs, avoid_loops );
+@@ -595,25 +580,24 @@
+ 
+      if ( !libpath.isEmpty() )
+      {
+-       d.handle = lt_dlopen( QFile::encodeName(libpath) );
++       d.handle = dlopen( QFile::encodeName( libpath ), RTLD_LAZY | RTLD_GLOBAL );
+        if (!d.handle )
+        {
+-          const char * ltdlError = lt_dlerror();
++          const char * dlError = dlerror();
+           if (execpath.isEmpty())
+           {
+              // Error
+              QString errorMsg = i18n("Could not open library '%1'.\n%2").arg(QFile::decodeName(libpath))
+-		.arg(ltdlError ? QFile::decodeName(ltdlError) : i18n("Unknown error"));
++		.arg(dlError ? QFile::decodeName(dlError) : i18n("Unknown error"));
+              exitWithErrorMsg(errorMsg);
+           }
+           else
+           {
+              // Print warning
+-             fprintf(stderr, "Could not open library %s: %s\n", lib.data(), ltdlError != 0 ? ltdlError : "(null)" );
++             fprintf(stderr, "Could not open library %s: %s\n", lib.data(), dlError != 0 ? dlError : "(null)" );
+           }
+        }
+      }
+-     lt_dlopen_flag = d.lt_dlopen_flag;
+      if (!d.handle )
+      {
+         d.result = 2; // Try execing
+@@ -632,21 +616,21 @@
+         exit(255);
+      }
+ 
+-     d.sym = lt_dlsym( d.handle, "kdeinitmain");
++     d.sym = dlsym( d.handle, "kdeinitmain");
+      if (!d.sym )
+      {
+-        d.sym = lt_dlsym( d.handle, "kdemain" );
++        d.sym = dlsym( d.handle, "kdemain" );
+         if ( !d.sym )
+         {
+ #if ! KDE_IS_VERSION( 3, 90, 0 )
+-           d.sym = lt_dlsym( d.handle, "main");
++           d.sym = dlsym( d.handle, "main");
+ #endif
+            if (!d.sym )
+            {
+-              const char * ltdlError = lt_dlerror();
+-              fprintf(stderr, "Could not find kdemain: %s\n", ltdlError != 0 ? ltdlError : "(null)" );
++              const char * dlError = dlerror();
++              fprintf(stderr, "Could not find kdemain: %s\n", dlError != 0 ? dlError : "(null)" );
+               QString errorMsg = i18n("Could not find 'kdemain' in '%1'.\n%2").arg(libpath)
+-                 .arg(ltdlError ? QFile::decodeName(ltdlError) : i18n("Unknown error"));
++                 .arg(dlError ? QFile::decodeName(dlError) : i18n("Unknown error"));
+               exitWithErrorMsg(errorMsg);
+            }
+         }
+@@ -1465,51 +1449,6 @@
+ 
+ static void kdeinit_library_path()
+ {
+-   QStringList ltdl_library_path =
+-     QStringList::split(':', QFile::decodeName(getenv("LTDL_LIBRARY_PATH")));
+-   QStringList ld_library_path =
+-     QStringList::split(':', QFile::decodeName(getenv("LD_LIBRARY_PATH")));
+-
+-   QCString extra_path;
+-   QStringList candidates = s_instance->dirs()->resourceDirs("lib");
+-   for (QStringList::ConstIterator it = candidates.begin();
+-        it != candidates.end();
+-        it++)
+-   {
+-      QString d = *it;
+-      if (ltdl_library_path.contains(d))
+-          continue;
+-      if (ld_library_path.contains(d))
+-          continue;
+-      if (d[d.length()-1] == '/')
+-      {
+-         d.truncate(d.length()-1);
+-         if (ltdl_library_path.contains(d))
+-            continue;
+-         if (ld_library_path.contains(d))
+-            continue;
+-      }
+-      if ((d == "/lib") || (d == "/usr/lib"))
+-         continue;
+-
+-      QCString dir = QFile::encodeName(d);
+-
+-      if (access(dir, R_OK))
+-          continue;
+-
+-      if ( !extra_path.isEmpty())
+-         extra_path += ":";
+-      extra_path += dir;
+-   }
+-
+-   if (lt_dlinit())
+-   {
+-      const char * ltdlError = lt_dlerror();
+-      fprintf(stderr, "can't initialize dynamic loading: %s\n", ltdlError != 0 ? ltdlError : "(null)" );
+-   }
+-   if (!extra_path.isEmpty())
+-      lt_dlsetsearchpath(extra_path.data());
+-
+    QCString display = getenv(DISPLAY);
+    if (display.isEmpty())
+    {
+@@ -1772,8 +1711,6 @@
+    d.wrapper_old = 0;
+    d.debug_wait = false;
+    d.launcher_ok = false;
+-   d.lt_dlopen_flag = lt_dlopen_flag;
+-   lt_dlopen_flag |= LTDL_GLOBAL;
+    init_signals();
+ #ifdef Q_WS_X11
+    setupX();
+@@ -1807,9 +1744,9 @@
+ #ifndef __CYGWIN__
+    if (!d.suicide && !getenv("KDE_IS_PRELINKED"))
+    {
+-      QString konq = locate("lib", "libkonq.la", s_instance);
++      QString konq = locate("lib", "libkonq.so", s_instance);
+       if (!konq.isEmpty())
+-	  (void) lt_dlopen(QFile::encodeName(konq).data());
++         dlopen( QFile::encodeName( konq ).data() , RTLD_LAZY | RTLD_GLOBAL );
+    }
+ #endif 
+    if (launch_klauncher)
+--- kdelibs-3.5.5/kinit/kioslave.cpp.orig	2005-10-10 17:05:37.000000000 +0200
++++ kdelibs-3.5.5/kinit/kioslave.cpp	2006-12-15 23:02:51.479824500 +0100
+@@ -31,21 +31,7 @@
+ 
+ #include <qstring.h>
+ 
+-#include "ltdl.h"
+-
+-#ifdef HAVE_DLFCN_H
+-# include <dlfcn.h>
+-#endif
+-
+-#ifdef RTLD_GLOBAL
+-# define LTDL_GLOBAL	RTLD_GLOBAL
+-#else
+-# ifdef DL_GLOBAL
+-#  define LTDL_GLOBAL	DL_GLOBAL
+-# else
+-#  define LTDL_GLOBAL	0
+-# endif
+-#endif
++#include <dlfcn.h>
+ 
+ /* These are to link libkio even if 'smart' linker is used */
+ #include <kio/authinfo.h>
+@@ -65,24 +51,23 @@
+         fprintf(stderr, "library path is empty.\n");
+         exit(1); 
+      }
+-     lt_dlinit();
+ 
+-     lt_dlhandle handle = lt_dlopen( libpath.data() );
++     void* handle = dlopen( libpath.data(), RTLD_LAZY | RTLD_GLOBAL );
+      if (!handle )
+      {
+-        const char * ltdlError = lt_dlerror();
+-        fprintf(stderr, "could not open %s: %s", libpath.data(), ltdlError != 0 ? ltdlError : "(null)" );
++        const char * dlError = dlerror();
++        fprintf(stderr, "could not open %s: %s", libpath.data(), dlError != 0 ? dlError : "(null)" );
+         exit(1);
+      }  
+ 
+-     lt_ptr sym = lt_dlsym( handle, "kdemain");
++     void* sym = dlsym( handle, "kdemain");
+      if (!sym )
+      {
+-        sym = lt_dlsym( handle, "main");
++        sym = dlsym( handle, "main");
+         if (!sym )
+         {
+-           const char * ltdlError = lt_dlerror();
+-           fprintf(stderr, "Could not find main: %s\n", ltdlError != 0 ? ltdlError : "(null)" );
++           const char * dlError = dlerror();
++           fprintf(stderr, "Could not find main: %s\n", dlError != 0 ? dlError : "(null)" );
+            exit(1);
+         }
+      }
+--- kdelibs-3.5.5/kio/kio/kimageio.cpp.orig	2005-09-10 10:26:44.000000000 +0200
++++ kdelibs-3.5.5/kio/kio/kimageio.cpp	2006-12-15 23:04:44.706900750 +0100
+@@ -17,7 +17,7 @@
+ #include <qregexp.h>
+ #include <qvaluelist.h>
+ 
+-#include <ltdl.h>
++#include <dlfcn.h>
+ #include "kimageio.h"
+ #include "kimageiofactory.h"
+ #include <klocale.h>
+@@ -109,10 +109,10 @@
+          iio->setStatus(1); // Error
+          return;
+       }
+-      lt_dlhandle libhandle = lt_dlopen( QFile::encodeName(libpath) );
++      void* libhandle = dlopen( QFile::encodeName(libpath), RTLD_LAZY | RTLD_GLOBAL );
+       if (libhandle == 0) {
+          iio->setStatus(1); // error
+-         kdWarning() << "KImageIOFormat::callLibFunc: couldn't dlopen " << mLib << "(" << lt_dlerror() << ")" << endl;
++         kdWarning() << "KImageIOFormat::callLibFunc: couldn't dlopen " << mLib << "(" << dlerror() << ")" << endl;
+          return;
+       }
+       bLibLoaded = true;
+@@ -120,22 +120,22 @@
+       if (bRead)
+       {
+          funcName = "kimgio_"+mType.lower()+"_read";
+-         lt_ptr func = lt_dlsym(libhandle, funcName.ascii());
++         void* func = dlsym(libhandle, funcName.ascii());
+ 
+          if (func == NULL) {
+             iio->setStatus(1); // error
+-            kdWarning() << "couln't find " << funcName << " (" << lt_dlerror() << ")" << endl;
++            kdWarning() << "couln't find " << funcName << " (" << dlerror() << ")" << endl;
+          }
+          mReadFunc = (void (*)(QImageIO *))func;
+       }
+       if (bWrite)
+       {
+          funcName = "kimgio_"+mType.lower()+"_write";
+-         lt_ptr func = lt_dlsym(libhandle, funcName.ascii());
++         void* func = dlsym(libhandle, funcName.ascii());
+ 
+          if (func == NULL) {
+             iio->setStatus(1); // error
+-            kdWarning() << "couln't find " << funcName << " (" << lt_dlerror() << ")" << endl;
++            kdWarning() << "couln't find " << funcName << " (" << dlerror() << ")" << endl;
+          }
+          mWriteFunc = (void (*)(QImageIO *))func;
+       }
+@@ -169,14 +169,7 @@
+      KSycocaEntry::read(*m_str, mWritePattern);
+      KSycocaEntry::read(*m_str, rPath);
+      if (!formatList)
+-     {
+         kiioflsd.setObject( formatList, new KImageIOFormatList());
+-        lt_dlinit(); // Do this only once!
+-        // Add rPaths.
+-        for(QStringList::Iterator it = rPath.begin();
+-            it != rPath.end(); ++it)
+-           lt_dladdsearchdir( QFile::encodeName(*it) );
+-     }
+      load();
+   }
+   else
================================================================


More information about the pld-cvs-commit mailing list