%general-entities; ]> $Date$ GCC-Java-&gcc-java-version; GCC-Java-&gcc-java-version; Introduction to GCC-Java See the introduction to the Java language and system at . The GNU Compiler Collection (GCC) contains a Java compiler to native code. Together with the ecj Java compiler from Eclipse (to bytecode), it provides a way to build an acceptable JVM from source. However, since the release of OpenJDK, the development of GCC-Java has almost stopped, and the built JVM is an old version, which cannot be used for building . &lfs80_checked; Using the instructions on this page will have the effect that the C and C++ compiler and libraries will be reinstalled, overwriting the ones on your system. This may lead to some issues. Please read the note and caution on the page. Package Information Download (HTTP): Download (FTP): Download MD5 sum: &gcc-java-md5sum; Download size: &gcc-java-size; Estimated disk space required: &gcc-java-buildsize; Estimated build time: &gcc-java-time; Additional Downloads Eclipse Java compiler: ANTLR binary, for building gjdoc (optional): GCC Java Dependencies Required , , and Recommended , for tests Optional and Libart for building the AWT peer User Notes: Installation of GCC Java The instructions below assume that the C and C++ compilers have the same version as the one you are installing, so that a bootstrap is not necessary. If you are upgrading the GCC version, then remove the from the ./configure options below. Install GCC Java by running the following commands: case $(uname -m) in x86_64) sed -e '/m64=/s/lib64/lib/' \ -i.orig gcc/config/i386/t-linux64 ;; esac sed -i 's/\(install.*:\) install-.*recursive/\1/' libffi/Makefile.in && sed -i 's/\(install-data-am:\).*/\1/' libffi/include/Makefile.in && sed -i 's/absolute/file normalize/' libjava/testsuite/lib/libjava.exp && sed -i 's/major.*1000.*minor/major/' gcc/java/decl.c && cp ../ecj-4.9.jar ./ecj.jar && mkdir build && cd build && ../configure \ --prefix=/usr \ --disable-multilib \ --with-system-zlib \ --disable-bootstrap \ --enable-java-home \ --with-jvm-root-dir=/opt/gcj \ --with-antlr-jar=$(pwd)/../../antlr-&antlr-version;-complete.jar \ --enable-languages=java && make If you have installed additional packages such as Valgrind and GDB, the GCC part of the testsuite will run more tests than in LFS. Some of those will report FAIL and others XPASS (pass when expected to FAIL). To run the tests, issue: ulimit -s 32768 && make -k check The tests are very long, and the results may be hard to find in the logs, specially if you use job control with make. You can get a summary of the tests with: ../contrib/test_summary Now, as the root user: make install && mkdir -pv /usr/share/gdb/auto-load/usr/lib && mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib && chown -v -R root:root \ /usr/lib/gcc/*linux-gnu/&gcc-java-version;/include{,-fixed} && gcj -o ecj ../../ecj-4.9.jar \ --main=org.eclipse.jdt.internal.compiler.batch.Main && mv ecj /usr/bin && ln -sfv ../../../usr/bin/ecj /opt/gcj/bin/javac Command Explanations The first two sed commands prevent the installation of the libffi library bundled with GCC, since it is outdated compared to . The next two sed commands implement upstream fixes to the GCC Java compiler and tests. mkdir build; cd build: The GCC documentation recommends building the package in a dedicated build directory. --disable-multilib: This parameter ensures that files are created for the specific architecture of your computer. --with-system-zlib: Uses the system zlib instead of the bundled one. --disable-bootstrap: Prevents the C and C++ compilers to recompile themselves. You should use this switch only if the installed C and C++ compilers are the same version as the ones you install. --enable-java-home: Creates a directory layout similar to that of a JVM. --with-jvm-root-dir=/opt/gcj: Installs the JVM in the specified location. --with-antlr-jar=...: Specifies the location of ANTLR, which is needed to build gjdoc. Remove if you have not downloaded antlr. --enable-languages=java: This command identifies which language to build. Note it is unavoidable that the C and C++ compilers be built too. : Allows to build the Java AWT GTK+2 peer. Needed to have a fully functional JVM. ulimit -s 32768: This command prevents several tests from running out of stack space. make -k check: This command runs the test suite without stopping if any errors are encountered. ../contrib/test_summary: This command will produce a summary of the test suite results. You can append | grep -A7 Summ to the command to produce an even more condensed version of the summary. You may also wish to redirect the output to a file for review and comparison later on. chown -v -R root:root /usr/lib/gcc/*linux-gnu/...: If the package is built by a user other than root, the ownership of the installed include directory (and its content) will be incorrect. This command changes the ownership to the root user and group. gcj -o ecj ...: compiles the eclipse compiler to native code, which is much faster than bytecode. This compiler is then used as a javac replacement in the JVM. Configuring GCC-Java Configuration Information The configuration is the same as , replacing /opt/jdk with /opt/gcj. Contents Installed Programs Installed Libraries Installed Directories aot-compile, ecj, gappletviewer, gc-analyze, gcj, gcj-dbtool, gcjh, gij, gjar, gjarsigner, gjavah, gjdoc, gkeytool, gnative2ascii, gorbd, grmic, grmid, grmiregistry, gserialver, gtnameserv, jcf-dump, jv-convert, rebuild-gcj-db. Symbolic links to these files are located in /opt/gcj/bin libgcj_bc.so, libgcj.so, libgcj-tools.so, and libgij.so /usr/include/c++/&gcc-java-version;/{gcj,gnu,java,javax,org,sun}, /usr/lib/gcj-&gcc-java-version;-17, /usr/lib/jvm-exports, /usr/lib/security, /opt/gcj, and /usr/share/java Some programs, libraries, and descriptions are not listed here, but can be found at as they were initially installed during the building of LFS. Short Descriptions aot-compile searches a directory for Java bytecode and uses gcj to compile it to native code. aot-compile ecj is the Eclipse Java compiler. ecj gappletviewer loads and run a Java applet. gappletviewer gc-analyze analyzes garbage collector (GC) memory dumps from Java code. gc-analyze gcj is an ahead-of-time compiler for the Java language. gcj gcj-dbtool is a tool for creating and manipulating class file mapping databases. gcj-dbtool gcjh generates header files from Java class files. gcjh gij is the GNU interpreter for Java bytecode. gij gjar is an (partial) implementation of the jar utility that comes with Sun's JDK. gjar gjarsigner is a Java ARchive (JAR) file signing and verification tool. gjarsigner gjavah generates header files from Java class files. gjavah gjdoc is a documentation tool similar to javadoc. gjdoc gkeytool manages private keys and public certificates in a Java environment. gkeytool gnative2ascii is an encoding converter for Java. gnative2ascii gorbd is an object request broker daemon. gorbd grmic generates stubs for Remote Method Invocation. grmic grmid RMI activation system daemon. grmid grmiregistry starts a remote object registry on the current host. grmiregistry gserialver prints the serialVersionUID of the specified class. gserialver gtnameserv starts a naming service. gtnameserv jcf-dump prints information about Java class files. jcf-dump jv-convert converts files from one encoding to another. jv-convert rebuild-gcj-db Merge the per-solib databases made by aot-compile into one system-wide database. rebuild-gcj-db