This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[patch] Fix in-src-tree builds by gdbserver/gnulib/ copy [Re: [PATCH] Link gnulib in gdbserver.]
On Sat, 14 Apr 2012 05:39:52 +0200, Yao Qi wrote:
> On 04/14/2012 05:25 AM, Jan Kratochvil wrote:
This broke in-src-tree build:
[...]
> > gcc: error: gnulib/libgnu.a: No such file or directory
> > make[4]: *** [gdbserver] Error 1
> > make[4]: Leaving directory `/home/jkratoch/redhat/gdb-clean/gdb/gdbserver'
>
> It is wired. I don't see such failure in in-source-tree (CVS trunk) build.
I do, on {x86_64,i686}-fedora{15,16,17,rawhide}-linux-gnu, not sure why it is
not reproducible for you - I also see it logical why it fails - using VPATH
make finds gnulib/libgnu.a in the gnulib source directory (gdb/gnulib/) and
therefore it does not rebuild libgnu.a in gdbserver/gnulib/ .
I also tried to force some phony dependency for libgnu.a in gdbserver/gnulib/
to force its rebuild there but it had other disadvantages. Also one could not
do make -C gdb/gdbserver/gnulib as the command-line variables overrides would
not apply, as was stated here.
* Using libgnu.a from gdb/gnulib/ for gdbserver is not good as they may have
different compilation options, also gdb/ may not be compilable for that host
etc.
* Copyting gdb/gnulib/ into gdbserver/gnulib/ in the CVS repository itself
would be possible but it would be just too much work to maintain etc.
AFAIK the GNU tools do not provide good enough support for the exact problem
here, therefore for building in-source-tree and having another build directory
of the source directory already containing pre-build binaries.
Therefore proposing to:
* Have single copy gdb/gnulib/ in CVS repository.
* Have two copies in the .tar distribution, it does not cost much:
225280 uncompressed
40970 gzip
32676 xz
* For direct build from repository in-source-tree do a clean binaries-less
copy from gdb/gnulib/ into gdbserver/gnulib/ .
* For direct build from repository out-of-source-tree do a clean binaries-less
copy from srcdir-gdb/gnulib/ into objdir-gdbserver/gnulib/ patching there
@*srcdir*@ variables so that it does not try
to access srcdir-gdbserver/gnulib/ which does not exist and where we must
not write anything.
Tested the combinations by the script below. As the gnulib/*.h files are not
yet in use in gdbserver/ it may not be well tested but I hope
GNULIB_INCLUDE_CFLAGS is right there.
OK to check it in?
Thanks,
Jan
------------------------------------------------------------------------------
set -ex
make -j1 -f src-release gdb.tar
cd ..
rm -rf gdb-test-rel?*
mkdir gdb-test-rel-treeout
cd gdb-test-rel-treeout
tar xf ../gdb-test-rel/gdb-7.4.50.20120414-cvs.tar;mv gdb-7.4.50.20120414-cvs/* .;rmdir gdb-7.4.50.20120414-cvs/
cd ..
mkdir gdb-test-rel-treein
cd gdb-test-rel-treein
tar xf ../gdb-test-rel/gdb-7.4.50.20120414-cvs.tar;mv gdb-7.4.50.20120414-cvs/* .;rmdir gdb-7.4.50.20120414-cvs/
cd ..
cd gdb-test-rel
git clean -dfx
git status
cd ..
cp -a gdb-test-rel gdb-test-rel-out
mkdir gdb-test-rel-out-build
cd gdb-test-rel-out-build
CFLAGS=-s ../gdb-test-rel-out/configure;make -j1 2>&1|tee log
cd ..
cp -a gdb-test-rel gdb-test-rel-in
cd gdb-test-rel-in
CFLAGS=-s ./configure;make -j1 2>&1|tee log
cd ..
mkdir gdb-test-rel-treeout-build
cd gdb-test-rel-treeout-build
CFLAGS=-s ../gdb-test-rel-treeout/configure;make -j1 2>&1|tee log
cd ..
cd gdb-test-rel-treein/
CFLAGS=-s ./configure;make -j1 2>&1|tee log
cd ..
echo OK
------------------------------------------------------------------------------
gdb/
2012-04-15 Jan Kratochvil <jan.kratochvil@redhat.com>
Fix builds in source tree.
* Makefile.in (diststuff): Recurse also into gdbserver.
gdb/gdbserver/
2012-04-15 Jan Kratochvil <jan.kratochvil@redhat.com>
Fix builds in source tree.
* Makefile.in (top_srcdir): New.
(GNULIB_INCLUDE_DIR): Change to ...
(GNULIB_INCLUDE_CFLAGS): ... here, include also local gnulib.
(GNULIB_FLAGS_TO_PASS): Remove.
(DISTSTUFF): New.
(all, install-only, uninstall, clean-info with others, all-lib, clean)
(distclean with others): Remove $(GNULIB_FLAGS_TO_PASS).
(diststuff, gnulib, gnulib-copy): New.
* configure: Regenerate.
* configure.ac: Test for gnulib/Makefile.in and create $GNULIB_SRC.
Call AC_CHECK_TOOL for AR.
(AC_OUTPUT) <gnulib/Makefile>: Use $GNULIB_SRC.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index b8b7109..5fb8418 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -1249,6 +1249,7 @@ do-maintainer-clean:
diststuff: $(DISTSTUFF) $(PACKAGE).pot $(CATALOGS)
cd doc; $(MAKE) $(MFLAGS) diststuff
+ cd gdbserver; $(MAKE) $(MFLAGS) diststuff
subdir_do: force
@for i in $(DODIRS); do \
diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index 6225e65..33219da 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -54,6 +54,7 @@ CC = @CC@
# Directory containing source files. Don't clean up the spacing,
# this exact string is matched for by the "configure" script.
srcdir = @srcdir@
+top_srcdir = @top_srcdir@
abs_top_srcdir=@abs_top_srcdir@
abs_srcdir=@abs_srcdir@
VPATH = @srcdir@
@@ -75,18 +76,10 @@ INCLUDE_DEP = $$(INCLUDE_DIR)
ustlibs = @ustlibs@
ustinc = @ustinc@
-# gnulib
-GNULIB_INCLUDE_DIR = $(srcdir)/../gnulib
+# gnulib; see gnulib-copy as it may be placed both in srcdir or objdir.
+GNULIB_INCLUDE_CFLAGS = -Ignulib -I$(srcdir)/../gnulib
GNULIB_LIB = gnulib/libgnu.a
-# We build gnulib directly under the gdbserver build directory, but
-# its sources don't live directly under gdbserver's source directory.
-# Tweak $srcdir and VPATH to make that work.
-GNULIB_FLAGS_TO_PASS = \
- "top_srcdir=$(abs_top_srcdir)/.." \
- "srcdir=$(abs_srcdir)/../gnulib" \
- "VPATH=$(abs_top_srcdir)/../gnulib:$(abs_top_srcdir)"
-
# Generated headers in the gnulib directory. These must be listed
# so that they are generated before other files are compiled.
GNULIB_H = gnulib/string.h @GNULIB_STDINT_H@
@@ -97,7 +90,7 @@ GNULIB_H = gnulib/string.h @GNULIB_STDINT_H@
# -I$(srcdir)/../regformats for regdef.h.
INCLUDE_CFLAGS = -I. -I${srcdir} -I$(srcdir)/../common \
-I$(srcdir)/../regformats -I$(INCLUDE_DIR) \
- -I$(GNULIB_INCLUDE_DIR)
+ $(GNULIB_INCLUDE_CFLAGS)
# M{H,T}_CFLAGS, if defined, has host- and target-dependent CFLAGS
# from the config/ directory.
@@ -122,6 +115,9 @@ INTERNAL_CFLAGS = ${INTERNAL_WARN_CFLAGS} $(WERROR_CFLAGS)
LDFLAGS = @LDFLAGS@
INTERNAL_LDFLAGS = $(LDFLAGS) @RDYNAMIC@
+# Things which need to be built when making a distribution.
+DISTSTUFF = gnulib
+
# All source files that go into linking GDB remote server.
SFILES= $(srcdir)/gdbreplay.c $(srcdir)/inferiors.c $(srcdir)/dll.c \
@@ -212,7 +208,7 @@ FLAGS_TO_PASS = \
${CC} -c ${INTERNAL_CFLAGS} $<
all: gdbserver$(EXEEXT) gdbreplay$(EXEEXT) $(extra_libraries)
- @cd gnulib; $(MAKE) $(FLAGS_TO_PASS) $(GNULIB_FLAGS_TO_PASS) all
+ @cd gnulib; $(MAKE) $(FLAGS_TO_PASS) all
# Traditionally "install" depends on "all". But it may be useful
# not to; for example, if the user has made some trivial change to a
@@ -233,13 +229,13 @@ install-only:
$(INSTALL_PROGRAM) gdbserver$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT); \
$(SHELL) $(srcdir)/../../mkinstalldirs $(DESTDIR)$(man1dir); \
$(INSTALL_DATA) $(srcdir)/gdbserver.1 $(DESTDIR)$(man1dir)/$$n.1
- @cd gnulib; $(MAKE) $(FLAGS_TO_PASS) $(GNULIB_FLAGS_TO_PASS) install
+ @cd gnulib; $(MAKE) $(FLAGS_TO_PASS) install
uninstall: force
n=`echo gdbserver | sed '$(program_transform_name)'`; \
if [ x$$n = x ]; then n=gdbserver; else true; fi; \
rm -f $(DESTDIR)/$(bindir)/$$n$(EXEEXT) $(DESTDIR)$(man1dir)/$$n.1
- @cd gnulib; $(MAKE) $(FLAGS_TO_PASS) $(GNULIB_FLAGS_TO_PASS) uninstall
+ @cd gnulib; $(MAKE) $(FLAGS_TO_PASS) uninstall
installcheck:
check:
@@ -249,7 +245,7 @@ install-pdf:
html:
install-html:
clean-info: force
- @cd gnulib; $(MAKE) $(FLAGS_TO_PASS) $(GNULIB_FLAGS_TO_PASS) $@
+ @cd gnulib; $(MAKE) $(FLAGS_TO_PASS) $@
gdbserver$(EXEEXT): $(OBS) ${ADD_DEPS} ${CDEPS} $(GNULIB_LIB)
rm -f gdbserver$(EXEEXT)
@@ -258,7 +254,7 @@ gdbserver$(EXEEXT): $(OBS) ${ADD_DEPS} ${CDEPS} $(GNULIB_LIB)
$(GNULIB_LIB) $(GNULIB_H): all-lib
all-lib: gnulib/Makefile
- @cd gnulib; $(MAKE) $(FLAGS_TO_PASS) $(GNULIB_FLAGS_TO_PASS) all
+ @cd gnulib; $(MAKE) $(FLAGS_TO_PASS) all
.PHONY: all-lib
@@ -316,13 +312,39 @@ clean:
rm -f i386-mmx.c i386-mmx-linux.c
rm -f x32.c x32-linux.c
rm -f x32-avx.c x32-avx-linux.c
- @cd gnulib; $(MAKE) $(FLAGS_TO_PASS) $(GNULIB_FLAGS_TO_PASS) clean
+ @cd gnulib; $(MAKE) $(FLAGS_TO_PASS) clean
maintainer-clean realclean distclean: clean
rm -f nm.h tm.h xm.h config.h stamp-h config.log
- @cd gnulib; $(MAKE) $(FLAGS_TO_PASS) $(GNULIB_FLAGS_TO_PASS) $@
+ @cd gnulib; $(MAKE) $(FLAGS_TO_PASS) $@
rm -f Makefile config.status
+diststuff: $(DISTSTUFF)
+
+# gnulib is normally included in distributed tar. If we build from repository
+# and outside of the source tree put the gdbserver/gnulib copy into objdir.
+
+.PHONY: gnulib
+gnulib:
+ rm -rf gnulib.new
+ $(MAKE) -C ../gnulib distdir=../gdbserver/gnulib.new distdir
+ for src in `find gnulib.new -type d` ; do \
+ dst=`echo $$src | sed 's/gnulib\.new/gnulib/'`; \
+ mkdir -p $$dst; \
+ done
+ for src in `find gnulib.new -type f` ; do \
+ dst=`echo $$src | sed 's/gnulib\.new/gnulib/'`; \
+ rm -f $$dst; \
+ cp $$src $$dst; \
+ done
+ sed -e "s&\(@\)srcdir@&.&" \
+ -e "s&\(@\)top_srcdir@&..&" \
+ -e "s&\(@\)abs_srcdir@&$$PWD/gnulib&" \
+ -e "s&\(@\)abs_top_srcdir@&$$PWD&" \
+ < gnulib.new/Makefile.in > gnulib/Makefile.in
+ rm -rf gnulib.new
+ $(SHELL) ./config.status gnulib/Makefile
+
config.h: stamp-h ; @true
stamp-h: config.in config.status
CONFIG_FILES="" CONFIG_HEADERS=config.h:config.in $(SHELL) ./config.status
diff --git a/gdb/gdbserver/configure b/gdb/gdbserver/configure
index 2ff44ce..eca6532 100755
--- a/gdb/gdbserver/configure
+++ b/gdb/gdbserver/configure
@@ -597,6 +597,7 @@ gltests_LIBOBJS
gl_LTLIBOBJS
gl_LIBOBJS
LTLIBOBJS
+AR
GNULIB_STDINT_H
am__fastdepCC_FALSE
am__fastdepCC_TRUE
@@ -9981,7 +9982,109 @@ if test x"$STDINT_H" != x; then
fi
-ac_config_files="$ac_config_files Makefile gnulib/Makefile:${srcdir}/../gnulib/Makefile.in"
+# gnulib is normally included in distributed tar. If we build from repository
+# and outside of the source tree put the gdbserver/gnulib copy into objdir.
+if ! test -e ${srcdir}/gnulib/Makefile.in ; then
+ GNULIB_SRC=:${srcdir}/../gnulib/Makefile.in
+ ac_config_commands="$ac_config_commands gnulib"
+
+else
+ GNULIB_SRC=
+fi
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_AR+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$AR"; then
+ ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_AR="${ac_tool_prefix}ar"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AR"; then
+ ac_ct_AR=$AR
+ # Extract the first word of "ar", so it can be a program name with args.
+set dummy ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_AR+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_AR"; then
+ ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_prog_ac_ct_AR="ar"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_AR" = x; then
+ AR=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ AR=$ac_ct_AR
+ fi
+else
+ AR="$ac_cv_prog_AR"
+fi
+
+
+ac_config_files="$ac_config_files Makefile gnulib/Makefile$GNULIB_SRC"
ac_config_commands="$ac_config_commands default"
@@ -10733,8 +10836,9 @@ do
case $ac_config_target in
"config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;;
"depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+ "gnulib") CONFIG_COMMANDS="$CONFIG_COMMANDS gnulib" ;;
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
- "gnulib/Makefile") CONFIG_FILES="$CONFIG_FILES gnulib/Makefile:${srcdir}/../gnulib/Makefile.in" ;;
+ "gnulib/Makefile$GNULIB_SRC") CONFIG_FILES="$CONFIG_FILES gnulib/Makefile$GNULIB_SRC" ;;
"default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;;
*) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -11415,6 +11519,7 @@ $as_echo X"$file" |
done
}
;;
+ "gnulib":C) make gnulib ;;
"default":C) case x$CONFIG_HEADERS in
xconfig.h:config.in)
echo > stamp-h ;;
diff --git a/gdb/gdbserver/configure.ac b/gdb/gdbserver/configure.ac
index ac8223a..33e82a5 100644
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -450,7 +450,17 @@ if test x"$STDINT_H" != x; then
fi
AC_SUBST(GNULIB_STDINT_H)
-AC_OUTPUT(Makefile gnulib/Makefile:${srcdir}/../gnulib/Makefile.in,
+# gnulib is normally included in distributed tar. If we build from repository
+# and outside of the source tree put the gdbserver/gnulib copy into objdir.
+if ! test -e ${srcdir}/gnulib/Makefile.in ; then
+ GNULIB_SRC=:${srcdir}/../gnulib/Makefile.in
+ AC_CONFIG_COMMANDS([gnulib], [make gnulib])
+else
+ GNULIB_SRC=
+fi
+AC_CHECK_TOOL(AR, ar)
+
+AC_OUTPUT(Makefile gnulib/Makefile$GNULIB_SRC,
[case x$CONFIG_HEADERS in
xconfig.h:config.in)
echo > stamp-h ;;