public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] omit -lcrt1.10.6.o and pass -no_new_main with -pg on darwin >= 10.8
@ 2012-05-25 13:07 Jack Howarth
  2012-05-25 18:49 ` Mike Stump
  0 siblings, 1 reply; 2+ messages in thread
From: Jack Howarth @ 2012-05-25 13:07 UTC (permalink / raw)
  To: gcc-patches; +Cc: mikestump, iains

   The attached patch limits the linkage of -lcrt1.10.6.o to darwin10 and darwin11
since its usage is deprecated in the 10.8sdk. The patch also solves radr://11491405,
"-pg broken for -mmacosx-version-min=10.8"...

19-May-2012 11:10 PM Jack Howarth:
Summary: The default  -mmacosx-version-min=10.8 under Xcode 4.4 breaks a number of FSF gcc tests which rely on -pg. such as...

FAIL: gcc.dg/nest.c execution test
FAIL: gcc.dg/nested-func-4.c execution test

Steps to Reproduce:
The attached compressed archive for xcodebug_pg_10.8.tar.bz2 contains the files from compiling these test cases with...

gcc-fsf-4.7 /sw/src/fink.build/gcc47-4.7.1-1000/gcc-4.7-20120518/gcc/testsuite/gcc.dg/nest.c --save-temps -v  -O2 -pg -lm -m32 -o ./nest.exe

and

gcc-fsf-4.7 /sw/src/fink.build/gcc47-4.7.1-1000/gcc-4.7-20120518/gcc/testsuite/gcc.dg/nested-func-4.c -v --save-temps -pg -lm -m32 -o ./nested-func-4.exe

as well as shell scripts for bad_runs.sh and bad_runs2.sh to execute each of the miscompiled binaries against the bundled FSF gcc shared library for libgcc_s.1.dylib.

Expected Results:
The nest.exe and nested-func-4.exe test cases should execute without errors as they do when built with the  -mmacosx-version-min=10.7 flag.

Actual Results:
In both cases, these test case fail with the error...

dyld: no valid entry point

The patch implements the recommended approach from the darwin linker developer of passing -no_new_main to the linker
when targeting 10.8 or later which tells the linker to look for "start" instead of "_main". Otherwise the linker sets up
_main as the entry point and _moninit is never called, resulting in a runtime error. Bootstrap and regression tested
on x86_64-apple-darwin12. 

http://gcc.gnu.org/ml/gcc-testresults/2012-05/msg02331.html

Okay for gcc trunk and later gcc-4_7-branch and gcc-4_6-branch?
            Jack


2012-05-24  Jack Howarth  <howarth@bromo.med.uc.edu>

	* config/darwin.h (STARTFILE_SPEC): Use -no_new_main with -lgcrt1.o
	on Darwin >= 12.
	(DARWIN_CRT1_SPEC): Use -lcrt1.10.6.o when Darwin >= 10 and < 12.

--- gcc/config/darwin.h	(revision 187856)
+++ gcc/config/darwin.h	(working copy)
@@ -356,7 +356,9 @@ extern GTY(()) int darwin_ms_struct;
      %{!Zbundle:%{pg:%{static:-lgcrt0.o}				    \
                      %{!static:%{object:-lgcrt0.o}			    \
                                %{!object:%{preload:-lgcrt0.o}		    \
-                                 %{!preload:-lgcrt1.o %(darwin_crt2)}}}}    \
+                                 %{!preload:-lgcrt1.o                       \
+                                 %:version-compare(>= 10.8 mmacosx-version-min= -no_new_main) \
+                                 %(darwin_crt2)}}}}    \
                 %{!pg:%{static:-lcrt0.o}				    \
                       %{!static:%{object:-lcrt0.o}			    \
                                 %{!object:%{preload:-lcrt0.o}		    \
@@ -379,7 +381,7 @@ extern GTY(()) int darwin_ms_struct;
 #define DARWIN_CRT1_SPEC						\
   "%:version-compare(!> 10.5 mmacosx-version-min= -lcrt1.o)		\
    %:version-compare(>< 10.5 10.6 mmacosx-version-min= -lcrt1.10.5.o)	\
-   %:version-compare(>= 10.6 mmacosx-version-min= -lcrt1.10.6.o)	\
+   %:version-compare(>< 10.6 10.8 mmacosx-version-min= -lcrt1.10.6.o)	\
    %{fgnu-tm: -lcrttms.o}"
 
 /* Default Darwin ASM_SPEC, very simple.  */

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

* Re: [PATCH] omit -lcrt1.10.6.o and pass -no_new_main with -pg on darwin >= 10.8
  2012-05-25 13:07 [PATCH] omit -lcrt1.10.6.o and pass -no_new_main with -pg on darwin >= 10.8 Jack Howarth
@ 2012-05-25 18:49 ` Mike Stump
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Stump @ 2012-05-25 18:49 UTC (permalink / raw)
  To: Jack Howarth; +Cc: gcc-patches, iains

On May 25, 2012, at 6:06 AM, Jack Howarth wrote:
>   The attached patch limits the linkage of -lcrt1.10.6.o to darwin10 and darwin11
> since its usage is deprecated in the 10.8sdk.

Ok.

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

end of thread, other threads:[~2012-05-25 18:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-25 13:07 [PATCH] omit -lcrt1.10.6.o and pass -no_new_main with -pg on darwin >= 10.8 Jack Howarth
2012-05-25 18:49 ` Mike Stump

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