From patchwork Tue Mar 11 15:59:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Ellcey X-Patchwork-Id: 329144 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id F19542C00BD for ; Wed, 12 Mar 2014 02:59:18 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 57D9A32EB2; Tue, 11 Mar 2014 15:59:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UBUqdDoArWm7; Tue, 11 Mar 2014 15:59:14 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 9F146237AE; Tue, 11 Mar 2014 15:59:14 +0000 (UTC) X-Original-To: uclibc@lists.busybox.net Delivered-To: uclibc@osuosl.org Received: from fraxinus.osuosl.org (fraxinus.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 819B41C2438 for ; Tue, 11 Mar 2014 15:59:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 7EDCD88628 for ; Tue, 11 Mar 2014 15:59:12 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GvFSNJwF6K7N for ; Tue, 11 Mar 2014 15:59:10 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mailapp01.imgtec.com (mailapp01.imgtec.com [195.89.28.114]) by fraxinus.osuosl.org (Postfix) with ESMTP id 01A5D885BC for ; Tue, 11 Mar 2014 15:59:09 +0000 (UTC) Received: from KLMAIL01.kl.imgtec.org (unknown [192.168.5.35]) by Websense Email Security Gateway with ESMTPS id 2AE2F2E719E20 for ; Tue, 11 Mar 2014 15:59:05 +0000 (GMT) Received: from KLMAIL02.kl.imgtec.org (192.168.5.97) by KLMAIL01.kl.imgtec.org (192.168.5.35) with Microsoft SMTP Server (TLS) id 14.3.174.1; Tue, 11 Mar 2014 15:59:07 +0000 Received: from BAMAIL02.ba.imgtec.org (192.168.66.28) by klmail02.kl.imgtec.org (192.168.5.97) with Microsoft SMTP Server (TLS) id 14.3.174.1; Tue, 11 Mar 2014 15:59:07 +0000 Received: from ubuntu-sellcey.mips.com (192.168.65.53) by bamail02.ba.imgtec.org (192.168.66.28) with Microsoft SMTP Server id 14.3.174.1; Tue, 11 Mar 2014 08:59:04 -0700 Received: by ubuntu-sellcey.mips.com (sSMTP sendmail emulation); Tue, 11 Mar 2014 08:59:04 -0700 From: "Steve Ellcey " Date: Tue, 11 Mar 2014 08:59:03 -0700 To: Subject: RFC: Proposal for a patch that changes multilib linker scripts. User-Agent: Heirloom mailx 12.5 6/20/10 MIME-Version: 1.0 Message-ID: X-BeenThere: uclibc@uclibc.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Discussion and development of uClibc \(the embedded C library\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: uclibc-bounces@uclibc.org Sender: uclibc-bounces@uclibc.org I am building a GCC cross compiler tool chain with uclibc and noticed a difference between libc.so from glibc and from uclibc when building a multilib toolchain. As an example, on glibc, compiling for mips64r2, N64 ABI, little endian; I put libraries like libc.so in /mips64r2/64/el/usr/lib/libc.so and the contents of libc.so are: /* GNU ld script Use the shared library, but some functions are only in the static library, so try that secondarily. */ OUTPUT_FORMAT(elf64-tradlittlemips) GROUP ( /usr/lib/libc.so.6 /usr/lib/libc_nonshared.a AS_NEEDED ( /usr/lib/ld.so .1 ) ) But when I build with uclibc and put libc.so in the same location by setting the MULTILIB_DIR, its libc.so contents are: /* GNU ld script * Use the shared library, but some functions are only in * the static library, so try that secondarily. */ OUTPUT_FORMAT("elf64-tradlittlemips", "elf64-tradbigmips", "elf64-tradlittlemips") GROUP ( /mips64r2/64/el/usr/lib/libc.so.0 /mips64r2/64/el/usr/lib/uclibc_nonshar ed.a AS_NEEDED ( /mips64r2/64/el/usr/lib/ld64-uClibc.so.0 ) ) Then when I try to compile things with this multilib GCC I get errors like: /local/home/sellcey/gcc/uclibc_err/install-mips-mti-linux-uclibc/mips-mti-linux-uclibc/bin/ld: cannot find /mips64r2/64/el/usr/lib/uclibc_nonshared.a inside /local/home/sellcey/gcc/uclibc_err/install-mips-mti-linux-uclibc/sysroot/mips64r2/64/el /local/home/sellcey/gcc/uclibc_err/install-mips-mti-linux-uclibc/mips-mti-linux-uclibc/bin/ld: cannot find /mips64r2/64/el/usr/lib/ld-uClibc.so.0 inside /local/home/sellcey/gcc/uclibc_err/install-mips-mti-linux-uclibc/sysroot/mips64r2/64/el I believe this is because I am running GCC with sysroot option and that is adding the '/mips64r2/64/el' prefix on to paths, but then that path is also in the libc.so ld script. I would like to modify uclibc so I can make the ld script for uclibc look more like the glibc one and have come up with attached changes. If it looks OK, I will submit a proper patch but I thought I would get some feedback on this approach first and make sure it is considered a reasonable change to propose. My idea is to add a new variable (GROUP_DIR) that can be set to change the contents of libc.so. By default it would be set to MULTILIB_DIR so that anyone who does not set this variable is not affected. But if it is set then it is used to set the contents of libc.so while MULTILIB_DIR is still used when determining where to install the actual libraries. Steve Ellcey sellcey@mips.com Here is a diff of my current idea for a patch: diff --git a/Makefile.in b/Makefile.in index 5419704..ccd7729 100644 --- a/Makefile.in +++ b/Makefile.in @@ -361,6 +361,11 @@ install_startfiles: startfiles | $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR) -$(INSTALL) -m 644 $(startfiles) $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/ # Installs development library links. + +ifeq ($(GROUP_DIR),) +GROUP_DIR=$(MULTILIB_DIR) +endif + install_dev: install_headers install_runtime install_startfiles | $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR) -$(INSTALL) -m 644 $(top_builddir)lib/*.a $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/ ifeq ($(HAVE_SHARED),y) @@ -372,9 +377,9 @@ ifeq ($(HAVE_SHARED),y) ifeq ($(HARDWIRED_ABSPATH),y) if [ -f $(top_builddir)lib/libc.so -a -f $(PREFIX)$(RUNTIME_PREFIX)$(MULTILIB_DIR)/$(SHARED_LIBNAME) ] ; then \ $(RM) $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libc.so; \ - $(SED) -e 's:$(NONSHARED_LIBNAME):$(DEVEL_PREFIX)$(MULTILIB_DIR)/$(NONSHARED_LIBNAME):' \ - -e 's:$(SHARED_LIBNAME):$(RUNTIME_PREFIX)$(MULTILIB_DIR)/$(SHARED_LIBNAME):' \ - -e 's:$(UCLIBC_LDSO):$(RUNTIME_PREFIX)$(MULTILIB_DIR)/$(UCLIBC_LDSO):' \ + $(SED) -e 's:$(NONSHARED_LIBNAME):$(DEVEL_PREFIX)$(GROUP_DIR)/$(NONSHARED_LIBNAME):' \ + -e 's:$(SHARED_LIBNAME):$(RUNTIME_PREFIX)$(GROUP_DIR)/$(SHARED_LIBNAME):' \ + -e 's:$(UCLIBC_LDSO):$(RUNTIME_PREFIX)$(GROUP_DIR)/$(UCLIBC_LDSO):' \ $(top_builddir)lib/libc.so > $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libc.so; \ $(SED) -i -e 's://:/:g' $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libc.so; \ fi @@ -388,7 +393,7 @@ ifeq ($(HARDWIRED_ABSPATH),y) if [ -f $(top_builddir)lib/libpthread.so -a -f $(PREFIX)$(RUNTIME_PREFIX)$(MULTILIB_DIR)/libpthread.so.$(ABI_VERSION) ] ; then \ $(RM) $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libpthread.so; \ cp $(top_srcdir)extra/scripts/format.lds $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libpthread.so; \ - echo "GROUP ( $(RUNTIME_PREFIX)$(MULTILIB_DIR)/libpthread.so.$(ABI_VERSION) $(DEVEL_PREFIX)$(MULTILIB_DIR)/libpthread_nonshared.a )" \ + echo "GROUP ( $(RUNTIME_PREFIX)$(GROUP_DIR)/libpthread.so.$(ABI_VERSION) $(DEVEL_PREFIX)$(GROUP_DIR)/libpthread_nonshared.a )" \ >> $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libpthread.so; \ $(SED) -i -e 's://:/:g' $(PREFIX)$(DEVEL_PREFIX)$(MULTILIB_DIR)/libpthread.so; \ fi