NetBSD Problem Report #50877

From rhialto@falu.nl  Tue Mar  1 22:05:50 2016
Return-Path: <rhialto@falu.nl>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id B0A417ABD8
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  1 Mar 2016 22:05:50 +0000 (UTC)
Message-Id: <201603012205.u21M5hux016069@murthe.falu.nl>
Date: Tue, 1 Mar 2016 23:05:43 +0100 (CET)
From: rhialto@falu.nl
Reply-To: rhialto@falu.nl
To: gnats-bugs@NetBSD.org
Subject: misc/calibre needs -rpath options [with patch]
X-Send-Pr-Version: 3.95

>Number:         50877
>Category:       pkg
>Synopsis:       misc/calibre needs -rpath options [with patch]
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Mar 01 22:10:00 +0000 2016
>Last-Modified:  Wed Mar 02 23:55:00 +0000 2016
>Originator:     Rhialto
>Release:        NetBSD 7.0
>Organization:

>Environment:


System: NetBSD murthe.falu.nl 7.0 NetBSD 7.0 (GENERIC.201509250726Z) amd64
Architecture: x86_64
Machine: amd64
>Description:

	When building the package for misc/calibre, it is discovered
	that some -rpath options are needed:

=> Checking for missing run-time search paths in calibre-2.45.0
ERROR: lib/calibre/calibre/plugins/libheadless.so: missing library: libGL.so.2
ERROR: lib/calibre/calibre/plugins/libheadless.so: missing library: libfreetype.so.17
ERROR: lib/calibre/calibre/plugins/pictureflow.so: missing library: libGL.so.2
ERROR: lib/calibre/calibre/plugins/pictureflow.so: missing library: libfreetype.so.17
ERROR: lib/calibre/calibre/plugins/progress_indicator.so: missing library: libGL.so.2
ERROR: lib/calibre/calibre/plugins/progress_indicator.so: missing library: libfreetype.so.17
ERROR: lib/calibre/calibre/plugins/qt_hack.so: missing library: libGL.so.2
ERROR: lib/calibre/calibre/plugins/qt_hack.so: missing library: libfreetype.so.17
*** Error code 1
>How-To-Repeat:
	cd /usr/pkgsrc/misc/calibre
	make package

	This probably only happens if you use native X.
>Fix:

	I've included a diff for the Makefile and a diff for a patch.
	Since that tends to get unreadable, I've also included the new
	version of the patch as a whole.

	Alternatively, instead of adding several ldflags lines for 3
	plugins

+                ldflags=['-Wl,-rpath,@X11LIB@'],

	and passing that on to LIBS,

@@ -612,9 +616,11 @@ class Build(Command):
         macx {{
             QMAKE_LFLAGS += "-undefined dynamic_lookup"
         }}
+        LIBS += {ldflags}
         ''').format(
             target=sip['target'], headers=' '.join(sip['headers'] +
xt.headers), sources=' '.join(ext.sources + sip['sources']),
             sipinc=pyqt['sip_inc_dir'],
yinc=sysconfig.get_python_inc(), py_lib=py_lib,
+            ldflags=' '.join(ext.ldflags),

	it could also just be done with one

@@ -612,9 +616,11 @@ class Build(Command):
         macx {{
             QMAKE_LFLAGS += "-undefined dynamic_lookup"
         }}
+        LIBS += -Wl,-rpath,@X11LIB@

	since the affected plugins are exactly the pyqt_extensions.
	But I thought that would be less general.

	The result builds, packages, and even seems to run (I gave it a
	quick try) (which is an improvement over the last time I spent
	some time on calibre-2.*).

	I tried appending to other make variables than LIBS, but that
	didn't take effect.

Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/misc/calibre/Makefile,v
retrieving revision 1.124
diff -u -r1.124 Makefile
--- Makefile	5 Dec 2015 21:25:50 -0000	1.124
+++ Makefile	1 Mar 2016 21:05:52 -0000
@@ -71,6 +71,12 @@
 SUBST_STAGE.path=	post-patch
 SUBST_FILES.path=	${FIX_PYTHON_PATHS}

+SUBST_CLASSES+=		x11lib
+SUBST_STAGE.x11lib=     post-patch
+SUBST_SED.x11lib+=      -e 's,@X11LIB@,${X11BASE}/lib,'
+SUBST_MESSAGE.x11lib=   Fixing rpath for X11 libraries.
+SUBST_FILES.x11lib+=    setup/extensions.py
+
 REPLACE_BASH+=		resources/calibre-portable.sh

 # These ones are for replacing python[0-9*] with PYTHONBIN
Index: patches/patch-setup_extensions.py
===================================================================
RCS file: /cvsroot/pkgsrc/misc/calibre/patches/patch-setup_extensions.py,v
retrieving revision 1.5
diff -u -r1.5 patch-setup_extensions.py
--- patches/patch-setup_extensions.py	8 Feb 2015 00:37:10 -0000	1.5
+++ patches/patch-setup_extensions.py	1 Mar 2016 21:05:52 -0000
@@ -1,10 +1,55 @@
 $NetBSD: patch-setup_extensions.py,v 1.5 2015/02/08 00:37:10 wiz Exp $

 Fix build for pictureflow.
+Add -Wl,-rpath,@X11LIB@ where needed.

---- setup/extensions.py.orig	2014-08-29 03:59:29.000000000 +0000
+--- setup/extensions.py.orig	2015-11-27 03:22:13.000000000 +0000
 +++ setup/extensions.py
-@@ -602,7 +602,7 @@ class Build(Command):
+@@ -231,6 +231,7 @@ extensions = [
+                 ['calibre/gui2/pictureflow/pictureflow.cpp'],
+                 inc_dirs=['calibre/gui2/pictureflow'],
+                 headers=['calibre/gui2/pictureflow/pictureflow.h'],
++                ldflags=['-Wl,-rpath,@X11LIB@'],
+                 sip_files=['calibre/gui2/pictureflow/pictureflow.sip']
+                 ),
+ 
+@@ -238,6 +239,7 @@ extensions = [
+                 ['calibre/gui2/progress_indicator/QProgressIndicator.cpp'],
+                 inc_dirs=['calibre/gui2/progress_indicator'],
+                 headers=['calibre/gui2/progress_indicator/QProgressIndicator.h'],
++                ldflags=['-Wl,-rpath,@X11LIB@'],
+                 sip_files=['calibre/gui2/progress_indicator/QProgressIndicator.sip']
+                 ),
+ 
+@@ -245,6 +247,7 @@ extensions = [
+                 ['calibre/ebooks/pdf/render/qt_hack.cpp'],
+                 inc_dirs=['calibre/ebooks/pdf/render'],
+                 headers=['calibre/ebooks/pdf/render/qt_hack.h'],
++                ldflags=['-Wl,-rpath,@X11LIB@'],
+                 qt_private=['core', 'gui'],
+                 sip_files=['calibre/ebooks/pdf/render/qt_hack.sip']
+                 ),
+@@ -552,6 +555,7 @@ class Build(Command):
+             DESTDIR = {destdir}
+             CONFIG -= create_cmake  # Prevent qmake from generating a cmake build file which it puts in the calibre src directory
+             QMAKE_LIBS_PRIVATE += {glib} {fontconfig}
++            LIBS += -Wl,-rpath,@X11LIB@
+             ''').format(
+                 headers=' '.join(headers), sources=' '.join(sources), others=' '.join(others), destdir=self.d(
+                     target), glib=glib_flags, fontconfig=fontconfig_flags, freetype=' '.join(ft_inc_dirs))
+@@ -612,9 +616,11 @@ class Build(Command):
+         macx {{
+             QMAKE_LFLAGS += "-undefined dynamic_lookup"
+         }}
++        LIBS += {ldflags}
+         ''').format(
+             target=sip['target'], headers=' '.join(sip['headers'] + ext.headers), sources=' '.join(ext.sources + sip['sources']),
+             sipinc=pyqt['sip_inc_dir'], pyinc=sysconfig.get_python_inc(), py_lib=py_lib,
++            ldflags=' '.join(ext.ldflags),
+             ver=__version__
+         )
+         for incdir in ext.inc_dirs:
+@@ -635,7 +641,7 @@ class Build(Command):
          if iswindows:
              qmc += ['-spec', 'win32-msvc2008']
          fext = 'dll' if iswindows else 'dylib' if isosx else 'so'


Full version of patches/patch-setup_extensions.py:

$NetBSD: patch-setup_extensions.py,v 1.5 2015/02/08 00:37:10 wiz Exp $

Fix build for pictureflow.
Add -Wl,-rpath,@X11LIB@ where needed.

--- setup/extensions.py.orig	2015-11-27 03:22:13.000000000 +0000
+++ setup/extensions.py
@@ -231,6 +231,7 @@ extensions = [
                 ['calibre/gui2/pictureflow/pictureflow.cpp'],
                 inc_dirs=['calibre/gui2/pictureflow'],
                 headers=['calibre/gui2/pictureflow/pictureflow.h'],
+                ldflags=['-Wl,-rpath,@X11LIB@'],
                 sip_files=['calibre/gui2/pictureflow/pictureflow.sip']
                 ),

@@ -238,6 +239,7 @@ extensions = [
                 ['calibre/gui2/progress_indicator/QProgressIndicator.cpp'],
                 inc_dirs=['calibre/gui2/progress_indicator'],
                 headers=['calibre/gui2/progress_indicator/QProgressIndicator.h'],
+                ldflags=['-Wl,-rpath,@X11LIB@'],
                 sip_files=['calibre/gui2/progress_indicator/QProgressIndicator.sip']
                 ),

@@ -245,6 +247,7 @@ extensions = [
                 ['calibre/ebooks/pdf/render/qt_hack.cpp'],
                 inc_dirs=['calibre/ebooks/pdf/render'],
                 headers=['calibre/ebooks/pdf/render/qt_hack.h'],
+                ldflags=['-Wl,-rpath,@X11LIB@'],
                 qt_private=['core', 'gui'],
                 sip_files=['calibre/ebooks/pdf/render/qt_hack.sip']
                 ),
@@ -552,6 +555,7 @@ class Build(Command):
             DESTDIR = {destdir}
             CONFIG -= create_cmake  # Prevent qmake from generating a cmake build file which it puts in the calibre src directory
             QMAKE_LIBS_PRIVATE += {glib} {fontconfig}
+            LIBS += -Wl,-rpath,@X11LIB@
             ''').format(
                 headers=' '.join(headers), sources=' '.join(sources), others=' '.join(others), destdir=self.d(
                     target), glib=glib_flags, fontconfig=fontconfig_flags, freetype=' '.join(ft_inc_dirs))
@@ -612,9 +616,11 @@ class Build(Command):
         macx {{
             QMAKE_LFLAGS += "-undefined dynamic_lookup"
         }}
+        LIBS += {ldflags}
         ''').format(
             target=sip['target'], headers=' '.join(sip['headers'] + ext.headers), sources=' '.join(ext.sources + sip['sources']),
             sipinc=pyqt['sip_inc_dir'], pyinc=sysconfig.get_python_inc(), py_lib=py_lib,
+            ldflags=' '.join(ext.ldflags),
             ver=__version__
         )
         for incdir in ext.inc_dirs:
@@ -635,7 +641,7 @@ class Build(Command):
         if iswindows:
             qmc += ['-spec', 'win32-msvc2008']
         fext = 'dll' if iswindows else 'dylib' if isosx else 'so'
-        name = '%s%s.%s' % ('release/' if iswindows else 'lib', sip['target'], fext)
+        name = '%s%s.%s' % ('release/' if iswindows else '.libs/lib', sip['target'], fext)
         try:
             os.chdir(src_dir)
             if self.newer(dest, sip['headers'] + sip['sources'] + ext.sources + ext.headers):

-Olaf.
-- 
___ Olaf 'Rhialto' Seibert  -- The Doctor: No, 'eureka' is Greek for
\X/ rhialto/at/xs4all.nl    -- 'this bath is too hot.'

>Audit-Trail:
From: Rhialto <rhialto@falu.nl>
To: gnats-admin@netbsd.org
Cc: rhialto@falu.nl
Subject: Re: pkg/50877: misc/calibre needs -rpath options [with patch]
Date: Wed, 2 Mar 2016 20:47:41 +0100

 Looking a bit further, it doesn't work completely. In the ebook-viewer,
 when you choose "Inspect" from the context menu, it crashes after
 drawing some of the Inspector window. This worked with misc/calibre1.
 Selecting text also seems broken: it always selects whole paragraphs on
 the first click; drag selection doesn't happen.

 Given that it crashes in some text-related function, I wonder if this
 message is related, that I get several times:

 XmbTextListToTextProperty result code -2

 Choosing an UTF-8 locale instead of Latin-1 seems to make no difference.

 This is of course a separate matter, but sort-of a contiuation of
 earlier problems with this series of Calibre. If/when I find something
 useful about this I'll open a new pr.

 Sample backtrace:

 Program received signal SIGSEGV, Segmentation fault.
 0x00007f7fda8d67e3 in WTF::Vector<WTF::OwnPtr<JSC::Yarr::CharacterClass>, 0ul, WTF::CrashOnOverflow>::shrink(unsigned long) ()
    from /usr/pkg/qt5/lib/libWebCore.so.1
 #0  0x00007f7fda8d67e3 in WTF::Vector<WTF::OwnPtr<JSC::Yarr::CharacterClass>, 0ul, WTF::CrashOnOverflow>::shrink(unsigned long) ()
    from /usr/pkg/qt5/lib/libWebCore.so.1
 #1  0x00007f7fdb162879 in WebCore::ContentSearchUtils::findMagicComment(WTF::String const&, WTF::String const&) () from /usr/pkg/qt5/lib/libWebCore.so.1
 #2  0x00007f7fdb162afc in WebCore::ContentSearchUtils::findStylesheetSourceMapURL(WTF::String const&) () from /usr/pkg/qt5/lib/libWebCore.so.1
 #3  0x00007f7fdb1764a3 in WebCore::InspectorPageAgent::sourceMapURLForResource(WebCore::CachedResource*) () from /usr/pkg/qt5/lib/libWebCore.so.1
 #4  0x00007f7fdb1b7518 in WebCore::InspectorPageAgent::buildObjectForFrameTree(WebCore::Frame*) () from /usr/pkg/qt5/lib/libWebCore.so.1
 #5  0x00007f7fdb1b7811 in WebCore::InspectorPageAgent::getResourceTree(WTF::String*, WTF::RefPtr<WebCore::TypeBuilder::Page::FrameResourceTree>&) ()
    from /usr/pkg/qt5/lib/libWebCore.so.1
 #6  0x00007f7fdb025f57 in WebCore::InspectorBackendDispatcherImpl::Page_getResourceTree(long, WebCore::InspectorObject*) ()
    from /usr/pkg/qt5/lib/libWebCore.so.1
 #7  0x00007f7fdb0521f8 in WebCore::InspectorBackendDispatcherImpl::dispatch(WTF::String const&) () from /usr/pkg/qt5/lib/libWebCore.so.1
 #8  0x00007f7fdb15b013 in WebCore::InspectorBackendDispatchTask::onTimer(WebCore::Timer<WebCore::InspectorBackendDispatchTask>*) ()
    from /usr/pkg/qt5/lib/libWebCore.so.1
 #9  0x00007f7fda8ed8ba in WebCore::ThreadTimers::sharedTimerFiredInternal() ()
    from /usr/pkg/qt5/lib/libWebCore.so.1
 #10 0x00007f7fe543a107 in QObject::event(QEvent*) ()
    from /usr/pkg/qt5/lib/libQt5Core.so.5
 #11 0x00007f7fe73c7df0 in QApplicationPrivate::notify_helper(QObject*, QEvent*)
     () from /usr/pkg/qt5/lib/libQt5Widgets.so.5
 #12 0x00007f7fe73cc8d3 in QApplication::notify(QObject*, QEvent*) ()
    from /usr/pkg/qt5/lib/libQt5Widgets.so.5
 #13 0x00007f7fe81b52ed in sipQApplication::notify(QObject*, QEvent*) ()
    from /usr/pkg/lib/python2.7/site-packages/PyQt5/QtWidgets.so
 #14 0x00007f7fe541aee3 in QCoreApplication::notifyInternal(QObject*, QEvent*)
     () from /usr/pkg/qt5/lib/libQt5Core.so.5
 #15 0x00007f7fe545743c in QTimerInfoList::activateTimers() ()
    from /usr/pkg/qt5/lib/libQt5Core.so.5
 #16 0x00007f7fe5457503 in idleTimerSourceDispatch(_GSource*, int (*)(void*), void*) () from /usr/pkg/qt5/lib/libQt5Core.so.5
 #17 0x00007f7fea0441c5 in g_main_context_dispatch ()
    from /usr/pkg/lib/libglib-2.0.so.0
 #18 0x00007f7fea04438a in g_main_context_iterate.isra ()
    from /usr/pkg/lib/libglib-2.0.so.0
 #19 0x00007f7fea044454 in g_main_context_iteration ()
    from /usr/pkg/lib/libglib-2.0.so.0
 #20 0x00007f7fe5457799 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/pkg/qt5/lib/libQt5Core.so.5
 #21 0x00007f7fe5419f5a in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/pkg/qt5/lib/libQt5Core.so.5
 #22 0x00007f7fe542035c in QCoreApplication::exec() ()
    from /usr/pkg/qt5/lib/libQt5Core.so.5
 #23 0x00007f7fe81b38cf in meth_QApplication_exec_ ()
    from /usr/pkg/lib/python2.7/site-packages/PyQt5/QtWidgets.so
 #24 0x00007f7ff78d327e in PyEval_EvalFrameEx ()
    from /usr/pkg/lib/libpython2.7.so.1.0
 #25 0x00007f7ff78d4392 in PyEval_EvalCodeEx ()
    from /usr/pkg/lib/libpython2.7.so.1.0
 #26 0x00007f7ff78d2cdb in PyEval_EvalFrameEx ()
    from /usr/pkg/lib/libpython2.7.so.1.0
 #27 0x00007f7ff78d4392 in PyEval_EvalCodeEx ()
    from /usr/pkg/lib/libpython2.7.so.1.0
 #28 0x00007f7ff78d2cdb in PyEval_EvalFrameEx ()
    from /usr/pkg/lib/libpython2.7.so.1.0
 #29 0x00007f7ff78d4392 in PyEval_EvalCodeEx ()
    from /usr/pkg/lib/libpython2.7.so.1.0
 #30 0x00007f7ff78d443d in PyEval_EvalCode ()
    from /usr/pkg/lib/libpython2.7.so.1.0
 #31 0x00007f7ff78eb743 in run_mod () from /usr/pkg/lib/libpython2.7.so.1.0
 #32 0x00007f7ff78ec6a7 in PyRun_FileExFlags ()
    from /usr/pkg/lib/libpython2.7.so.1.0
 #33 0x00007f7ff78ed6bd in PyRun_SimpleFileExFlags ()
    from /usr/pkg/lib/libpython2.7.so.1.0
 #34 0x00007f7ff78fc813 in Py_Main () from /usr/pkg/lib/libpython2.7.so.1.0
 #35 0x0000000000400965 in _start ()


 -Olaf.
 -- 
 ___ Olaf 'Rhialto' Seibert  -- The Doctor: No, 'eureka' is Greek for
 \X/ rhialto/at/xs4all.nl    -- 'this bath is too hot.'

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.