PATCH: PR bootstrap/18532: libgcc.mk isn't parallel build safe for multilib

H. J. Lu hjl@lucon.org
Thu Dec 2 18:58:00 GMT 2004


On Thu, Dec 02, 2004 at 10:44:59AM -0800, Zack Weinberg wrote:
> "H. J. Lu" <hjl@lucon.org> writes:
> 
> >> I don't see the need for the dependency on $prev_extra, could you
> >> explain why that is there?  I'd think it would be preferable either
> >> to invoke recursive make just once with *all* the EXTRA_MULTILIB_PARTS
> >> targets (across all the multilibs) or else to allow the recursive
> >> makes for each multilib to run in parallel.
> >
> > We need it since each multilib is built with
> >
> > $(MAKE) T=$dir ...
> >
> > "$dir" is different in each build.
> 
> I see.
> 
> > We may not do it in parallel safely, which is PR bootstrap/18532. We
> > may only do it safely one multilib at a time.
> 
> Can you actually demonstrate a problem if the $prev_extra dependency
> is removed, or is this just a theoretical issue?
> 

It isn't a problem for x86-64 since it only has 2 sets and the default
one is built before libgcc.mk is reached. It may be a problem for
targets with more than 2 sets since you may have

make T=dir1/ ...
make T=dir2/ ...

running at the same time. It is the same as running

make T=dir1/ ...
make T=dir1/ ...

at the same time.

> >> Also, some nitpicks: You should hoist the definition of $suffix
> >> from where you have it (and from the other place it appears, in the
> >> SHLIB_LINK logic at the beginning of the loop over all multilibs) to
> >> next to the definition of $dir and $flags, and add it to the set of
> >> variables printed out in comments for each multilib.
> >
> > I removed my suffix.
> 
> Now it's not always set.  You have to hoist the existing definition
> out of the SHLIB_LINK logic, like I said.
> 

Here is the new patch.


H.J.
----
2004-12-02  H.J. Lu  <hongjiu.lu@intel.com>

	PR bootstrap/18532
	* mklibgcc.in: Only run make one at a time for multilib.

--- gcc/mklibgcc.in.multilib	2004-12-01 10:11:00.000000000 -0800
+++ gcc/mklibgcc.in	2004-12-02 10:55:33.819615236 -0800
@@ -147,6 +147,7 @@ done
 # Rules to generate object files.
 #
 
+prev_extra=
 for ml in $MULTILIBS; do
 
   # Work out relevant parameters that depend only on the multilib.
@@ -160,6 +161,11 @@ for ml in $MULTILIBS; do
   libgcc_s_so=
   libunwind_a=
   libunwind_so=
+  if [ "$dir" = . ]; then
+    suffix=
+  else
+    suffix=`echo $dir | sed s,/,_,g`
+  endif
 
   if [ "$LIBUNWIND" ]; then
     libunwind_a=$dir/libunwind.a
@@ -177,7 +183,6 @@ for ml in $MULTILIBS; do
 	  libunwind_soname=libunwind
 	fi
       else
-        suffix=`echo $dir | sed s,/,_,g`
 	libgcc_eh_a=$dir/libgcc_eh.a
 	libgcc_s_so_base=$dir/libgcc_s_${suffix}
 	libgcc_s_so=${libgcc_s_so_base}${SHLIB_EXT}
@@ -655,37 +660,37 @@ for ml in $MULTILIBS; do
   done
 
   # EXTRA_MULTILIB_PARTS.
-  echo
-  for f in $EXTRA_MULTILIB_PARTS; do
-    case $dir in
-    .) out=$f ; t= ;;
-    *) out=$dir/$f ; t=$dir/ ;;
-    esac
-    case $out in
-    # Prevent `make' from interpreting $out as a macro assignment
-    *'$(EQ)'*) targ="T_TARGET=$out T_TARGET" ;;
-    *) targ=$out ;;
-    esac
+  if [ -n "$EXTRA_MULTILIB_PARTS" ]; then
+    # We can't have individual element in EXTRA_MULTILIB_PARTS as a
+    # target since it won't be parallel build safe.  We bundle them
+    # together and pass them to Makefile. libgcc.mk has no knowledge
+    # of if and how EXTRA_MULTILIB_PARTS are built.
+    
+    extra=
+    extra_out=
+    echo
+    for f in $EXTRA_MULTILIB_PARTS; do
+      case $dir in
+      .) out=$f ; t= ;;
+      *) out=$dir/$f ; t=$dir/ ;;
+      esac
+      case $out in
+      # Prevent `make' from interpreting $out as a macro assignment
+      *'$(EQ)'*) targ="T_TARGET=$out T_TARGET" ;;
+      *) targ=$out ;;
+      esac
+      extra_out="$extra_out $out"
+      extra="$extra $targ"
+    done
 
-    echo $out: stmp-dirs
+    echo extra$suffix: stmp-dirs $prev_extra
     echo "	$make_compile" \\
     echo '	  LIBGCC2_CFLAGS="$(LIBGCC2_CFLAGS)' $flags '" ' \\
-    echo '	  MULTILIB_CFLAGS="'$flags'"' T=$t $targ
-    echo "all: $out"
+    echo '	  MULTILIB_CFLAGS="'$flags'"' T=$t $extra
+    echo "all: extra$suffix"
 
-    # Make libunwind.so and libgcc_s.so depend on these, since they are
-    # likely to be implicitly used by the link process.  However, we must
-    # then arrange to remove them from the explicit object list generated
-    # from $^ - see below.
-    if [ "$libgcc_s_so" ]; then
-      libgcc_s_so_extra="$libgcc_s_so_extra $out"
-      echo "$libgcc_s_so: $out"
-    fi
-    if [ "$libunwind_so" ]; then
-      libunwind_so_extra="$libunwind_so_extra $out"
-      echo "$libunwind_so: $out"
-    fi
-  done
+    prev_extra=extra$suffix
+  fi
 
   # Library build rules.
   dir=`echo ${ml} | sed -e 's/;.*$//' -e 's/=/$(EQ)/g'`
@@ -760,7 +765,7 @@ EOF
     echo "	$SHLIB_LINK" \
 	 | sed -e "s%@multilib_flags@%$flags%g" \
 	       -e "s%@multilib_dir@%$dir%g" \
-	       -e "s%@shlib_objs@%\$(filter-out $libgcc_s_so_extra,\$(objects))%g" \
+	       -e "s%@shlib_objs@%\$(objects)%g" \
 	       -e "s%@shlib_base_name@%$libgcc_s_so_base%g" \
 	       -e "s%@shlib_so_name@%$libgcc_s_soname%g" \
 	       -e "s%@shlib_map_file@%$mapfile%g" \
@@ -775,7 +780,7 @@ EOF
     echo "	$SHLIBUNWIND_LINK" \
 	   | sed -e "s%@multilib_flags@%$flags%g" \
 		 -e "s%@multilib_dir@%$dir%g" \
-		 -e "s%@shlib_objs@%\$(filter-out $libunwind_so_extra,\$(objects))%g" \
+		 -e "s%@shlib_objs@%\$(objects)%g" \
 		 -e "s%@shlib_base_name@%$libunwind_so_base%g" \
 		 -e "s%@shlib_so_name@%$libunwind_soname%g" \
 		 -e "s%@shlib_dir@%$shlib_dir%g" \



More information about the Gcc-patches mailing list