NetBSD Problem Report #54363

From www@netbsd.org  Tue Jul  9 13:57:48 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 290AA7A188
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  9 Jul 2019 13:57:48 +0000 (UTC)
Message-Id: <20190709135746.ECAC37A1C2@mollari.NetBSD.org>
Date: Tue,  9 Jul 2019 13:57:46 +0000 (UTC)
From: clement.bouvier.europe@gmail.com
Reply-To: clement.bouvier.europe@gmail.com
To: gnats-bugs@NetBSD.org
Subject: archivers/libcomprex failed to build on macosx
X-Send-Pr-Version: www-1.0

>Number:         54363
>Category:       pkg
>Synopsis:       archivers/libcomprex failed to build on macosx
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    macos-pkg-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jul 09 14:00:00 +0000 2019
>Last-Modified:  Thu Jul 11 17:40:44 +0000 2019
>Originator:     clement bouvier
>Release:        current
>Organization:
>Environment:
Macosx Mojave 10.14.5
>Description:
archivers/libcomprex failed to build under macosx because of undefined symbol in the module part of the project.

libtool: link: clang  -o .libs/libar.so -bundle  .libs/ar.o .libs/header.o .libs/utils.o   -L/Users/cbouvier/prj/pkgsrc/archivers/libcomprex/work/.buildlink/lib /Users/cbouvier/prj/pkgsrc/archivers/libcomprex/work/.buildlink/lib/libintl.dylib -lc -liconv  -O2  
Undefined symbols for architecture x86_64:
  "_cxClose", referenced from:
      _saveArchive in ar.o
  "_cxDestroyFsIterator", referenced from:
      _saveArchive in ar.o
  "_cxDirAddFile", referenced from:
      _readArchive in ar.o
  "_cxGetArchiveRoot", referenced from:
      _readArchive in ar.o
  "_cxGetFileArchive", referenced from:
      _openFile in ar.o
      ___readFunc in ar.o
  "_cxGetFileCompressedSize", referenced from:
      ___readFunc in ar.o
      ___seekFunc in ar.o
  "_cxGetFileDate", referenced from:
      _saveArchive in ar.o
  "_cxGetFileGid", referenced from:
      _saveArchive in ar.o
  "_cxGetFileMode", referenced from:
      _saveArchive in ar.o
  "_cxGetFileName", referenced from:
      _saveArchive in ar.o
  "_cxGetFilePhysicalPath", referenced from:
      _saveArchive in ar.o
  "_cxGetFileSize", referenced from:
      _readArchive in ar.o
      _saveArchive in ar.o
  "_cxGetFileUid", referenced from:
      _saveArchive in ar.o
  "_cxGetFsIterFirst", referenced from:
      _saveArchive in ar.o
  "_cxGetFsIterNext", referenced from:
      _saveArchive in ar.o
  "_cxGetFsNodeType", referenced from:
      _saveArchive in ar.o
  "_cxNewFile", referenced from:
      _readArchive in ar.o
  "_cxNewFp", referenced from:
      _openFile in ar.o
  "_cxNewFsIterator", referenced from:
      _saveArchive in ar.o
  "_cxOpenFile", referenced from:
      _saveArchive in ar.o
  "_cxRead", referenced from:
      _readArchive in ar.o
      _saveArchive in ar.o
      ___readFunc in ar.o
      _cxArValidateMagic in header.o
      _cxArReadHeader in header.o
  "_cxRegisterModule", referenced from:
      _initComprexModule in ar.o
  "_cxSeek", referenced from:
      _readArchive in ar.o
      _openFile in ar.o
      ___readFunc in ar.o
  "_cxSetArchiveType", referenced from:
      _readArchive in ar.o
  "_cxSetCloseFunc", referenced from:
      _openFile in ar.o
  "_cxSetFileCompressedSize", referenced from:
      _readArchive in ar.o
  "_cxSetFileDate", referenced from:
      _readArchive in ar.o
  "_cxSetFileGid", referenced from:
      _readArchive in ar.o
  "_cxSetFileMode", referenced from:
      _readArchive in ar.o
  "_cxSetFileName", referenced from:
      _readArchive in ar.o
  "_cxSetFileSize", referenced from:
      _readArchive in ar.o
  "_cxSetFileUid", referenced from:
      _readArchive in ar.o
  "_cxSetReadFunc", referenced from:
      _openFile in ar.o
  "_cxSetSeekFunc", referenced from:
      _openFile in ar.o
  "_cxSetWriteFunc", referenced from:
      _openFile in ar.o
  "_cxTell", referenced from:
      _readArchive in ar.o
      ___readFunc in ar.o
  "_cxWrite", referenced from:
      _saveArchive in ar.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

More details are available on the Joyent MacOS build
http://useast.manta.joyent.com/pkgsrc/public/reports/Darwin/trunk/x86_64/20190707.1543/libcomprex-0.3.3nb18/build.log
>How-To-Repeat:
build archivers/libcomprex
>Fix:
The project has plugin code to load into the library at runtime (The plugin part is under modules).

The linker need to know that some symbols in the plugin part (Theses symbols are in the core lib comprex ) will be resolved at runtime during the loading of the module.
The macOS linker uses -undefined dynamic_lookup flags.
The patch remplaces -no-undefined flags by the previous one.

It is pretty hard to test the functionnality; indeed the project is pretty old and the tests are not so useful(there is no news in the mailing list since 2003!). However I obtain the same behaviors as the same code under netbsd-8 with gcc with the tests.

I wonder if the project is till used...but anyway we can build it....

Index: Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/archivers/libcomprex/Makefile,v
retrieving revision 1.41
diff -u -r1.41 Makefile
--- Makefile	1 Jul 2019 04:07:44 -0000	1.41
+++ Makefile	9 Jul 2019 13:51:22 -0000
@@ -18,6 +18,20 @@
 CONFIGURE_ENV+=		ac_cv_lib_curl_curl_formparse=yes
 REPLACE_SH=		comprex-config.in

+.include "../../mk/bsd.prefs.mk"
+
+# macos linker need to know that undefined symbols are resolved 
+# at runtime during the loading of plugin code
+.if ${OPSYS} == "Darwin"
+SUBST_CLASSES+=         plugins
+SUBST_STAGE.plugins=     pre-configure
+SUBST_MESSAGE.plugins=   allow comprex symbols to be resolved at runtime  
+SUBST_FILES.plugins=     modules/archive/ar/Makefile.in modules/archive/bzip2/Makefile.in modules/archive/cab/Makefile.in \
+                         modules/archive/cpio/Makefile.in modules/archive/tar/Makefile.in modules/archive/zip/Makefile.in \
+                         modules/archive/zlib/Makefile.in modules/scheme/curl/Makefile.in
+SUBST_SED.plugins=       -e 's,-no-undefined,-undefined dynamic_lookup,g'
+.endif
+
 .include "../../archivers/bzip2/buildlink3.mk"
 .include "../../devel/gettext-lib/buildlink3.mk"
 .include "../../www/curl/buildlink3.mk"

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: pkg-manager->macos-pkg-people
Responsible-Changed-By: hauke@NetBSD.org
Responsible-Changed-When: Thu, 11 Jul 2019 17:40:44 +0000
Responsible-Changed-Why:
A MacOS X problem.


>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.