This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] omit -lcrt1.10.6.o and pass -no_new_main with -pg on darwin >= 10.8
- From: Jack Howarth <howarth at bromo dot med dot uc dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Cc: mikestump at comcast dot net, iains at gcc dot gnu dot org
- Date: Fri, 25 May 2012 09:06:51 -0400
- Subject: [PATCH] omit -lcrt1.10.6.o and pass -no_new_main with -pg on darwin >= 10.8
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. */