HACKING 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. Things libgcj hackers should know
  2. ---------------------------------
  3. If you want to hack on the libgcj files you need to be aware of the
  4. following things. There are probably lots of other things that should be
  5. explained in this HACKING file. Please add them if you discover them :)
  6. --
  7. If you plan to modify a .java file, you will need to configure with
  8. --enable-java-maintainer-mode. In order to make this work properly,
  9. you will need to have 'ecj1' and 'gjavah' executables in your PATH at
  10. build time.
  11. One way to do this is to download ecj.jar (see contrib/download_ecj)
  12. and write a simple wrapper script like:
  13. #! /bin/sh
  14. gij -cp /home/tromey/gnu/Generics/trunk/ecj.jar \
  15. org.eclipse.jdt.internal.compiler.batch.GCCMain \
  16. ${1+"$@"}
  17. For gjavah, you can make a tools.zip from the classes in
  18. classpath/lib/tools/ and write a gjavah script like:
  19. #! /bin/sh
  20. dir=/home/tromey/gnu/Generics/Gcjh
  21. gij -cp $dir/tools.zip \
  22. gnu.classpath.tools.javah.Main \
  23. ${1+"$@"}
  24. Another way to get a version of gjavah is to first do a
  25. non-maintainer-mode build and use the newly installed gjavah.
  26. --
  27. To regenerate libjava/configure, first run aclocal passing the flags
  28. found near the top of Makefile.am, then autoconf. H. J. Lu writes that
  29. this can be done using these commands:
  30. cd libjava &&
  31. rm -f aclocal.m4 &&
  32. ACFLAGS=$(grep "^ACLOCAL_AMFLAGS" Makefile.in | sed -e "s/ACLOCAL_AMFLAGS[ \t ]*=//") &&
  33. aclocal-1.11 $ACFLAGS &&
  34. rm -f configure &&
  35. autoconf-2.64 &&
  36. rm -fr autom4te.cache
  37. See the GCC documentation which auto* versions to use.
  38. --
  39. libgcj uses GNU Classpath as an upstream provider. Snapshots of
  40. Classpath are imported into the libgcj source tree. Some classes are
  41. overridden by local versions; these files still appear in the libgcj
  42. tree.
  43. To import a new release:
  44. - Check out a classpath snapshot or take a release tar.gz file.
  45. I use 'cvs export' for this. Make a tag to ensure future hackers
  46. know exactly what revision was checked out; tags are of the form
  47. 'libgcj-import-DATE' (when using a tagged checkout do:
  48. - ./autogen.sh && ./configure && make dist
  49. to get a proper .tar.gz for importing below).
  50. - Get a svn checkout of
  51. svn+ssh://gcc.gnu.org/svn/gcc/branches/CLASSPATH/libjava/classpath
  52. this contains "pure" GNU Classpath inside the GCC tree.
  53. - Clean it up and get the files from a new version:
  54. - find classpath -type f | grep -v '/\.svn' | grep -v '/\.cvs' | xargs rm
  55. - tar zxf classpath-x.tar.gz
  56. - cp -r classpath-x/* classpath
  57. - Add/Remove files:
  58. - svn status classpath | grep ^\! | cut -c8- | xargs svn remove
  59. - svn status classpath | grep ^\? | cut -c8- | xargs svn add
  60. - If there are any empty directories now they can be removed. You can find
  61. candidates (dirs with files removed) with:
  62. - for i in `svn status classpath | grep ^D | cut -c8-`; \
  63. do ls -d `dirname $i`; done | uniq
  64. - Update vendor branch
  65. - svn commit classpath
  66. - Note the new revision number (Xrev)
  67. - Get a fresh svn trunk checkout and cd gcc/libjava
  68. - Merge the changes between classpath versions into the trunk.
  69. svn merge -rXrev-1:Xrev \
  70. svn+ssh://gcc.gnu.org/svn/gcc/branches/CLASSPATH/libjava/classpath \
  71. classpath
  72. - Resolve any conflicts pointed out by svn status classpath | grep ^C
  73. - Makefile.in files will be regenerated in the next step.
  74. - Other files should have a "GCJ LOCAL" comment, and/or are mentioned
  75. in the classpath/ChangeLog.gcj file.
  76. (Don't forget to svn resolved files.)
  77. - Use auto* to create configure, Makefile.in, etc
  78. Make sure you have Automake 1.11.1 installed. Exactly that version!
  79. You have to make sure to use the gcc libtool.m4 and gcc lt* scripts
  80. cd .../classpath
  81. cp ../../lt* .
  82. cp ../../config.sub ../../config.guess .
  83. aclocal -I m4 -I ../.. -I ../../config
  84. autoconf
  85. autoheader
  86. automake
  87. rm -rf autom4te.cache
  88. cd ..
  89. scripts/makemake.tcl > sources.am
  90. automake
  91. - Remove the generated class and header files:
  92. find classpath -name '*.class' | xargs -r rm -f
  93. find gnu java javax org sun -name '*.h' \
  94. | xargs -r grep -Fl 'DO NOT EDIT THIS FILE - it is machine generated' \
  95. | xargs -r rm -f
  96. - Build, fix, till everything works.
  97. Be sure to build all peers (--enable-java-awt=gtk,xlib,qt
  98. --enable-gconf-peer --enable-gstreamer-peer).
  99. Be sure to build gjdoc (--enable-gjdoc).
  100. Be sure to update gnu/classpath/Configuration.java to reflect
  101. the new version
  102. Possibly update the gcj/javaprims.h file with scripts/classes.pl
  103. (See below, it can only be done after the first source->bytecode
  104. pass has finished.)
  105. You will need to configure with --enable-java-maintainer-mode and you
  106. will need to update the .class files and generated CNI header files in
  107. your working tree
  108. - Add/Remove newly generated files:
  109. - svn status classpath | grep '^!.*\.class$' | cut -c8- | xargs svn remove
  110. - svn status classpath | grep '^?' | cut -c8- | xargs svn add
  111. - svn status gnu java javax org sun | grep '^!.*\.h$' | cut -c8- | xargs svn remove
  112. - svn status gnu java javax org sun | grep '^?' | cut -c8- | xargs svn add
  113. Over time we plan to remove as many of the remaining divergences as
  114. possible.
  115. File additions and deletions require running scripts/makemake.tcl
  116. before running automake.
  117. --
  118. In general you should not make any changes in the classpath/
  119. directory. Changes here should come via imports from upstream.
  120. However, there are three (known) exceptions to this rule:
  121. * In an emergency, such as a bootstrap breakage, it is ok to commit a
  122. patch provided that the problem is resolved (by fixing a compiler
  123. bug or fixing the Classpath bug upstream) somehow and the resolution
  124. is later checked in (erasing the local diff).
  125. * On a release branch to fix a bug, where a full-scale import of
  126. Classpath is not advisable.
  127. * We maintain a fair number of divergences in the build system.
  128. This is a pain but they don't seem suitable for upstream.
  129. --
  130. You can develop in a GCC tree using a CVS checkout of Classpath, most
  131. of the time. (The exceptions are when an incompatible change has been
  132. made in Classpath and some core part of libgcj has not yet been
  133. updated.)
  134. The way to set this up is very similar to importing a new version of
  135. Classpath into the libgcj tree. In your working tree:
  136. * cd gcc/libjava; rm -rf classpath
  137. * cvs co classpath
  138. * cd classpath
  139. Now run the auto tools as specified in the import process; then
  140. cd ..
  141. * Run 'scripts/makemake.tcl > sources.am' in the source tree
  142. * Run automake for libgcj
  143. Now you should be ready to go.
  144. If you are working in a tree like this, you must remember to run
  145. makemake.tcl and automake whenever you update your embedded classpath
  146. tree.
  147. --
  148. If you add a class to java.lang, java.io, or java.util
  149. (including sub-packages, like java.lang.ref).
  150. * Edit gcj/javaprims.h
  151. * Go to the `namespace java' line, and delete that entire block (the
  152. entire contents of the namespace)
  153. * Then insert the output of `perl scripts/classes.pl' into the file
  154. at that point. This must be run from the source tree, in
  155. libjava/classpath/lib; it uses the .class file name to determine
  156. what to print.