RFC: Proposal for a patch that changes multilib linker scripts.
Bernhard Reutner-Fischer
rep.dot.nop at gmail.com
Tue Apr 8 14:07:35 UTC 2014
On Tue, Mar 11, 2014 at 08:59:03AM -0700, Steve Ellcey wrote:
>
> 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
> <root>/mips64r2/64/el/usr/lib/libc.so and the contents of libc.so are:
so you install the final target libc by issuing:
make realclean > /dev/null
TARCH=mips
sed -i -e '/^MULTILIB_DIR=/s/\(MULTILIB_DIR=\).*/\1"lib"/' \
-e 's/^TARGET_\([^=]*\)=y/# TARGET_\1 is not set/' \
-e "s/# \(TARGET_${TARCH}\) is not set/\1=y/" \
-e "s/^\(TARGET_ARCH\)=\"[^\"]*\"/\1=\"${TARCH}\"/"\
.config
make silentoldconfig
make realclean > /dev/null
d="/opt/${TARCH}-mine-linux-uclibc/tc-sysroot"
export PATH="$d/usr/bin:$d/bin:$PATH"
make ${MAKEFLAGS} \
V=2 \
CROSS_COMPILE=${TARCH}-mine-linux-uclibc- \
AR=${TARCH}-mine-linux-uclibc-gcc-ar \
NM=${TARCH}-mine-linux-uclibc-gcc-nm \
RANLIB=${TARCH}-mine-linux-uclibc-gcc-ranlib \
MULTILIB_DIR="lib" \
PREFIX="/opt/${TARCH}-mine-linux-uclibc/" \
RUNTIME_PREFIX="/" \
DEVEL_PREFIX="/usr/" \
AWK=/opt/${TARCH}-mine-linux-uclibc/tc-sysroot/usr/bin/awk \
SED=/opt/${TARCH}-mine-linux-uclibc/tc-sysroot/bin/sed \
all install install_utils || exit 1
except your PREFIX is more like "<root>/mips64r2/64/el/"
i suppose?
i.e. your PREFIX is not correct WRT your --with-build-sysroot and/or
--with-sysroot=
MULTILIB_DIR is supposed to be used for mulitilib setups (in the gcc
sense) but since it was apparent back than that we (gcc) 'd also need
something like multi-arch support we (uClibc) did not implement looping
make over multilib- or multiarch- configs internally in the buildsys but
(currently) rely on the user to configure, build and install all the
multilib/multiarch variants she wants on their own.
Our install-path setup follows what debian needs, see defaults in
extra/Configs/Config.in for RUNTIME_PREFIX, DEVEL_PREFIX, MULTILIB_DIR.
I hope that clarifies the purpose of the MULTILIB_DIR.
Does that answer your question?
thanks,
>
>
> /* 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 at 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
> _______________________________________________
> uClibc mailing list
> uClibc at uclibc.org
> http://lists.busybox.net/mailman/listinfo/uclibc
More information about the uClibc
mailing list