Patch for Review: Build all libjava .class files at once

Mohan Embar gnustuff@thisiscool.com
Thu May 1 09:33:00 GMT 2003


Hi Patch People,

For those of us who have done one libgcj full build too many,
here is a patch which compiles all (non-special-cased) libjava
.java files into .class files in one single invocation of gcj,
as mentioned here:

http://gcc.gnu.org/ml/java/2003-02/msg00590.html

On my PII 450MHz/256MB machine running RH 8.0, this patch cuts
the time for this step down to roughly four and a half minutes
compared to a pre-patch time of roughly 12.5 minutes.

Tested on i686-pc-linux-gnu. This patch is against the
active development branch.

-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/

ChangeLog
2003-05-01  Mohan Embar  <gnustuff@thisiscool.com>

	* Makefile.am: (.java.class) Append source file to
	file list instead of invoking gcj on it.
	(built_java_class_files) New phony target for compiling
	all Java sources in one invocation of gcj instead of
	individually.
	(build_java_sources_init) New phony target which performs
	initialization for built_java_class_files.
	(libgcj-@gcc_version@.jar) Changed dependency from
	$(all_java_class_files) to built_java_class_files
	(all-recursive) idem
	* Makefile.in: Rebuilt.

Index: Makefile.am
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/Makefile.am,v
retrieving revision 1.292
diff -u -2 -r1.292 Makefile.am
--- Makefile.am	30 Apr 2003 07:23:38 -0000	1.292
+++ Makefile.am	1 May 2003 08:46:59 -0000
@@ -326,9 +326,25 @@
 all_java_class_files = $(all_java_source_files:.java=.class)
 
+# Create a list of out-of-date, non-special-case-compilable Java
+# source files and compile them in one go.
+.PHONY: build_java_sources_init built_java_class_files
+
+tmp_java_filelist = tmp-java-filelist
+
 .java.class:
-	$(JAVAC) $(JCFLAGS) -classpath '' -bootclasspath $(here):$(srcdir) \
-             -d $(here) $<
+	@echo $< >> $(tmp_java_filelist)
+
+build_java_sources_init: 
+	-@rm -f $(tmp_java_filelist)
+	@touch $(tmp_java_filelist)
+	@echo Creating Java source file list....
+
+built_java_class_files: build_java_sources_init $(all_java_class_files)
+	@if test -s $(tmp_java_filelist); then echo Compiling Java sources....; \
+	    $(JAVAC) $(JCFLAGS) -classpath '' -bootclasspath $(here):$(srcdir) \
+	    -d $(here) @$(tmp_java_filelist); \
+	fi
 
-libgcj-@gcc_version@.jar: $(all_java_class_files)
+libgcj-@gcc_version@.jar: built_java_class_files
 	-@rm -f libgcj-@gcc_version@.jar
 ## Note that we explicitly want to include directory information.
@@ -2711,5 +2727,5 @@
 ## Also force all the class files to build first. This makes them build in
 ## the right order to improve performance.
-all-recursive: $(all_java_class_files) $(nat_headers) $(x_nat_headers)
+all-recursive: built_java_class_files $(nat_headers) $(x_nat_headers)
 
 ## ################################################################






More information about the Java-patches mailing list