Makefile.in (LLINKER): New variable.

* Makefile.in (LLINKER): New variable.
	(mostlyclean): Remove link mutex.
	* configure.ac: Handle --enable-link-mutex.
	* lock-and-run.sh: New script.

From-SVN: r198977
This commit is contained in:
Jason Merrill 2013-05-16 11:09:31 -04:00 committed by Jason Merrill
parent 11678eb383
commit 427b248dd0
24 changed files with 139 additions and 11 deletions

View File

@ -1,3 +1,10 @@
2013-05-16 Jason Merrill <jason@redhat.com>
* Makefile.in (LLINKER): New variable.
(mostlyclean): Remove link mutex.
* configure.ac: Handle --enable-link-mutex.
* lock-and-run.sh: New script.
2013-05-16 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com> 2013-05-16 Ramana Radhakrishnan <ramana.radhakrishnan@arm.com>
PR target/19599 PR target/19599

View File

@ -235,6 +235,13 @@ LINKER = $(CC)
LINKER_FLAGS = $(CFLAGS) LINKER_FLAGS = $(CFLAGS)
endif endif
# Like LINKER, but use a mutex for serializing front end links.
ifeq (@DO_LINK_MUTEX@,true)
LLINKER = $(SHELL) $(srcdir)/lock-and-run.sh linkfe.lck $(LINKER)
else
LLINKER = $(LINKER)
endif
# ------------------------------------------- # -------------------------------------------
# Programs which operate on the build machine # Programs which operate on the build machine
# ------------------------------------------- # -------------------------------------------
@ -4529,6 +4536,8 @@ mostlyclean: lang.mostlyclean
-rm -f gtype.state -rm -f gtype.state
# Delete genchecksum outputs # Delete genchecksum outputs
-rm -f *-checksum.c -rm -f *-checksum.c
# Delete lock-and-run bits
-rm -rf linkfe.lck lock-stamp.*
# Delete all files made by compilation # Delete all files made by compilation
# that don't exist in the distribution. # that don't exist in the distribution.

View File

@ -1,3 +1,7 @@
2013-05-16 Jason Merrill <jason@redhat.com>
* gcc-interface/Make-lang.in (gnat1$(exeext)): Use link mutex.
2013-05-13 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> 2013-05-13 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR ada/57188 PR ada/57188

View File

@ -185,6 +185,7 @@ endif
GCC_LINKERFLAGS = $(filter-out -Werror, $(ALL_LINKERFLAGS)) GCC_LINKERFLAGS = $(filter-out -Werror, $(ALL_LINKERFLAGS))
GCC_LINK=$(LINKER) $(GCC_LINKERFLAGS) $(LDFLAGS) GCC_LINK=$(LINKER) $(GCC_LINKERFLAGS) $(LDFLAGS)
GCC_LLINK=$(LLINKER) $(GCC_LINKERFLAGS) $(LDFLAGS)
# Lists of files for various purposes. # Lists of files for various purposes.
@ -562,7 +563,8 @@ TARGET_ADA_SRCS =
# Since the RTL should be built with the latest compiler, remove the # Since the RTL should be built with the latest compiler, remove the
# stamp target in the parent directory whenever gnat1 is rebuilt # stamp target in the parent directory whenever gnat1 is rebuilt
gnat1$(exeext): $(TARGET_ADA_SRCS) $(GNAT1_OBJS) $(ADA_BACKEND) libcommon-target.a $(LIBDEPS) gnat1$(exeext): $(TARGET_ADA_SRCS) $(GNAT1_OBJS) $(ADA_BACKEND) libcommon-target.a $(LIBDEPS)
+$(GCC_LINK) -o $@ $(GNAT1_OBJS) $(ADA_BACKEND) libcommon-target.a $(LIBS) $(SYSLIBS) $(BACKENDLIBS) $(CFLAGS) +$(GCC_LLINK) -o $@ $(GNAT1_OBJS) $(ADA_BACKEND) \
libcommon-target.a $(LIBS) $(SYSLIBS) $(BACKENDLIBS) $(CFLAGS)
$(RM) stamp-gnatlib2-rts stamp-tools $(RM) stamp-gnatlib2-rts stamp-tools
gnatbind$(exeext): ada/b_gnatb.o $(CONFIG_H) $(GNATBIND_OBJS) ggc-none.o libcommon-target.a $(LIBDEPS) gnatbind$(exeext): ada/b_gnatb.o $(CONFIG_H) $(GNATBIND_OBJS) ggc-none.o libcommon-target.a $(LIBDEPS)

View File

@ -1,3 +1,7 @@
2013-05-16 Jason Merrill <jason@redhat.com>
* Make-lang.in (cc1$(exeext)): Use link mutex.
2013-04-24 Paolo Carlini <paolo.carlini@oracle.com> 2013-04-24 Paolo Carlini <paolo.carlini@oracle.com>
* c-typeck.c (pointer_diff): Change -Wpointer-arith pedwarns * c-typeck.c (pointer_diff): Change -Wpointer-arith pedwarns

View File

@ -75,7 +75,7 @@ cc1-checksum.c : build/genchecksum$(build_exeext) checksum-options \
cc1-checksum.o : cc1-checksum.c $(CONFIG_H) $(SYSTEM_H) cc1-checksum.o : cc1-checksum.c $(CONFIG_H) $(SYSTEM_H)
cc1$(exeext): $(C_OBJS) cc1-checksum.o $(BACKEND) $(LIBDEPS) cc1$(exeext): $(C_OBJS) cc1-checksum.o $(BACKEND) $(LIBDEPS)
+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(C_OBJS) \ +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ $(C_OBJS) \
cc1-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS) cc1-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
# #
# Build hooks: # Build hooks:

28
gcc/configure vendored
View File

@ -670,6 +670,7 @@ subdirs
dollar dollar
gcc_tooldir gcc_tooldir
enable_lto enable_lto
DO_LINK_MUTEX
MAINT MAINT
zlibinc zlibinc
zlibdir zlibdir
@ -916,6 +917,7 @@ with_long_double_128
with_gc with_gc
with_system_zlib with_system_zlib
enable_maintainer_mode enable_maintainer_mode
enable_link_mutex
enable_version_specific_runtime_libs enable_version_specific_runtime_libs
enable_plugin enable_plugin
enable_libquadmath_support enable_libquadmath_support
@ -1627,6 +1629,8 @@ Optional Features:
--enable-maintainer-mode --enable-maintainer-mode
enable make rules and dependencies not useful (and enable make rules and dependencies not useful (and
sometimes confusing) to the casual installer sometimes confusing) to the casual installer
--enable-link-mutex avoid linking multiple front-ends at once to avoid
thrashing on the build machine
--enable-version-specific-runtime-libs --enable-version-specific-runtime-libs
specify that runtime libraries should be installed specify that runtime libraries should be installed
in a compiler-specific directory in a compiler-specific directory
@ -17830,7 +17834,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF cat > conftest.$ac_ext <<_LT_EOF
#line 17833 "configure" #line 17837 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
@ -17936,7 +17940,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF cat > conftest.$ac_ext <<_LT_EOF
#line 17939 "configure" #line 17943 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
@ -27061,6 +27065,26 @@ else
MAINT='#' MAINT='#'
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to avoid linking multiple front-ends at once" >&5
$as_echo_n "checking whether to avoid linking multiple front-ends at once... " >&6; }
# Check whether --enable-link-mutex was given.
if test "${enable_link_mutex+set}" = set; then :
enableval=$enable_link_mutex; do_link_mutex=$enableval
else
do_link_mutex=no
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $do_link_mutex" >&5
$as_echo "$do_link_mutex" >&6; }
if test "$do_link_mutex" = "yes"; then
DO_LINK_MUTEX=true
else
DO_LINK_MUTEX=false
fi
# -------------- # --------------
# Language hooks # Language hooks
# -------------- # --------------

View File

@ -4958,6 +4958,24 @@ else
fi fi
AC_SUBST(MAINT)dnl AC_SUBST(MAINT)dnl
dnl Whether to prevent multiple front-ends from linking at the same time
AC_MSG_CHECKING([whether to avoid linking multiple front-ends at once])
AC_ARG_ENABLE(link-mutex,
[AS_HELP_STRING([--enable-link-mutex],
[avoid linking multiple front-ends at once to avoid thrashing
on the build machine])],
do_link_mutex=$enableval,
do_link_mutex=no)
AC_MSG_RESULT($do_link_mutex)
if test "$do_link_mutex" = "yes"; then
DO_LINK_MUTEX=true
else
DO_LINK_MUTEX=false
fi
AC_SUBST(DO_LINK_MUTEX)
# -------------- # --------------
# Language hooks # Language hooks
# -------------- # --------------

View File

@ -1,5 +1,7 @@
2013-05-16 Jason Merrill <jason@redhat.com> 2013-05-16 Jason Merrill <jason@redhat.com>
* Make-lang.in (cc1plus$(exeext)): Use link mutex.
PR c++/57279 PR c++/57279
* decl.c (grokdeclarator): Allow member function qualifiers in * decl.c (grokdeclarator): Allow member function qualifiers in
TYPENAME context in C++11 mode. TYPENAME context in C++11 mode.

View File

@ -100,7 +100,7 @@ cc1plus-checksum.c : build/genchecksum$(build_exeext) checksum-options \
cc1plus-checksum.o : cc1plus-checksum.c $(CONFIG_H) $(SYSTEM_H) cc1plus-checksum.o : cc1plus-checksum.c $(CONFIG_H) $(SYSTEM_H)
cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBDEPS) cc1plus$(exeext): $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBDEPS)
+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
$(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS) $(CXX_OBJS) cc1plus-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
ifeq ($(ENABLE_MAINTAINER_RULES), true) ifeq ($(ENABLE_MAINTAINER_RULES), true)

View File

@ -1293,6 +1293,11 @@ opposite effect. If neither option is specified, the configure script
will try to guess whether the @code{.init_array} and will try to guess whether the @code{.init_array} and
@code{.fini_array} sections are supported and, if they are, use them. @code{.fini_array} sections are supported and, if they are, use them.
@item --enable-link-mutex
When building GCC, use a mutex to avoid linking the compilers for
multiple languages at the same time, to avoid thrashing on build
systems with limited free memory. The default is not to use such a mutex.
@item --enable-maintainer-mode @item --enable-maintainer-mode
The build rules that regenerate the Autoconf and Automake output files as The build rules that regenerate the Autoconf and Automake output files as
well as the GCC master message catalog @file{gcc.pot} are normally well as the GCC master message catalog @file{gcc.pot} are normally

View File

@ -1,3 +1,7 @@
2013-05-16 Jason Merrill <jason@redhat.com>
* Make-lang.in (f951$(exeext)): Use link mutex.
2013-05-05 Tobias Burnus <burnus@net-b.de> 2013-05-05 Tobias Burnus <burnus@net-b.de>
* resolve.c (conformable_arrays): Avoid segfault * resolve.c (conformable_arrays): Avoid segfault

View File

@ -98,7 +98,7 @@ gfortran-cross$(exeext): gfortran$(exeext)
# The compiler itself is called f951. # The compiler itself is called f951.
f951$(exeext): $(F95_OBJS) \ f951$(exeext): $(F95_OBJS) \
$(BACKEND) $(LIBDEPS) attribs.o $(BACKEND) $(LIBDEPS) attribs.o
+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
$(F95_OBJS) $(BACKEND) $(ZLIB) $(LIBS) attribs.o \ $(F95_OBJS) $(BACKEND) $(ZLIB) $(LIBS) attribs.o \
$(BACKENDLIBS) $(BACKENDLIBS)

View File

@ -1,3 +1,7 @@
2013-05-16 Jason Merrill <jason@redhat.com>
* Make-lang.in (go1$(exeext)): Use link mutex.
2013-01-16 Shenghou Ma <minux.ma@gmail.com> 2013-01-16 Shenghou Ma <minux.ma@gmail.com>
* gospec.c: pass -u pthread_create to linker when static linking. * gospec.c: pass -u pthread_create to linker when static linking.

View File

@ -76,7 +76,7 @@ GO_OBJS = \
go/unsafe.o go/unsafe.o
go1$(exeext): $(GO_OBJS) attribs.o $(BACKEND) $(LIBDEPS) go1$(exeext): $(GO_OBJS) attribs.o $(BACKEND) $(LIBDEPS)
+$(CXX) $(ALL_CXXFLAGS) $(LDFLAGS) -o $@ \ +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
$(GO_OBJS) attribs.o $(BACKEND) $(LIBS) $(BACKENDLIBS) $(GO_OBJS) attribs.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
# Documentation. # Documentation.

View File

@ -1,3 +1,7 @@
2013-05-16 Jason Merrill <jason@redhat.com>
* Make-lang.in (jc1$(exeext)): Use link mutex.
2013-05-06 Jakub Jelinek <jakub@redhat.com> 2013-05-06 Jakub Jelinek <jakub@redhat.com>
PR libgcj/57074 PR libgcj/57074

View File

@ -99,7 +99,7 @@ jvspec.o-warn = -Wno-error
jc1$(exeext): $(JAVA_OBJS) $(BACKEND) $(LIBDEPS) attribs.o jc1$(exeext): $(JAVA_OBJS) $(BACKEND) $(LIBDEPS) attribs.o
rm -f $@ rm -f $@
+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
$(JAVA_OBJS) $(BACKEND) $(ZLIB) $(LIBICONV) $(LIBS) attribs.o $(BACKENDLIBS) $(JAVA_OBJS) $(BACKEND) $(ZLIB) $(LIBICONV) $(LIBS) attribs.o $(BACKENDLIBS)
jcf-dump$(exeext): $(JCFDUMP_OBJS) $(LIBDEPS) jcf-dump$(exeext): $(JCFDUMP_OBJS) $(LIBDEPS)

29
gcc/lock-and-run.sh Normal file
View File

@ -0,0 +1,29 @@
#! /bin/sh
# Shell-based mutex using mkdir.
lockdir=$1 prog=$2; shift 2 || exit 1
count=0
# Remember when we started trying to acquire the lock.
touch lock-stamp.$$
trap 'rm -r "$lockdir" lock-stamp.$$' 0
until mkdir "$lockdir" 2>/dev/null; do
# Say something periodically so the user knows what's up.
if [ `expr $count % 30` = 0 ]; then
# Reset if the lock has been renewed.
if [ -n "`find \"$lockdir\" -newer lock-stamp.$$`" ]; then
touch lock-stamp.$$
count=1
# Steal the lock after 5 minutes.
elif [ $count = 300 ]; then
echo removing stale $lockdir >&2
rm -r "$lockdir"
else
echo waiting to acquire $lockdir >&2
fi
fi
sleep 1
count=`expr $count + 1`
done
echo $prog "$@"
$prog "$@"
# The trap runs on exit.

View File

@ -1,3 +1,7 @@
2013-05-16 Jason Merrill <jason@redhat.com>
* Make-lang.in ($(LTO_EXE)): Use link mutex.
2013-05-15 Martin Jambor <mjambor@suse.cz> 2013-05-15 Martin Jambor <mjambor@suse.cz>
* lto-partition.c (lto_balanced_map): Print symbol order instead * lto-partition.c (lto_balanced_map): Print symbol order instead

View File

@ -71,7 +71,7 @@ lto.stagefeedback:
lto-warn = $(STRICT_WARN) lto-warn = $(STRICT_WARN)
$(LTO_EXE): $(LTO_OBJS) $(BACKEND) $(LIBDEPS) $(LTO_EXE): $(LTO_OBJS) $(BACKEND) $(LIBDEPS)
+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
$(LTO_OBJS) $(BACKEND) $(BACKENDLIBS) $(LIBS) $(LTO_OBJS) $(BACKEND) $(BACKENDLIBS) $(LIBS)
# Dependencies # Dependencies

View File

@ -1,3 +1,7 @@
2013-05-16 Jason Merrill <jason@redhat.com>
* Make-lang.in (cc1obj$(exeext)): Use link mutex.
2012-11-20 Diego Novillo <dnovillo@google.com> 2012-11-20 Diego Novillo <dnovillo@google.com>
* objc-act.c: Replace all vec<T, A>() initializers with vNULL. * objc-act.c: Replace all vec<T, A>() initializers with vNULL.

View File

@ -68,7 +68,7 @@ cc1obj-checksum.c : build/genchecksum$(build_exeext) checksum-options \
cc1obj-checksum.o : cc1obj-checksum.c $(CONFIG_H) $(SYSTEM_H) cc1obj-checksum.o : cc1obj-checksum.c $(CONFIG_H) $(SYSTEM_H)
cc1obj$(exeext): $(OBJC_OBJS) $(C_AND_OBJC_OBJS) cc1obj-checksum.o $(BACKEND) $(LIBDEPS) cc1obj$(exeext): $(OBJC_OBJS) $(C_AND_OBJC_OBJS) cc1obj-checksum.o $(BACKEND) $(LIBDEPS)
+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
$(OBJC_OBJS) $(C_AND_OBJC_OBJS) cc1obj-checksum.o \ $(OBJC_OBJS) $(C_AND_OBJC_OBJS) cc1obj-checksum.o \
$(BACKEND) $(LIBS) $(BACKENDLIBS) $(BACKEND) $(LIBS) $(BACKENDLIBS)

View File

@ -1,3 +1,7 @@
2013-05-16 Jason Merrill <jason@redhat.com>
* Make-lang.in (cc1objplus$(exeext)): Use link mutex.
2012-06-02 Jason Merrill <jason@redhat.com> 2012-06-02 Jason Merrill <jason@redhat.com>
* objcp-decl.c (objcp_start_struct): Adjust for change in * objcp-decl.c (objcp_start_struct): Adjust for change in

View File

@ -72,7 +72,7 @@ cc1objplus-checksum.c : build/genchecksum$(build_exeext) checksum-options \
cc1objplus-checksum.o : cc1objplus-checksum.c $(CONFIG_H) $(SYSTEM_H) cc1objplus-checksum.o : cc1objplus-checksum.c $(CONFIG_H) $(SYSTEM_H)
cc1objplus$(exeext): $(OBJCXX_OBJS) cc1objplus-checksum.o $(BACKEND) $(LIBDEPS) cc1objplus$(exeext): $(OBJCXX_OBJS) cc1objplus-checksum.o $(BACKEND) $(LIBDEPS)
+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \ +$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
$(OBJCXX_OBJS) cc1objplus-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS) $(OBJCXX_OBJS) cc1objplus-checksum.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
# Objective C++ language specific files. # Objective C++ language specific files.