This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[PATCH] Fix multilib build
- From: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
- To: newlib at sourceware dot org
- Cc: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
- Date: Thu, 8 Dec 2016 09:54:52 +0100
- Subject: [PATCH] Fix multilib build
- Authentication-results: sourceware.org; auth=none
This is an attempt to fix the problem described here:
https://sourceware.org/ml/newlib/2016/msg01139.html
https://gcc.gnu.org/ml/gcc/2016-12/msg00010.html
There is no change if libtool is used.
Some run-time support libraries provided by GCC (e.g. libgomp) use
configure checks to detect certain features, e.g. availability of
thread-local storage. The configure script generates a test program and
tries to compile and link it. It should use target libraries and
startfiles of the build tree if available and not random ones from the
installation prefix for this procedure. The search directories
specified by -B are a bit special, see for_each_path() in gcc.c of the
GCC sources. First a search is performed on all search paths with the
multilib directories appended (if desired), then a second search is
performed on demand with the base directory only. For each multilib
there is a "newlib" subdirectory. This directory is specified by a -B
option for the support libraries. In order to find the newlib artifacts
(ctr0.o, libc.a libg.a and libm.a) there must be additional multilib
subdirectories.
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
newlib/Makefile.am | 30 +++++++++++++++++++++++-------
newlib/Makefile.in | 32 ++++++++++++++++++++++++++------
newlib/configure | 33 +++++++++++++++++++++++++++++++--
newlib/configure.in | 25 +++++++++++++++++++++++++
4 files changed, 105 insertions(+), 15 deletions(-)
diff --git a/newlib/Makefile.am b/newlib/Makefile.am
index 20ab163..88845e7 100644
--- a/newlib/Makefile.am
+++ b/newlib/Makefile.am
@@ -77,16 +77,17 @@ toollibdir = $(tooldir)/lib$(MULTISUBDIR)
AR_FLAGS = rc
+noinst_DATA = stmp-targ-include
+
if USE_LIBTOOL
toollib_LTLIBRARIES = libm.la \
libc.la
else
toollib_LIBRARIES = libm.a \
libc.a
+noinst_DATA += $(MULTISUBDIR_CRT0) $(MULTISUBDIR_LIBC) $(MULTISUBDIR_LIBM)
endif
-noinst_DATA = stmp-targ-include
-
toollib_DATA = $(CRT0) $(CRT1)
@@ -171,23 +172,38 @@ libc/libc.a: ; @true
libm.a: libm/libm.a
rm -f $@
- ln libm/libm.a $@ >/dev/null 2>/dev/null || cp libm/libm.a $@
+ ln $< $@ >/dev/null 2>/dev/null || cp $< $@
libm/libm.a: ; @true
endif # USE_LIBTOOL
+$(with_multisubdir):
+ $(MKDIR_P) $@
+
+$(with_multisubdir)/crt0.o: $(CRT0_DIR)$(CRT0) $(with_multisubdir)
+ rm -f $@
+ ln $< $@ >/dev/null 2>/dev/null || cp $< $@
+
+$(with_multisubdir)/libc.a: libc.a $(with_multisubdir)
+ rm -f $@ $(with_multisubdir)/libg.a
+ ln $< $@ >/dev/null 2>/dev/null || cp $< $@
+ ln libg.a $(with_multisubdir)/libg.a >/dev/null 2>/dev/null || \
+ cp libg.a $(with_multisubdir)/libg.a
+
+$(with_multisubdir)/libm.a: libm.a $(with_multisubdir)
+ rm -f $@
+ ln $< $@ >/dev/null 2>/dev/null || cp $< $@
+
crt0.o: $(CRT0_DIR)$(CRT0)
rm -f $@
- ln $(CRT0_DIR)$(CRT0) $@ >/dev/null 2>/dev/null \
- || cp $(CRT0_DIR)$(CRT0) $@
+ ln $< $@ >/dev/null 2>/dev/null || cp $< $@
$(CRT0_DIR)$(CRT0): ; @true
crt1.o: $(CRT1_DIR)$(CRT1)
rm -f $@
- ln $< $@ >/dev/null 2>/dev/null \
- || cp $< $@
+ ln $< $@ >/dev/null 2>/dev/null || cp $< $@
$(CRT1_DIR)$(CRT1): ; @true
diff --git a/newlib/Makefile.in b/newlib/Makefile.in
index f0296b6..651b7c4 100644
--- a/newlib/Makefile.in
+++ b/newlib/Makefile.in
@@ -53,6 +53,7 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
+@USE_LIBTOOL_FALSE@am__append_1 = $(MULTISUBDIR_CRT0) $(MULTISUBDIR_LIBC) $(MULTISUBDIR_LIBM)
subdir = .
DIST_COMMON = NEWS README ChangeLog $(srcdir)/Makefile.in \
$(srcdir)/Makefile.am $(top_srcdir)/configure \
@@ -223,6 +224,9 @@ MACHINE_OBJECTLIST = @MACHINE_OBJECTLIST@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
+MULTISUBDIR_CRT0 = @MULTISUBDIR_CRT0@
+MULTISUBDIR_LIBC = @MULTISUBDIR_LIBC@
+MULTISUBDIR_LIBM = @MULTISUBDIR_LIBM@
NEWLIB_CFLAGS = @NEWLIB_CFLAGS@
NM = @NM@
NMEDIT = @NMEDIT@
@@ -314,6 +318,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
+with_multisubdir = @with_multisubdir@
AUTOMAKE_OPTIONS = cygnus dejagnu
ACLOCAL_AMFLAGS = -I . -I ..
@@ -380,13 +385,13 @@ SUBDIRS = libc libm \
tooldir = $(exec_prefix)/$(host_alias)
toollibdir = $(tooldir)/lib$(MULTISUBDIR)
AR_FLAGS = rc
+noinst_DATA = stmp-targ-include $(am__append_1)
@USE_LIBTOOL_TRUE@toollib_LTLIBRARIES = libm.la \
@USE_LIBTOOL_TRUE@ libc.la
@USE_LIBTOOL_FALSE@toollib_LIBRARIES = libm.a \
@USE_LIBTOOL_FALSE@ libc.a
-noinst_DATA = stmp-targ-include
toollib_DATA = $(CRT0) $(CRT1)
# The functions ldexp, frexp and modf are traditionally supplied in
@@ -930,21 +935,36 @@ uninstall-am: uninstall-toollibDATA uninstall-toollibLIBRARIES \
@USE_LIBTOOL_FALSE@libm.a: libm/libm.a
@USE_LIBTOOL_FALSE@ rm -f $@
-@USE_LIBTOOL_FALSE@ ln libm/libm.a $@ >/dev/null 2>/dev/null || cp libm/libm.a $@
+@USE_LIBTOOL_FALSE@ ln $< $@ >/dev/null 2>/dev/null || cp $< $@
@USE_LIBTOOL_FALSE@libm/libm.a: ; @true
+$(with_multisubdir):
+ $(MKDIR_P) $@
+
+$(with_multisubdir)/crt0.o: $(CRT0_DIR)$(CRT0) $(with_multisubdir)
+ rm -f $@
+ ln $< $@ >/dev/null 2>/dev/null || cp $< $@
+
+$(with_multisubdir)/libc.a: libc.a $(with_multisubdir)
+ rm -f $@ $(with_multisubdir)/libg.a
+ ln $< $@ >/dev/null 2>/dev/null || cp $< $@
+ ln libg.a $(with_multisubdir)/libg.a >/dev/null 2>/dev/null || \
+ cp libg.a $(with_multisubdir)/libg.a
+
+$(with_multisubdir)/libm.a: libm.a $(with_multisubdir)
+ rm -f $@
+ ln $< $@ >/dev/null 2>/dev/null || cp $< $@
+
crt0.o: $(CRT0_DIR)$(CRT0)
rm -f $@
- ln $(CRT0_DIR)$(CRT0) $@ >/dev/null 2>/dev/null \
- || cp $(CRT0_DIR)$(CRT0) $@
+ ln $< $@ >/dev/null 2>/dev/null || cp $< $@
$(CRT0_DIR)$(CRT0): ; @true
crt1.o: $(CRT1_DIR)$(CRT1)
rm -f $@
- ln $< $@ >/dev/null 2>/dev/null \
- || cp $< $@
+ ln $< $@ >/dev/null 2>/dev/null || cp $< $@
$(CRT1_DIR)$(CRT1): ; @true
diff --git a/newlib/configure b/newlib/configure
index 30e1d57..053f165 100755
--- a/newlib/configure
+++ b/newlib/configure
@@ -633,6 +633,10 @@ CRT1
CRT0_DIR
CRT0
EXTRA_DIRS
+MULTISUBDIR_LIBM
+MULTISUBDIR_LIBC
+MULTISUBDIR_CRT0
+with_multisubdir
HAVE_DOC_FALSE
HAVE_DOC_TRUE
subdirs
@@ -11776,7 +11780,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11779 "configure"
+#line 11783 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11882,7 +11886,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 11885 "configure"
+#line 11889 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12156,12 +12160,33 @@ subdirs="$subdirs libc"
subdirs="$subdirs libm"
+# Some run-time support libraries provided by GCC (e.g. libgomp) use configure
+# checks to detect certain features, e.g. availability of thread-local
+# storage. The configure script generates a test program and tries to compile
+# and link it. It should use target libraries and startfiles of the build
+# tree if available and not random ones from the installation prefix for this
+# procedure. The search directories specified by -B are a bit special, see
+# for_each_path() in gcc.c of the GCC sources. First a search is performed on
+# all search paths with the multilib directory appended (if desired), then a
+# second search is performed on demand with the base directory only. For each
+# multilib there is a "newlib" subdirectory. This directory is specified by
+# a -B option for the support libraries. In order to find the newlib
+# artifacts (ctr0.o, libc.a, libg.a and libm.a) there must be additional
+# multilib subdirectories.
+MULTISUBDIR_CRT0=
+MULTISUBDIR_LIBC=
+MULTISUBDIR_LIBM=
if test -z "${with_multisubdir}"; then
subdirs="$subdirs doc"
have_doc=yes
else
have_doc=
+ MULTISUBDIR_LIBC=${with_multisubdir}/libc.a
+ MULTISUBDIR_LIBM=${with_multisubdir}/libm.a
+ if test "x${have_crt0}" = "xyes"; then
+ MULTISUBDIR_CRT0=${with_multisubdir}/crt0.o
+ fi
fi
if test x$have_doc = xyes; then
HAVE_DOC_TRUE=
@@ -12172,6 +12197,10 @@ else
fi
+
+
+
+
EXTRA_DIRS=
case $host in
i[34567]86-pc-linux-*)
diff --git a/newlib/configure.in b/newlib/configure.in
index 01c6367..f448e09 100644
--- a/newlib/configure.in
+++ b/newlib/configure.in
@@ -260,13 +260,38 @@ AC_SUBST(CC_FOR_NEWLIB)
AC_CONFIG_SUBDIRS(libc)
AC_CONFIG_SUBDIRS(libm)
+# Some run-time support libraries provided by GCC (e.g. libgomp) use configure
+# checks to detect certain features, e.g. availability of thread-local
+# storage. The configure script generates a test program and tries to compile
+# and link it. It should use target libraries and startfiles of the build
+# tree if available and not random ones from the installation prefix for this
+# procedure. The search directories specified by -B are a bit special, see
+# for_each_path() in gcc.c of the GCC sources. First a search is performed on
+# all search paths with the multilib directory appended (if desired), then a
+# second search is performed on demand with the base directory only. For each
+# multilib there is a "newlib" subdirectory. This directory is specified by
+# a -B option for the support libraries. In order to find the newlib
+# artifacts (ctr0.o, libc.a, libg.a and libm.a) there must be additional
+# multilib subdirectories.
+MULTISUBDIR_CRT0=
+MULTISUBDIR_LIBC=
+MULTISUBDIR_LIBM=
if test -z "${with_multisubdir}"; then
AC_CONFIG_SUBDIRS(doc)
have_doc=yes
else
have_doc=
+ MULTISUBDIR_LIBC=${with_multisubdir}/libc.a
+ MULTISUBDIR_LIBM=${with_multisubdir}/libm.a
+ if test "x${have_crt0}" = "xyes"; then
+ MULTISUBDIR_CRT0=${with_multisubdir}/crt0.o
+ fi
fi
AM_CONDITIONAL(HAVE_DOC, test x$have_doc = xyes)
+AC_SUBST(with_multisubdir)
+AC_SUBST(MULTISUBDIR_CRT0)
+AC_SUBST(MULTISUBDIR_LIBC)
+AC_SUBST(MULTISUBDIR_LIBM)
EXTRA_DIRS=
case $host in
--
1.8.4.5