From owner-freebsd-current@FreeBSD.ORG Thu Aug 22 06:18:23 2013 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 29750F4; Thu, 22 Aug 2013 06:18:23 +0000 (UTC) (envelope-from trond@fagskolen.gjovik.no) Received: from smtp.fagskolen.gjovik.no (smtp.fagskolen.gjovik.no [IPv6:2001:700:1100:1:200:ff:fe00:b]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id BE3CF20E5; Thu, 22 Aug 2013 06:18:22 +0000 (UTC) Received: from mail.fig.ol.no (localhost [127.0.0.1]) by mail.fig.ol.no (8.14.7/8.14.7) with ESMTP id r7M6IHTE016658 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 22 Aug 2013 08:18:17 +0200 (CEST) (envelope-from trond@fagskolen.gjovik.no) Received: from localhost (trond@localhost) by mail.fig.ol.no (8.14.7/8.14.7/Submit) with ESMTP id r7M6IHNc016655; Thu, 22 Aug 2013 08:18:17 +0200 (CEST) (envelope-from trond@fagskolen.gjovik.no) X-Authentication-Warning: mail.fig.ol.no: trond owned process doing -bs Date: Thu, 22 Aug 2013 08:18:17 +0200 (CEST) From: =?ISO-8859-1?Q?Trond_Endrest=F8l?= Sender: Trond.Endrestol@fagskolen.gjovik.no To: Dimitry Andric Subject: Re: Problems with iconv in base and static linking In-Reply-To: Message-ID: References: User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) Organization: Fagskolen Innlandet OpenPGP: url=http://fig.ol.no/~trond/trond.key MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="2055831798-1417330623-1377152297=:90799" X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=unavailable version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on mail.fig.ol.no Cc: Baptiste Daroussin , freebsd-current@freebsd.org, Bryan Drewery X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Aug 2013 06:18:23 -0000 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --2055831798-1417330623-1377152297=:90799 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT On Wed, 21 Aug 2013 21:49+0200, Dimitry Andric wrote: > Hi, > > While packaging my just-rebuilt ports today, I noticed a strange message > occurring during the package creation stage: > > $ sudo make -C /usr/ports/ports-mgmt/pkg repackage > ===> Building package for pkg-1.1.4_1 > Creating package for pkg-1.1.4_1 > Service unavailable I'd just like to voice my opinion over the mostly meaningless error message. It's an insult to us users, and us system administrators in particular. Please do better by providing error messages that adequately explains what went wrong. Now that's an idea for GSoC. ;-) > $ > > In fact, *every* make package/repackage produces the "Service > unavailable" message. The message is actually produced by the pkg(8) > command, which is run as follows: > > /usr/local/sbin/pkg-static create -o /usr/ports/packages pkg-1.1.4_1 > > Now comes the interesting part: if you use /usr/local/sbin/pkg instead, > the "Service unavailable" message does *not* appear. > > It turns out this is because pkg(8) uses libarchive, which is now > compiled with iconv support from base by default. But the iconv in base > does *not* work properly in statically linked executables. For example, > take this small program: > > #include > #include > > int main(void) > { > iconv_t ic = iconv_open("UTF-8", "ISO-8859-1"); > if (ic == (iconv_t)-1) > err(1, "iconv_open failed"); > iconv_close(ic); > return 0; > } > > If you compile and link this statically, it will produce: > > $ cc -static iconv-test.c -o iconv-test-static > $ ./iconv-test-static > iconv-test-static: iconv_open failed: Invalid argument > Service unavailable$ > > The reason for the message is that libc's iconv tries to dlopen(3) a > dynamic library in /usr/lib/i18n, which does not work in static > executables. > > As a quick fix for pkg(8), we could build the static version of > libarchive without -DHAVE_ICONV and friends. This also helps other > consumers of libarchive that link statically. > > Of course, there may be other consumers of libc's iconv that might want > to link statically, so it should really be fixed there instead. For > example, by not doing the dlopen, and failing gracefully. Or maybe by > actually linking in (a subset of) the /usr/lib/i18n libraries. > > -Dimitry -- +-------------------------------+------------------------------------+ | Vennlig hilsen, | Best regards, | | Trond Endrestøl, | Trond Endrestøl, | | IT-ansvarlig, | System administrator, | | Fagskolen Innlandet, | Gjøvik Technical College, Norway, | | tlf. mob. 952 62 567, | Cellular...: +47 952 62 567, | | sentralbord 61 14 54 00. | Switchboard: +47 61 14 54 00. | +-------------------------------+------------------------------------+ --2055831798-1417330623-1377152297=:90799--