public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH]: Pass -no_pie on SYSTEMSPEC for darwin11
@ 2011-06-17  4:32 Jack Howarth
  2011-06-17 11:21 ` IainS
  2011-06-17 17:49 ` Mike Stump
  0 siblings, 2 replies; 10+ messages in thread
From: Jack Howarth @ 2011-06-17  4:32 UTC (permalink / raw)
  To: gcc-patches; +Cc: mikestump, iains

  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 <howarth@bromo.med.uc.edu>

	* libjava/configure.ac (SYSTEMSPEC): Pass -no_pie for darwin11.
	* libjava/configure: Regenerate.


Index: libjava/configure.ac
===================================================================
--- libjava/configure.ac	(revision 175131)
+++ libjava/configure.ac	(working copy)
@@ -898,9 +898,12 @@ case "${host}" in
         SYSTEMSPEC="-lunicows $SYSTEMSPEC"
       fi
     ;;
-    *-*-darwin[[912]]*)
+    *-*-darwin9*)
       SYSTEMSPEC="%{!Zdynamiclib:%{!Zbundle:-allow_stack_execute}}"
     ;;
+    *-*-darwin[[12]]*)
+      SYSTEMSPEC="-no_pie %{!Zdynamiclib:%{!Zbundle:-allow_stack_execute}}"
+    ;;
     *)
       SYSTEMSPEC=
     ;;

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH]: Pass -no_pie on SYSTEMSPEC for darwin11
  2011-06-17  4:32 [PATCH]: Pass -no_pie on SYSTEMSPEC for darwin11 Jack Howarth
@ 2011-06-17 11:21 ` IainS
  2011-06-17 13:57   ` Jack Howarth
                     ` (3 more replies)
  2011-06-17 17:49 ` Mike Stump
  1 sibling, 4 replies; 10+ messages in thread
From: IainS @ 2011-06-17 11:21 UTC (permalink / raw)
  To: Jack Howarth; +Cc: GCC Patches, Mike Stump

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 <howarth@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.

-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  
{                                                                 \

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH]: Pass -no_pie on SYSTEMSPEC for darwin11
  2011-06-17 11:21 ` IainS
@ 2011-06-17 13:57   ` Jack Howarth
  2011-06-17 15:34   ` Jack Howarth
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Jack Howarth @ 2011-06-17 13:57 UTC (permalink / raw)
  To: IainS; +Cc: GCC Patches, Mike Stump

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 <howarth@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,
   I suspect these failures are related to those seen in the boehm-gc
testsuite when those tests are built with the default -pie linker option. I'll
have to repeat a build without the patch but a cursory examination suggests
ecj1 is miscompiled with -pie. If I remove -no_pie from /sw/lib/gcc4.7/lib/libgcj.spec
after building and installing gcc trunk, the crashes in gcj don't occur.
IMHO, my patch is effectively doing the same thing that Mike checked in with...

# Ensure we don't try and use -pie, as it is incompatible with pch.
BOOT_LDFLAGS += `case ${host} in *-*-darwin[1][1-9]*) echo -Wl,-no_pie ;; esac;`

The libjava build uses gcj.spec to build ecj1, etc and Mike's change is insufficient
to cause -no_pie to be used for those cases (since those parts of the libjava bootstrap
don't honor BOOT_LDFLAGS).
                 Jack
ps I'll repeat the bootstrap without my patch and open a PR for the gcj failure.
However, I believe it was an exception failure which would place us in the system unwinder
and that will be extremely difficult to debug outside of Apple.

>
> -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 {                                                                 \

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH]: Pass -no_pie on SYSTEMSPEC for darwin11
  2011-06-17 11:21 ` IainS
  2011-06-17 13:57   ` Jack Howarth
@ 2011-06-17 15:34   ` Jack Howarth
  2011-06-17 15:55   ` Jack Howarth
  2011-06-18  5:54   ` Jack Howarth
  3 siblings, 0 replies; 10+ messages in thread
From: Jack Howarth @ 2011-06-17 15:34 UTC (permalink / raw)
  To: IainS; +Cc: GCC Patches, Mike Stump

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 <howarth@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 {                                                                 \

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH]: Pass -no_pie on SYSTEMSPEC for darwin11
  2011-06-17 11:21 ` IainS
  2011-06-17 13:57   ` Jack Howarth
  2011-06-17 15:34   ` Jack Howarth
@ 2011-06-17 15:55   ` Jack Howarth
  2011-06-18  5:54   ` Jack Howarth
  3 siblings, 0 replies; 10+ messages in thread
From: Jack Howarth @ 2011-06-17 15:55 UTC (permalink / raw)
  To: IainS; +Cc: GCC Patches, Mike Stump

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 <howarth@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.
>
> -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).

This is from a complete bootstrap with...

BOOT_LDFLAGS += -Wl,-no_pie 

Otherwise you are not duplicating darwin11's -pie linker default. Again it is
essential that you cause ecj1 to be linked with -pie to manifest this problem.
Also note the comments in...

http://gcc.gnu.org/ml/gcc/2011-06/msg00211.html

which argue that there is little to be gained by building gcc as PIE. If that
is valid, my patch achieves that. The problem is that the infrastructure for
gcj and ecj1 currently doesn't allow BOOT_LDFLAGS to be used when ecj1 is built.
Note that if I go back to the build directory (without my patch),  relink
ecjx with -Wl,-no_pie and copy that over the installed ecj1, the crash in gcj
disappears.
               Jack

>
> 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 {                                                                 \

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH]: Pass -no_pie on SYSTEMSPEC for darwin11
  2011-06-17  4:32 [PATCH]: Pass -no_pie on SYSTEMSPEC for darwin11 Jack Howarth
  2011-06-17 11:21 ` IainS
@ 2011-06-17 17:49 ` Mike Stump
  2011-06-17 20:10   ` Jack Howarth
  1 sibling, 1 reply; 10+ messages in thread
From: Mike Stump @ 2011-06-17 17:49 UTC (permalink / raw)
  To: Jack Howarth; +Cc: gcc-patches List, Iain Sandoe, Java Patches

On Jun 16, 2011, at 7:21 PM, 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?

The darwin aspects of this seem right to me.  I'm less familiar with the SYSTEMSPEC bit in libjava, someone want to give a quick comment on if this is the right knob to twist?

Roughly, there are unresolved issues with position independent code with the garbage collector (or was it a problem with some unknown bit in the compiler), and this just turns off a new OS default for java to work around the issue.  I hope that's an at least half way accurate description.  We're aiming to have the default for C be -fpie, but for java, no pie.  For the C compiler, we must build the compiler without -pie in order for PCH to work.  It is reasonable to turn off pie in the java compiler as well.

Jack, do we have a PR number for this?  If so, please include in the changelog in the usual spot.

> 2011-06-16  Jack Howarth <howarth@bromo.med.uc.edu>
> 
> 	* libjava/configure.ac (SYSTEMSPEC): Pass -no_pie for darwin11.
> 	* libjava/configure: Regenerate.
> 
> 
> Index: libjava/configure.ac
> ===================================================================
> --- libjava/configure.ac	(revision 175131)
> +++ libjava/configure.ac	(working copy)
> @@ -898,9 +898,12 @@ case "${host}" in
>         SYSTEMSPEC="-lunicows $SYSTEMSPEC"
>       fi
>     ;;
> -    *-*-darwin[[912]]*)
> +    *-*-darwin9*)
>       SYSTEMSPEC="%{!Zdynamiclib:%{!Zbundle:-allow_stack_execute}}"
>     ;;
> +    *-*-darwin[[12]]*)
> +      SYSTEMSPEC="-no_pie %{!Zdynamiclib:%{!Zbundle:-allow_stack_execute}}"
> +    ;;
>     *)
>       SYSTEMSPEC=
>     ;;

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH]: Pass -no_pie on SYSTEMSPEC for darwin11
  2011-06-17 17:49 ` Mike Stump
@ 2011-06-17 20:10   ` Jack Howarth
  2011-06-18  8:32     ` IainS
  0 siblings, 1 reply; 10+ messages in thread
From: Jack Howarth @ 2011-06-17 20:10 UTC (permalink / raw)
  To: Mike Stump; +Cc: gcc-patches List, Iain Sandoe, Java Patches

On Fri, Jun 17, 2011 at 10:43:07AM -0700, Mike Stump wrote:
> On Jun 16, 2011, at 7:21 PM, 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?
> 
> The darwin aspects of this seem right to me.  I'm less familiar with the SYSTEMSPEC bit in libjava, someone want to give a quick comment on if this is the right knob to twist?

Mike,
   Since SYSTEMSPEC in configure.ac is setting system specific options for libgcj.spec.in, it seemed
the most rational place to append -no_pie to (and we already had a darwin entry in the case statement).
FYI, I also tried a different approach of not appending -no_pie SYSTEMSPEC on darwin but instead using...

Index: config/mh-darwin
===================================================================
--- config/mh-darwin	(revision 175150)
+++ config/mh-darwin	(working copy)
@@ -5,3 +5,4 @@ BOOT_CFLAGS += -mdynamic-no-pic
 
 # Ensure we don't try and use -pie, as it is incompatible with pch.
 BOOT_LDFLAGS += `case ${host} in *-*-darwin[1][1-9]*) echo -Wl,-no_pie ;; esac;`
+LDFLAGS_FOR_TARGET += `case ${host} in *-*-darwin[1][1-9]*) echo -Wl,-no_pie ;; esac;`

while this produced an apparently functional gcj (ecj1), the libjava testsuite showed two additional
regressions compared to my original SYSTEMSPEC approach to the problem...

cat <<'EOF' |
Native configuration is x86_64-apple-darwin11.0.0

		=== libjava tests ===


Running target unix/-m32
FAIL: TestClosureGC run               <================= new failure
FAIL: PR16923.c compilation
FAIL: TestLeak output - source compiled test  <================= new failure

		=== libjava Summary for unix/-m32 ===

# of expected passes		2570
# of unexpected failures	3
# of untested testcases		1

Running target unix/-m64
FAIL: TestClosureGC run     <==================== new failure
FAIL: PR16923 run
FAIL: Throw_2 execution - source compiled test
FAIL: Throw_2 -findirect-dispatch execution - source compiled test
FAIL: Throw_2 -O3 execution - source compiled test
FAIL: Throw_2 -O3 -findirect-dispatch execution - source compiled test
FAIL: TestLeak output - source compiled test   <======================= new failure

		=== libjava Summary for unix/-m64 ===

# of expected passes		2563
# of unexpected failures	7
# of untested testcases		6

		=== libjava Summary ===

# of expected passes		5133
# of unexpected failures	10
# of untested testcases		7

Compiler version: gcc libjava 
Platform: x86_64-apple-darwin11.0.0
configure flags: --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

compared to the results for only passing -no_pie on libgcj.spec...

http://gcc.gnu.org/ml/gcc-testresults/2011-06/msg01853.html


> 
> Roughly, there are unresolved issues with position independent code with the garbage collector (or was it a problem with some unknown bit in the compiler), and this just turns off a new OS default for java to work around the issue.  I hope that's an at least half way accurate description.  We're aiming to have the default for C be -fpie, but for java, no pie.  For the C compiler, we must build the compiler without -pie in order for PCH to work.  It is reasonable to turn off pie in the java compiler as well.
> 
> Jack, do we have a PR number for this?  If so, please include in the changelog in the usual spot.

I plan on opening a PR shortly, but I was hoping to be able to reproduce the same failures under linux
using a bootstrap with the compiler defaulted to -fPIC code generation and the inverse change applied
to linux of...

BOOT_LDFLAGS += -pie

to see how its boehm-gc and libjava testsuite results were impacted.
                        Jack

> 
> > 2011-06-16  Jack Howarth <howarth@bromo.med.uc.edu>
> > 
> > 	* libjava/configure.ac (SYSTEMSPEC): Pass -no_pie for darwin11.
> > 	* libjava/configure: Regenerate.
> > 
> > 
> > Index: libjava/configure.ac
> > ===================================================================
> > --- libjava/configure.ac	(revision 175131)
> > +++ libjava/configure.ac	(working copy)
> > @@ -898,9 +898,12 @@ case "${host}" in
> >         SYSTEMSPEC="-lunicows $SYSTEMSPEC"
> >       fi
> >     ;;
> > -    *-*-darwin[[912]]*)
> > +    *-*-darwin9*)
> >       SYSTEMSPEC="%{!Zdynamiclib:%{!Zbundle:-allow_stack_execute}}"
> >     ;;
> > +    *-*-darwin[[12]]*)
> > +      SYSTEMSPEC="-no_pie %{!Zdynamiclib:%{!Zbundle:-allow_stack_execute}}"
> > +    ;;
> >     *)
> >       SYSTEMSPEC=
> >     ;;

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH]: Pass -no_pie on SYSTEMSPEC for darwin11
  2011-06-17 11:21 ` IainS
                     ` (2 preceding siblings ...)
  2011-06-17 15:55   ` Jack Howarth
@ 2011-06-18  5:54   ` Jack Howarth
  2011-06-18  8:57     ` IainS
  3 siblings, 1 reply; 10+ messages in thread
From: Jack Howarth @ 2011-06-18  5:54 UTC (permalink / raw)
  To: IainS; +Cc: GCC Patches, Mike Stump

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 <howarth@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.
>
> -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).

Iain,
   This change should be unncessary since -pie on the linker only operates
on executables (hence the name PIE).
              Jack

>
> 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 {                                                                 \

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH]: Pass -no_pie on SYSTEMSPEC for darwin11
  2011-06-17 20:10   ` Jack Howarth
@ 2011-06-18  8:32     ` IainS
  0 siblings, 0 replies; 10+ messages in thread
From: IainS @ 2011-06-18  8:32 UTC (permalink / raw)
  To: Mike Stump; +Cc: Jack Howarth, gcc-patches List, Java Patches

Hi Mike, Jack,

On 17 Jun 2011, at 20:24, Jack Howarth wrote:

> On Fri, Jun 17, 2011 at 10:43:07AM -0700, Mike Stump wrote:
>> On Jun 16, 2011, at 7:21 PM, 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?
>>
>> The darwin aspects of this seem right to me.  I'm less familiar  
>> with the SYSTEMSPEC bit in libjava, someone want to give a quick  
>> comment on if this is the right knob to twist?
>
>   Since SYSTEMSPEC in configure.ac is setting system specific  
> options for libgcj.spec.in, it seemed
> the most rational place to append -no_pie to (and we already had a  
> darwin entry in the case statement).
> FYI, I also tried a different approach of not appending -no_pie  
> SYSTEMSPEC on darwin but instead using...

maybe I need more coffee .. and the gcc gathering was very sociable...  
but...

... It seems to me that switching pie off in libjava spec == switching  
pie off for every java program.

(i.e. it doesn't seem equivalent to BOOT_CFLAGS, but maybe I'm still  
missing something).

>> Roughly, there are unresolved issues with position independent code  
>> with the garbage collector (or was it a problem with some unknown  
>> bit in the compiler), and this just turns off a new OS default for  
>> java to work around the issue.  I hope that's an at least half way  
>> accurate description.  We're aiming to have the default for C be - 
>> fpie, but for java, no pie.  For the C compiler, we must build the  
>> compiler without -pie in order for PCH to work.  It is reasonable  
>> to turn off pie in the java compiler as well.
>>
>> Jack, do we have a PR number for this?  If so, please include in  
>> the changelog in the usual spot.
>
> I plan on opening a PR shortly, but I was hoping to be able to  
> reproduce the same failures under linux
> using a bootstrap with the compiler defaulted to -fPIC code  
> generation and the inverse change applied
> to linux of...

The thing that is not clear is this.

libjava (and boehm-gc) with pie passes on d9 and d10 (modulo a test- 
suite related kludge); so it doesn't seem that there's a fundamental  
problem.
(c.f. PCH, which won't work with pie, by definition from its design).

AFAIR ecj1 is not involved in the libjava tests - because they don't  
actually compile from .java.

(I'm not debating that there is a problem with ecj1 - but maybe that  
needs to be solved in the explicit build instructions for that  
executable).

----

So is this 'fix' a work-around for a tool bug... or is there really a  
lurking problem in boehm-gc/libjava that is uncovered by darwin11?

we seem to be switching off pie without actually pointing at the  
reason for doing so...

Iain

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH]: Pass -no_pie on SYSTEMSPEC for darwin11
  2011-06-18  5:54   ` Jack Howarth
@ 2011-06-18  8:57     ` IainS
  0 siblings, 0 replies; 10+ messages in thread
From: IainS @ 2011-06-18  8:57 UTC (permalink / raw)
  To: Jack Howarth; +Cc: GCC Patches, Mike Stump

Hi Jack,

On 18 Jun 2011, at 03:57, Jack Howarth wrote:

> On Fri, Jun 17, 2011 at 12:04:34PM +0100, IainS wrote:
>> Hi Jack,
>> ===
>> ****
>> kludge to suppress pie for for dylibs (use in place of the darwin9.h
>> hunk from the attachment on PR49371).
>
> Iain,
>   This change should be unncessary since -pie on the linker only  
> operates
> on executables (hence the name PIE).

On darwin < 11 .. which don't default to linking pie:

As stated, it's a kludge to allow fpie to be put as a test-suite  
option...
... since the options are passed verbatim to library builds, all the  
dylib builds fail otherwise ...

if there is an alternate way of filtering 'fpie/fPIE' out of dylib  
builds, that could be more globally applied the to the test suite,  
that would be a good fix to make.

(the kludge is expedient to test the hypothesis that pie works with  
libjava on darwin 9 & 10 -- FAOD: I am not suggesting it for trunk)...

Iain

>> 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  
>> {                                                                 \

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-06-18  7:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-17  4:32 [PATCH]: Pass -no_pie on SYSTEMSPEC for darwin11 Jack Howarth
2011-06-17 11:21 ` IainS
2011-06-17 13:57   ` Jack Howarth
2011-06-17 15:34   ` Jack Howarth
2011-06-17 15:55   ` Jack Howarth
2011-06-18  5:54   ` Jack Howarth
2011-06-18  8:57     ` IainS
2011-06-17 17:49 ` Mike Stump
2011-06-17 20:10   ` Jack Howarth
2011-06-18  8:32     ` IainS

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).