This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] Fix race condition in libstdc++-v3/configure.ac


Two build issues that happen most likely with --enable-maintainer-mode,
but can also happen without, if you re-build after 'svn up' (if that
update changed Makefile.in files in any of the multilib directories).

1) It is possible that several config.status instances run concurrently
in one directory: that can happen if plain
  automake

was issued or triggered due to, say, configure.ac being new; then all
build tree Makefile files are out of date wrt. their Makefile.in files
(as opposed to: wrt. config.status, in which case one invocation of
the script will update all Makefile.in instances).

In this case, the scriptlet passed to AC_CONFIG_COMMANDS at the end of
libstdc++-v3/configure.ac to append the 'MULTISUBDIR' setting uses the
same temporary file from each config.status script instance.

2) Even if only one Makefile is regenerated, say, due to a
  ./config.status include/Makefile

(which is what automake puts into the regeneration rule), the commands
associated with the 'default' tag are not invoked, thus the MULTISUBDIR
setting isn't appended at all.

This can lead to interesting errors.  For example, I was seeing that
instead of installing to both
  $prefix/include/c++/4.5.0/${host_alias}/bits/c++config.h
  $prefix/include/c++/4.5.0/${host_alias}/32/bits/c++config.h

the latter was installed to the place of the former.

This issue is similar to
<http://thread.gmane.org/gmane.comp.gcc.devel/108469>
but here we don't need to cater to all AM_ENABLE_MULTILIB users.

So, we can either fix this by adding the commands associated with the
'default' tag to each Makefile creation, or, as a hack, override
Automake's internal am__depfiles_maybe variable.  I'd prefer the former,
even if it adds some duplication in configure.

I wasn't quite sure whether the 'cd include && make' is necessary each
time include/Makefile is changed, or only when config.status is invoked
without arguments (i.e., after configure runs).  The patch assumes the
latter and introduces a 'generate-headers' tag for this.

Tested by trying out some build situations.  OK?

Thanks,
Ralf

v3: fix config.status instantiation of subdir makefiles.

libstdc++-v3/ChangeLog:
2009-08-30  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>

	* configure.ac: Replace AC_CONFIG_COMMANDS([default])
	instantiation with additional commands issued for each Makefile
	in glibcxx_SUBDIRS, so `./config.status subdir/Makefile' also
	runs these commands.
	Add a separate AC_CONFIG_COMMANDS([generate-headers]) for
	running `make' in include.
	* configure: Regenerate.

diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index bc05d2d..eb7b5da 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -388,45 +388,29 @@ AC_SUBST(LIBSUPCXX_PICFLAGS)
 dnl In autoconf 2.5x, AC_OUTPUT is replaced by four AC_CONFIG_* macros,
 dnl which can all be called multiple times as needed, plus one (different)
 dnl AC_OUTPUT macro.  This one lists the files to be created:
-AC_CONFIG_FILES( \
-  Makefile \
-  AC_FOREACH([DIR], glibcxx_SUBDIRS, [DIR/Makefile ])
-  )
+AC_CONFIG_FILES(Makefile)
 AC_CONFIG_FILES([scripts/testsuite_flags],[chmod +x scripts/testsuite_flags])
 
-dnl These commands are run at the end of config.status:
-AC_CONFIG_COMMANDS([default],
-[if test -n "$CONFIG_FILES"; then
-   # Multilibs need MULTISUBDIR defined correctly in certain makefiles so
-   # that multilib installs will end up installed in the correct place.
-   # The testsuite needs it for multilib-aware ABI baseline files.
-   # To work around this not being passed down from config-ml.in ->
-   # srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually
-   # append it here.  Only modify Makefiles that have just been created.
-   #
-   # Also, get rid of this simulated-VPATH thing that automake does.
-   cat > vpsed << \_EOF
+# Multilibs need MULTISUBDIR defined correctly in certain makefiles so
+# that multilib installs will end up installed in the correct place.
+# The testsuite needs it for multilib-aware ABI baseline files.
+# To work around this not being passed down from config-ml.in ->
+# srcdir/Makefile.am -> srcdir/{src,libsupc++,...}/Makefile.am, manually
+# append it here.  Only modify Makefiles that have just been created.
+#
+# Also, get rid of this simulated-VPATH thing that automake does.
+AC_CONFIG_FILES(AC_FOREACH([DIR], glibcxx_SUBDIRS, [DIR/Makefile ]),
+  [cat > vpsed$$ << \_EOF
 s!`test -f '$<' || echo '$(srcdir)/'`!!
 _EOF
-   for i in $SUBDIRS; do
-    case $CONFIG_FILES in
-     *${i}/Makefile*)
-       #echo "Adding MULTISUBDIR to $i/Makefile"
-       sed -f vpsed $i/Makefile > tmp
-       grep '^MULTISUBDIR =' Makefile >> tmp
-       mv tmp $i/Makefile
-       ;;
-    esac
-   done
-   rm vpsed
- fi
- (cd include && ${MAKE-make})
-],
-[
-# Variables needed in config.status (file generation) which aren't already
-# passed by autoconf.
-SUBDIRS="$SUBDIRS"
+   sed -f vpsed$$ $ac_file > tmp$$
+   grep '^MULTISUBDIR =' Makefile >> tmp$$
+   mv tmp$$ $ac_file
+   rm vpsed$$
 ])
 
+AC_CONFIG_COMMANDS([generate-headers],
+  [(cd include && ${MAKE-make})])
+
 dnl And this actually makes things happen:
 AC_OUTPUT


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]