NetBSD Problem Report #54357

From www@netbsd.org  Sun Jul  7 13:00:39 2019
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 "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 9C9CD7A171
	for <gnats-bugs@gnats.NetBSD.org>; Sun,  7 Jul 2019 13:00:39 +0000 (UTC)
Message-Id: <20190707130038.C47477A1A8@mollari.NetBSD.org>
Date: Sun,  7 Jul 2019 13:00:38 +0000 (UTC)
From: clement.bouvier.europe@gmail.com
Reply-To: clement.bouvier.europe@gmail.com
To: gnats-bugs@NetBSD.org
Subject: editor/ted editor does not build on macosx 
X-Send-Pr-Version: www-1.0

>Number:         54357
>Category:       pkg
>Synopsis:       editor/ted editor does not build on macosx
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 07 13:05:00 +0000 2019
>Last-Modified:  Wed Jul 10 05:55:01 +0000 2019
>Originator:     clément bouvier
>Release:        current
>Organization:
>Environment:
macosx Mojave 10.14.5
>Description:
ted editor does not build on macosx due to undefined symbol in the final binary.

appUtil.a (generated by the package) under macosx does not include the common symbols for the build to terminate.

>How-To-Repeat:
try to build the ted editor on macosx
>Fix:
Add -c flags to ranlib.

Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/editors/ted/Makefile,v
retrieving revision 1.63
diff -u -r1.63 Makefile
--- Makefile	12 Mar 2018 11:16:24 -0000	1.63
+++ Makefile	7 Jul 2019 12:59:14 -0000
@@ -52,6 +52,17 @@

 INSTALLATION_DIRS=	bin lib/X11/app-defaults ${AFMDIR} ${INDDIR} ${INFODIR}

+.include "../../mk/bsd.prefs.mk"
+
+# ranlib on macos does not include common-symbol in the table of contents.
+.if ${OPSYS} == "Darwin"
+SUBST_CLASSES+=         common-symbols
+SUBST_STAGE.common-symbols=     pre-configure
+SUBST_MESSAGE.common-symbols=   include common symbol in the table of contents
+SUBST_FILES.common-symbols=     appUtil/makefile.in
+SUBST_SED.common-symbols=       -e 's,@RANLIB@,@RANLIB@ -c,g'
+.endif
+
 post-extract:
 	@cd ${WRKSRC} ; ${TOOLS_PATH.bsdtar} xf tedPackage/TedBindist.tar

>Audit-Trail:
From: =?utf-8?Q?cl=C3=A9ment_bouvier?= <clement.bouvier.europe@gmail.com>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/54357: editor/ted editor does not build on macosx
Date: Tue, 9 Jul 2019 19:56:56 +0400

 There is better than the previous patch and more concise. The compiler =
 can produce no common-symbol with -fno-common.
 Sorry.

 Index: Makefile
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /cvsroot/pkgsrc/editors/ted/Makefile,v
 retrieving revision 1.63
 diff -u -r1.63 Makefile
 --- Makefile	12 Mar 2018 11:16:24 -0000	1.63
 +++ Makefile	9 Jul 2019 15:53:48 -0000
 @@ -34,6 +34,10 @@
  CONFIGURE_ENV+=3D	=
 ac_zlib_includes=3D"${BUILDLINK_PREFIX.zlib}/include"
  CONFIGURE_ENV+=3D	ac_zlib_libraries=3D"${BUILDLINK_PREFIX.zlib}/lib"=

 =20
 +# ranlib on macos does not include common symbols in the table of =
 contents
 +# so force the compiler to produce no common symbol
 +CFLAGS.Darwin+=3D		-fno-common
 +
  LDFLAGS.SunOS+=3D		-liconv
  LDFLAGS.Darwin+=3D	-liconv
  LDFLAGS+=3D		-lXft

 > Le 7 juil. 2019 =C3=A0 17:05, gnats-admin@netbsd.org a =C3=A9crit :
 >=20
 > Thank you very much for your problem report.
 > It has the internal identification `pkg/54357'.
 > The individual assigned to look at your
 > report is: pkg-manager.=20
 >=20
 >> Category:       pkg
 >> Responsible:    pkg-manager
 >> Synopsis:       editor/ted editor does not build on macosx
 >> Arrival-Date:   Sun Jul 07 13:05:00 +0000 2019
 >=20

From: David Holland <dholland-pbugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/54357: editor/ted editor does not build on macosx
Date: Tue, 9 Jul 2019 16:57:06 +0000

 On Sun, Jul 07, 2019 at 01:05:00PM +0000, clement.bouvier.europe@gmail.com wrote:
  > +# ranlib on macos does not include common-symbol in the table of contents.

 Is this true in general or caused by something about this package?
 Because if the former, I find it hard to believe this hasn't exploded
 5000 other packages...

 -- 
 David A. Holland
 dholland@netbsd.org

From: =?utf-8?Q?cl=C3=A9ment_bouvier?= <clement.bouvier.europe@gmail.com>
To: gnats-bugs@netbsd.org
Cc: pkg-manager@netbsd.org,
 gnats-admin@netbsd.org,
 pkgsrc-bugs@netbsd.org
Subject: Re: pkg/54357: editor/ted editor does not build on macosx
Date: Wed, 10 Jul 2019 09:49:51 +0400

 Hi David,

 About the general part with macosx (with the context of the package).
 $ uname -a:
 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; =
 root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64

 $ cat foo.c
 int i;

 $ cat bar.c
 extern int i;

 int inc(int s) {
     return i + s;=20
 }=20

 $ cat main.c
 #include <stdio.h>

 int inc(int s);

 int main(void) {
     printf("result: %d\n ", inc(1));
 }

 $ cc -c foo.c ; cc -c bar.c ; cc -c main.c

 $ nm -g foo.o
 0000000000000004 C _i

 $ nm -g bar.o
                                  U _i
 0000000000000000 T _inc

 $ nm -g main.o
                                  U _inc
 0000000000000000 T _main
                                  U _printf

 Now I want to create an archive with ar  and a table of symbols

 $ ar -rc foobar.a foo.o bar.o
 $ ranlib foobar.a

 Let's create the binary:
 $ cc -o app main.o foobar.a
 Undefined symbols for architecture x86_64:
      "_i", referenced from:
            _inc in foobar.a(bar.o)
           (maybe you meant: _inc)
 ld: symbol(s) not found for architecture x86_64
 clang: error: linker command failed with exit code 1 (use -v to see =
 invocation)

 Let's look at the TOC in foobar.a

 $ ar -x foobar.a '__.SYMDEF SORTED'
 $ od -c __.SYMDEF\ SORTED=20
 0000000   \b  \0  \0  \0  \0  \0  \0  \0  \b 002  \0  \0  \b  \0  \0  \0
 0000020    _   i   n   c  \0  \0  \0  \0                               =20=

 0000030

 There is no i symbol.
 Now the man of ranlib tells about -c flags:
 "Include  common  symbols  as  definitions  with  respect to the table =
 of contents.  This is seldom the intended behavior for linking from a
  library, as it forces the linking of a library member just because it =
 uses an uninitialized global that is undefined at that point  in  the
  linking.  This option is included only because this was the original =
 behavior of ranlib.  This option is not the default."

 Let's see:
 $ranlib -c foobar.a

 $ cc -o app main.o foobar.a ; ./app
 result: 1

 Now the TOC in footer.a has i symbol:

 $ ar -x  foobar.a '__.SYMDEF SORTED'
 $ od -c  __.SYMDEF\ SORTED
 0000000  020  \0  \0  \0  \0  \0  \0  \0   x  \0  \0  \0 003  \0  \0  \0
 0000020  020 002  \0  \0  \b  \0  \0  \0   _   i  \0   _   i   n   c  \0
 0000040

 About the ted editor, you have a linker error:

 Undefined symbols for architecture x86_64:
   "_UNI_DingbatsCodeSet", referenced from:
       _appFontOpenX11Fonts in appFrame.a(appFontX11.o)
   "_UNI_DingbatsToGlyphMapping", referenced from:
       _appFontOpenX11Fonts in appFrame.a(appFontX11.o)
       _utilTextConverterConvertFromUtf8 in =
 appUtil.a(utilTextConverter.o)
   "_UNI_SymbolCodeSet", referenced from:
       _appFontOpenX11Fonts in appFrame.a(appFontX11.o)
   "_UNI_SymbolToGlyphMapping", referenced from:
       _appFontOpenX11Fonts in appFrame.a(appFontX11.o)
       _utilTextConverterConvertFromUtf8 in =
 appUtil.a(utilTextConverter.o)
 ld: symbol(s) not found for architecture x86_64

 $ nm -g work/Ted-2.21/appFrame/appFontX11.o | grep _UNI
                  U _UNI_DingbatsCodeSet
                  U _UNI_DingbatsToGlyphMapping
                  U _UNI_SymbolCodeSet
                  U _UNI_SymbolToGlyphMapping

 $ grep -rn '_UNI_DingbatsCodeSet' work/Ted-2.21/
 Binary file work/Ted-2.21//appUtil/uniLegacyMapping.o matches
 Binary file work/Ted-2.21//appFrame/appFontX11.o matches
 Binary file work/Ted-2.21//lib/appUtil.a matches
 Binary file work/Ted-2.21//lib/appFrame.a matches

 $ nm -g work/Ted-2.21/appUtil/uniLegacyMapping.o
 0000000000000010 C _UNI_DingbatsCodeSet
 0000000000000010 C _UNI_DingbatsToGlyphMapping
 0000000000000010 C _UNI_SymbolCodeSet
 0000000000000010 C _UNI_SymbolToGlyphMapping

 The archive appFrame.a is built with ar and ranlib without the -c flags =
 (normal but it is not the default on macosx).

 Of course we can use the cflag -fno-common. We avoid the common-symbols =
 and so Ted finally builds.

 Do I answer to your question?

 Cl=C3=A9ment.





 > Le 9 juil. 2019 =C3=A0 21:00, David Holland =
 <dholland-pbugs@netbsd.org> a =C3=A9crit :
 >=20
 > The following reply was made to PR pkg/54357; it has been noted by =
 GNATS.
 >=20
 > From: David Holland <dholland-pbugs@netbsd.org>
 > To: gnats-bugs@netbsd.org
 > Cc:=20
 > Subject: Re: pkg/54357: editor/ted editor does not build on macosx
 > Date: Tue, 9 Jul 2019 16:57:06 +0000
 >=20
 > On Sun, Jul 07, 2019 at 01:05:00PM +0000, =
 clement.bouvier.europe@gmail.com wrote:
 >> +# ranlib on macos does not include common-symbol in the table of =
 contents.
 >=20
 > Is this true in general or caused by something about this package?
 > Because if the former, I find it hard to believe this hasn't exploded
 > 5000 other packages...
 >=20
 > --=20
 > David A. Holland
 > dholland@netbsd.org
 >=20

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.