Description of problem: A simple hello world program compiled with "gcj -static" under a fully updated (as of Jan 22, 2005) Fedora Core 3 i386 installation gives out "Segmentation fault" immediately upon running. Version-Release number of selected component (if applicable): #gcj -v Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-java-awt=gtk --host=i386-redhat-linux Thread model: posix gcc version 3.4.2 20041017 (Red Hat 3.4.2-6.fc3) How reproducible: Write a simple hello world-type program and save as HelloWorld.java -- just main and a System.out.println. Compile with "gcj --main=HelloWorld HelloWorld.java". Verify that running a.out prints "Hello, world!" :). Now do it with "gcj -static --main=HelloWorld HelloWorld.java" and run the new multi-megabyte a.out to confirm the "Segmentation fault".
Well, static linking is almost always a bad idea and in the Java case even more. Guess I'll just remove the .a libs for FC4. The problem is, at link time you don't know what all classes you'll need, and if you miss one that will be needed (as in this case at least gnu.gcj.convert.Output_UTF8), it will die miserably. You can add -Wl,--whole-archive -lgcj -Wl,--no-whole-archive to the link line and it will work just fine then, just beware that e.g. on x86_64 where I was trying this even stripped HelloWorld program has 8MB+.
We should reject -static as an option to gcj.
Well, already not including libgcj.a will effectively mean rejection of -static. http://people.redhat.com/drepper/no_static_linking.html
-static is now rejected in gcj and no Java .a included in rawhide gcc.
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on the solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2005-257.html