NetBSD Problem Report #51689

From www@NetBSD.org  Sun Dec  4 07:21:22 2016
Return-Path: <www@NetBSD.org>
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 D493D7A170
	for <gnats-bugs@gnats.NetBSD.org>; Sun,  4 Dec 2016 07:21:22 +0000 (UTC)
Message-Id: <20161204072120.E2C4F7A346@mollari.NetBSD.org>
Date: Sun,  4 Dec 2016 07:21:20 +0000 (UTC)
From: davshao@gmail.com
Reply-To: davshao@gmail.com
To: gnats-bugs@NetBSD.org
Subject: devel/ncurses DragonFly libncurses.la has wrong libdir
X-Send-Pr-Version: www-1.0

>Number:         51689
>Category:       pkg
>Synopsis:       devel/ncurses DragonFly libncurses.la has wrong libdir
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    dfly-pkg-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Dec 04 07:25:00 +0000 2016
>Closed-Date:    Mon Oct 22 16:16:47 +0000 2018
>Last-Modified:  Mon Oct 22 16:16:47 +0000 2018
>Originator:     David Shao
>Release:        current pkgsrc
>Organization:
>Environment:
DragonFly  4.7-DEVELOPMENT DragonFly v4.7.0.945.gcac153-DEVELOPMENT #4: Sat Dec  3 10:39:18 PST 2016     xxxxxx@:/usr/obj/usr/src/sys/X86_64_GENERIC  x86_64

>Description:
On DragonFly 4.7-DEVELOPMENT, building devel/ncurses with entries in
/usr/pkg/etc/mk.conf:

PREFER_PKGSRC=		yes

CURSES_DEFAULT=ncurses
READLINE_DEFAULT=readline

results in /usr/pkg/lib/libncurses.la having an incorrect line:

# Directory that this library needs to be installed in:
libdir='/usr/pkgsrc/devel/ncurses/work/.destdir/usr/pkg/lib'

instead of 
libdir='/usr/pkg/lib'

Following the build one can see DESTDIR changing from:

cd c++ && /usr/pkg/bin/gmake DESTDIR="" RPATH_LIST="/usr/pkg/lib" all
gmake[1]: Entering directory '/usr/pkgsrc/devel/ncurses/work/ncurses-6.0/c++'

to what seems to result in an incorrect libdir being deduced once the build progresses to:

===> Installing for ncurses-6.0nb2
=> Creating installation directories
cd man && /usr/pkg/bin/gmake DESTDIR="/usr/pkgsrc/devel/ncurses/work/.destdir" RPATH_LIST="/usr/pkg/lib" install
gmake[1]: Entering directory '/usr/pkgsrc/devel/ncurses/work/ncurses-6.0/man'

This problem was submitted upstream but the upstream maintainer was unable to diagnose the problem, "libtool pkgsrc DragonFly base ncurses made private":

http://lists.gnu.org/archive/html/bug-ncurses/2016-02/msg00008.html

To quote:

"Other frameworks seem to support pkgconfig, but, I believe due to
pkgsrc not wanting conflicts with NetBSD's native xorg, pkgsrc
actively impedes the use of pkgconfig in preference to pkgsrc's
buildlink.  Other frameworks also seem to not use libtool to install
whereas pkgsrc does for ncurses.

The problem is that the libdir field in the resulting pkgsrc
libncurses.la on recent DragonFly alone draws in the build directory
from DESTDIR in addition to the desired /usr/pkg/lib.

It appears to me that what is happening is that at least one source
file in the ncurses subdirectory is being regenerated in the second
install pass, leading to the wrong DESTDIR being appended to
libncurses.la libdir.  In the initial pass to make the object files,
the DESTDIR of "" is what is desired for libdir: ...

As a workaround the patch below simply adds another pass into the
ncurses subdirectory right before the c++ subdirectory is processed.
This fixes the problem on recent DragonFly using pkgsrc and seems to
do no harm on FreeBSD 11-current amd64, FreeBSD 10-2-release, NetBSD
7.99.26 amd64 native xorg, and NetBSD 7.99.26 amd64 modular xorg."

In current patch I threw in various other fixes such as the rpath syntax.  Does devel/ncurses actually build on recent FreeBSD that has switched to a different name for the C++ lib?






>How-To-Repeat:

>Fix:

As a diff between devel/ncurses directories:

diff -Nur devel/ncurses/distinfo devel/ncurses.new/distinfo
--- devel/ncurses/distinfo	2015-11-02 19:27:50.000000000 -0800
+++ devel/ncurses.new/distinfo	2016-03-22 08:26:24.000000000 -0700
@@ -6,6 +6,7 @@
 Size (ncurses-6.0.tar.gz) = 3131891 bytes
 SHA1 (patch-aa) = 6acf84077e84fd693bb2b52377774db3d15b4f8f
 SHA1 (patch-ab) = 235ae1d844721a5ea9d027d051eedc0f7898413c
-SHA1 (patch-ac) = fd1892bfb4dcf8a22ae4654eb944eda9725f964e
+SHA1 (patch-ac) = 9737d0341cfd3128f8f8e61adb8d54399350ac10
+SHA1 (patch-aclocal.m4) = 905d3d933adbd96fc50d829e42a5b194e1618847
 SHA1 (patch-ncurses_base_MKlib__gen.sh) = f8ce67fbd273529e4161a2820677d05a623fd527
 SHA1 (patch-ncurses_tinfo_lib__baudrate.c) = e383a11530a3045e729ab8c738e57a9e217a994f
diff -Nur devel/ncurses/patches/patch-ac devel/ncurses.new/patches/patch-ac
--- devel/ncurses/patches/patch-ac	2015-08-17 10:10:32.000000000 -0700
+++ devel/ncurses.new/patches/patch-ac	2016-03-22 08:25:59.000000000 -0700
@@ -7,7 +7,28 @@

 --- configure.orig	2015-08-05 09:20:32.000000000 +0000
 +++ configure
-@@ -11090,12 +11090,7 @@ case ".$MANPAGE_RENAMES" in
+@@ -1496,7 +1496,7 @@ echo $ECHO_N "checking for prefix... $EC
+ if test "x$prefix" = "xNONE" ; then
+ 	case "$cf_cv_system_name" in
+ 		# non-vendor systems don't have a conflict
+-	(openbsd*|freebsd*|mirbsd*|linux*|cygwin*|msys*|k*bsd*-gnu|mingw*)
++	(openbsd*|freebsd*|dragonfly*|mirbsd*|linux*|cygwin*|msys*|k*bsd*-gnu|mingw*)
+ 		prefix=/usr
+ 		;;
+ 	(*)	prefix=$ac_default_prefix
+@@ -5862,7 +5862,10 @@ case $cf_cv_system_name in
+ (openbsd[2-9].*|mirbsd*)
+ 	LD_RPATH_OPT="-Wl,-rpath,"
+ 	;;
+-(dragonfly*|freebsd*)
++(dragonfly*)
++	LD_RPATH_OPT="-Wl,-rpath,"
++	;;
++(freebsd*)
+ 	LD_RPATH_OPT="-rpath "
+ 	;;
+ (netbsd*)
+@@ -11090,12 +11093,7 @@ case ".$MANPAGE_RENAMES" in
  (.no)
  	;;
  (.|.yes)
@@ -21,3 +42,24 @@
  	;;
  esac

+@@ -19307,6 +19305,9 @@ ac_main_return=return
+ 
+ if test -n "$GXX" ; then
+ case $cf_cv_system_name in
++(freebsd*)
++	cf_stdcpp_libname=c++
++	;;
+ (os2*)
+ 	cf_stdcpp_libname=stdcpp
+ 	;;
+@@ -23916,6 +23919,10 @@ echo "${as_me:-configure}:23723: testing
+ 		done
+ 	fi
+ 
++	if test "$cf_dir" == "c++" ; then
++		echo '	cd ncurses && ${MAKE} ${TOP_MFLAGS} $@' >>Makefile
++	fi
++
+ 	echo '	cd '$cf_dir' && ${MAKE} ${TOP_MFLAGS} $@' >>Makefile
+ done
+ 
diff -Nur devel/ncurses/patches/patch-aclocal.m4 devel/ncurses.new/patches/patch-aclocal.m4
--- devel/ncurses/patches/patch-aclocal.m4	1969-12-31 16:00:00.000000000 -0800
+++ devel/ncurses.new/patches/patch-aclocal.m4	2016-02-10 10:36:00.000000000 -0800
@@ -0,0 +1,46 @@
+$NetBSD$
+
+--- aclocal.m4.orig	2015-08-06 00:46:34.000000000 +0000
++++ aclocal.m4
+@@ -751,7 +751,7 @@ AC_MSG_CHECKING(for prefix)
+ if test "x$prefix" = "xNONE" ; then
+ 	case "$cf_cv_system_name" in
+ 		# non-vendor systems don't have a conflict
+-	(openbsd*|freebsd*|mirbsd*|linux*|cygwin*|msys*|k*bsd*-gnu|mingw*)
++	(openbsd*|freebsd*|dragonfly*|mirbsd*|linux*|cygwin*|msys*|k*bsd*-gnu|mingw*)
+ 		prefix=/usr
+ 		;;
+ 	(*)	prefix=$ac_default_prefix
+@@ -3140,7 +3140,10 @@ case $cf_cv_system_name in
+ (openbsd[[2-9]].*|mirbsd*)
+ 	LD_RPATH_OPT="-Wl,-rpath,"
+ 	;;
+-(dragonfly*|freebsd*)
++(dragonfly*)
++	LD_RPATH_OPT="-Wl,-rpath,"
++	;;
++(freebsd*)
+ 	LD_RPATH_OPT="-rpath "
+ 	;;
+ (netbsd*)
+@@ -3589,6 +3592,10 @@ CF_EOF
+ 		done
+ 	fi
+ 
++	if test "$cf_dir" == "c++" ; then
++		echo '	cd ncurses && ${MAKE} ${TOP_MFLAGS} [$]@' >>Makefile
++	fi
++
+ 	echo '	cd '$cf_dir' && ${MAKE} ${TOP_MFLAGS} [$]@' >>Makefile
+ done
+ 
+@@ -6253,6 +6260,9 @@ AC_DEFUN([CF_STDCPP_LIBRARY],
+ [
+ if test -n "$GXX" ; then
+ case $cf_cv_system_name in
++(freebsd*)
++	cf_stdcpp_libname=c++
++	;;
+ (os2*)
+ 	cf_stdcpp_libname=stdcpp
+ 	;;

Here is an individual new file patch for aclocal.m4:

$NetBSD$

--- aclocal.m4.orig	2015-08-06 00:46:34.000000000 +0000
+++ aclocal.m4
@@ -751,7 +751,7 @@ AC_MSG_CHECKING(for prefix)
 if test "x$prefix" = "xNONE" ; then
 	case "$cf_cv_system_name" in
 		# non-vendor systems don't have a conflict
-	(openbsd*|freebsd*|mirbsd*|linux*|cygwin*|msys*|k*bsd*-gnu|mingw*)
+	(openbsd*|freebsd*|dragonfly*|mirbsd*|linux*|cygwin*|msys*|k*bsd*-gnu|mingw*)
 		prefix=/usr
 		;;
 	(*)	prefix=$ac_default_prefix
@@ -3140,7 +3140,10 @@ case $cf_cv_system_name in
 (openbsd[[2-9]].*|mirbsd*)
 	LD_RPATH_OPT="-Wl,-rpath,"
 	;;
-(dragonfly*|freebsd*)
+(dragonfly*)
+	LD_RPATH_OPT="-Wl,-rpath,"
+	;;
+(freebsd*)
 	LD_RPATH_OPT="-rpath "
 	;;
 (netbsd*)
@@ -3589,6 +3592,10 @@ CF_EOF
 		done
 	fi

+	if test "$cf_dir" == "c++" ; then
+		echo '	cd ncurses && ${MAKE} ${TOP_MFLAGS} [$]@' >>Makefile
+	fi
+
 	echo '	cd '$cf_dir' && ${MAKE} ${TOP_MFLAGS} [$]@' >>Makefile
 done

@@ -6253,6 +6260,9 @@ AC_DEFUN([CF_STDCPP_LIBRARY],
 [
 if test -n "$GXX" ; then
 case $cf_cv_system_name in
+(freebsd*)
+	cf_stdcpp_libname=c++
+	;;
 (os2*)
 	cf_stdcpp_libname=stdcpp
 	;;


>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: pkg-manager->dragonfly-pkg-people
Responsible-Changed-By: hauke@NetBSD.org
Responsible-Changed-When: Sun, 04 Dec 2016 11:48:58 +0000
Responsible-Changed-Why:
This is a Dragonfly BSD issue.


From: Joerg Sonnenberger <joerg@bec.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/51689: devel/ncurses DragonFly libncurses.la has wrong libdir
Date: Sun, 4 Dec 2016 18:56:27 +0100

 On Sun, Dec 04, 2016 at 07:25:00AM +0000, davshao@gmail.com wrote:
 > # Directory that this library needs to be installed in:
 > libdir='/usr/pkgsrc/devel/ncurses/work/.destdir/usr/pkg/lib'

 Can you provide me with the work.log, please? There are a number of
 different ways this would have gone wrong, but it is easiest to tell
 from the wrapper output.

 Joerg

From: David Shao <davshao@gmail.com>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/51689: devel/ncurses DragonFly libncurses.la has wrong libdir
Date: Sun, 4 Dec 2016 19:50:35 -0800

 Sorry I did not make this clear.  There are multiple issues.

 I cannot verify at the moment because I am rebuilding a system after
 having to replace a motherboard, but I believe devel/ncurses has
 problems even building on recent FreeBSD that changed the name of its
 std c++ library.  That explains the lines in the patches:

 + case $cf_cv_system_name in
 ++(freebsd*)
 ++    cf_stdcpp_libname=c++
 ++    ;;

 So why hasn't this been noticed by anyone else?  I believe for almost
 anyone else, FreeBSD's base (n)curses implementation works fine, so
 usually pkgsrc ncurses does not have to be built.  I ran into this
 problem immediately because I standardized on

 PREFER_PKGSRC = yes
 CURSES_DEFAULT=ncurses
 READLINE_DEFAULT=readline

 FreeBSD ports does not notice because I believe an essential
 distinction may be that pkgsrc is building the C++ bindings while
 ports is not.  From pkgsrc devel/ncurses/Makefile.common:

 CONFIGURE_ARGS+=    --with-cxx-binding

 The big problem with devel/ncurses is indeed DragonFly, but I believe
 it may apply to any system that has privatized its base (n)curses even
 to the point where header files are not in the usual /usr/include.  I
 believe there is some interaction in the build when C++ bindings are
 enabled and when the base system lacks any trace of (n)curses that
 causes problems setting DESTDIR.  The heart of the patch for DragonFly
 is

 ++    if test "$cf_dir" == "c++" ; then
 ++        echo '    cd ncurses && ${MAKE} ${TOP_MFLAGS} $@' >>Makefile
 ++    fi
 ++

 (ncurses seems to generate its own Makefile) which simply adds another
 pass into ncurses to make whatever newly generated file may exist,
 somehow avoiding the bad DESTDIR problem.  My own testing with modular
 NetBSD and FreeBSD seems to indicate no problems with this extra pass.

 I made this PR so the information in it would be available for easy query.

From: "Thomas Klausner" <wiz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/51689 CVS commit: pkgsrc/devel/ncurses
Date: Fri, 30 Dec 2016 11:28:19 +0000

 Module Name:	pkgsrc
 Committed By:	wiz
 Date:		Fri Dec 30 11:28:19 UTC 2016

 Modified Files:
 	pkgsrc/devel/ncurses: distinfo
 	pkgsrc/devel/ncurses/patches: patch-ab patch-ac

 Log Message:
 rpath should not include DESTDIR.

 Hopefully addresses PR 51689.


 To generate a diff of this commit:
 cvs rdiff -u -r1.30 -r1.31 pkgsrc/devel/ncurses/distinfo
 cvs rdiff -u -r1.19 -r1.20 pkgsrc/devel/ncurses/patches/patch-ab
 cvs rdiff -u -r1.24 -r1.25 pkgsrc/devel/ncurses/patches/patch-ac

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Fri, 30 Dec 2016 11:42:57 +0000
State-Changed-Why:
I think I just fixed this, please test.


Responsible-Changed-From-To: dragonfly-pkg-people->dfly-pkg-people
Responsible-Changed-By: dholland@NetBSD.org
Responsible-Changed-When: Tue, 03 Jan 2017 10:36:33 +0000
Responsible-Changed-Why:
use right address


State-Changed-From-To: feedback->closed
State-Changed-By: sevan@NetBSD.org
State-Changed-When: Mon, 22 Oct 2018 16:16:47 +0000
State-Changed-Why:
I have a ncurses-6.1nb2.tgz package from my bulkbuild, looks like it's fixed.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.