On Fri, Jun 17, 2011 at 12:04:34PM +0100, IainS wrote: > Hi Jack, > > On 17 Jun 2011, at 03:21, Jack Howarth wrote: > >> >> The gcj compiler needs to pass -no_pie for linkage on darwin11 due to >> the new -pie >> default of the linker. The attached patch accomplishes this by passing >> -no_pie on SYSTEMSPEC >> for *-*-darwin[12]*. Since Darwin10 supports -no_pie in its linker, I >> included it in the >> triplet match to simplify the syntax. Bootstrap and tested on x86_64- >> apple-darwin11. >> Okay for gcc trunk? >> Jack >> >> 2011-06-16 Jack Howarth <howa...@bromo.med.uc.edu> >> >> * libjava/configure.ac (SYSTEMSPEC): Pass -no_pie for darwin11. >> * libjava/configure: Regenerate. > > > I would like to see some more analysis of what the underlying reasons > for failure are.
Iain, Stock gcc trunk without my patch, which creates a gcj (ecj1) linked with -pie, crashes as... [MacPro:~] howarth% gcj-fsf-4.7 --main=testme -O testme.java -pie -v Using built-in specs. Reading specs from /sw/lib/gcc4.7/lib/gcc/x86_64-apple-darwin11.0.0/4.7.0/../../../libgcj.spec rename spec startfile to startfileorig rename spec lib to liborig COLLECT_GCC=gcj-fsf-4.7 COLLECT_LTO_WRAPPER=/sw/lib/gcc4.7/libexec/gcc/x86_64-apple-darwin11.0.0/4.7.0/lto-wrapper Target: x86_64-apple-darwin11.0.0 Configured with: ../gcc-4.7-20110617/configure --prefix=/sw --prefix=/sw/lib/gcc4.7 --mandir=/sw/share/man --infodir=/sw/lib/gcc4.7/info --enable-languages=c,c++,fortran,objc,obj-c++,java --with-gmp=/sw --with-libiconv-prefix=/sw --with-ppl=/sw --with-cloog=/sw --with-mpc=/sw --with-system-zlib --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --program-suffix=-fsf-4.7 --enable-checking=yes --enable-cloog-backend=isl Thread model: posix gcc version 4.7.0 20110617 (experimental) (GCC) COLLECT_GCC_OPTIONS='-fsaw-java-file' '-mmacosx-version-min=10.7.0' '-O' '-pie' '-v' '-fbootclasspath=./:/sw/lib/gcc4.7/share/java/libgcj-4.7.0.jar' '-shared-libgcc' '-mtune=core2' /sw/lib/gcc4.7/libexec/gcc/x86_64-apple-darwin11.0.0/4.7.0/ecj1 testme.java -fbootclasspath=./:/sw/lib/gcc4.7/share/java/libgcj-4.7.0.jar -fsource=1.5 -ftarget=1.5 -fzip-dependency /var/folders/1l/n78sywl52lz6kkys6nv7mnph0000gp/T//ccxj1zOQ.zip -fzip-target /var/folders/1l/n78sywl52lz6kkys6nv7mnph0000gp/T//ccXXudTY.jar Exception in thread "main" java.lang.ClassFormatError: org.eclipse.jdt.internal.compiler.Compiler (erroneous exception handler info) at java.lang.VMClassLoader.defineClass(libgcj.12.dylib) at java.lang.ClassLoader.defineClass(libgcj.12.dylib) at java.security.SecureClassLoader.defineClass(libgcj.12.dylib) at java.net.URLClassLoader.findClass(libgcj.12.dylib) at java.lang.ClassLoader.loadClass(libgcj.12.dylib) at java.lang.ClassLoader.loadClass(libgcj.12.dylib) at org.eclipse.jdt.internal.compiler.impl.CompilerOptions.resetDefaults(CompilerOptions.java:963) at org.eclipse.jdt.internal.compiler.impl.CompilerOptions.<init>(CompilerOptions.java:371) at org.eclipse.jdt.internal.compiler.impl.CompilerOptions.<init>(CompilerOptions.java:363) at org.eclipse.jdt.internal.compiler.batch.Main.initialize(Main.java:3548) at org.eclipse.jdt.internal.compiler.batch.Main.<init>(Main.java:1435) at org.eclipse.jdt.internal.compiler.batch.Main.<init>(Main.java:1423) at org.eclipse.jdt.internal.compiler.batch.GCCMain.<init>(GCCMain.java:62) at org.eclipse.jdt.internal.compiler.batch.GCCMain.main(GCCMain.java:498) Running... MacPro:~] howarth% gdb /sw/lib/gcc4.7/libexec/gcc/x86_64-apple-darwin11.0.0/4.7.0/ecj1 ... (gdb) r testme.java -fbootclasspath=./:/sw/lib/gcc4.7/share/java/libgcj-4.7.0.jar -fsource=1.5 -ftarget=1.5 -fzip-dependency testme.zip -fzip-target testme.jar Starting program: /sw/lib/gcc4.7/libexec/gcc/x86_64-apple-darwin11.0.0/4.7.0/ecj1 testme.java -fbootclasspath=./:/sw/lib/gcc4.7/share/java/libgcj-4.7.0.jar -fsource=1.5 -ftarget=1.5 -fzip-dependency testme.zip -fzip-target testme.jar Reading symbols for shared libraries +++++........................ done Program exited normally. ...produces no backtraces (and no a.out). Jack > > -fpie works fine with darwin 9 and darwin 10 libjava [XCode 3.1.4 and > 3.2.5 respectively, bootstrap w/4.2.1] > (modulo suppressing it when building test-suite .dylibs *** - which is a > testsuite options handling issue - not a fundamental problem). > > so: > > make -k check-target-libjava "RUNTESTFLAGS=--target_board=unix/-fpie\{- > m32,-m64\} " > > passes without regression (re the no pie case) given that pie is > suppressed for dylibs. > > ----- > > So is your proposed patch a work-around for (as yet unreleased) darwin > 11 tool-chain bugs or ... ? > > Iain > > === > **** > kludge to suppress pie for for dylibs (use in place of the darwin9.h > hunk from the attachment on PR49371). > > Index: gcc/config/darwin9.h > =================================================================== > --- gcc/config/darwin9.h (revision 175110) > +++ gcc/config/darwin9.h (working copy) > @@ -35,6 +35,12 @@ along with GCC; see the file COPYING3. If not see > /* Tell collect2 to run dsymutil for us as necessary. */ > #define COLLECT_RUN_DSYMUTIL 1 > > +#undef PIE_SPEC > +#define PIE_SPEC \ > + "%{fpie|pie|fPIE: %{!Zdynamiclib: \ > + %{mdynamic-no-pic: %n'-mdynamic-no-pic' overrides '-pie', '-fpie' > or '-fPIE'; \ > + :-pie}}}" > + > #undef ASM_OUTPUT_ALIGNED_COMMON > #define ASM_OUTPUT_ALIGNED_COMMON(FILE, NAME, SIZE, ALIGN) \ > do { \