From a28917086bde6321f6ee3a0aac0dbef708e7b356 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Mon, 14 Oct 2013 21:38:38 +0000 Subject: [PATCH] * updated *crt1* linking logic for OS X 10.8+: o don't link by default o when generating profiling info, link gcrt1.o and specify "-no_new_main" linker parameter * don't use version-specific crt1.o files when targetting the iPhoneSimulator platform * don't link a crt1.o file when targetting iOS 6 or later (all info from http://llvm.org/svn/llvm-project/cfe/trunk/lib/Driver/Tools.cpp ) git-svn-id: trunk@25789 - --- compiler/systems/t_bsd.pas | 44 ++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/compiler/systems/t_bsd.pas b/compiler/systems/t_bsd.pas index 5c9a8f7e50..636e715c7e 100644 --- a/compiler/systems/t_bsd.pas +++ b/compiler/systems/t_bsd.pas @@ -230,6 +230,9 @@ begin begin if not(cs_profile in current_settings.moduleswitches) then begin + { 10.8 and later: no crt1.* } + if CompareVersionStrings(MacOSXVersionMin,'10.8')>=0 then + exit(''); { x86: crt1.10.6.o -> crt1.10.5.o -> crt1.o } { others: crt1.10.5 -> crt1.o } {$if defined(i386) or defined(x86_64)} @@ -238,17 +241,28 @@ begin {$endif} if CompareVersionStrings(MacOSXVersionMin,'10.5')>=0 then exit('crt1.10.5.o'); - { iOS/simulator: crt1.3.1.o -> crt1.o } -{$if defined(i386) or defined(arm)} - if {$ifdef i386}(target_info.system=system_i386_iphonesim) and{$endif} - (CompareVersionStrings(iPhoneOSVersionMin,'3.1')>=0) then - exit('crt1.3.1.o'); +{$if defined(arm)} + { iOS: + iOS 6 and later: nothing + iOS 3.1 - 5.x: crt1.3.1.o + pre-iOS 3.1: crt1.o + } + if (CompareVersionStrings(iPhoneOSVersionMin,'6.0')>=0) then + exit(''); + if (CompareVersionStrings(iPhoneOSVersionMin,'3.1')>=0) then + exit('crt1.3.1.o'); {$endif} { nothing special -> default } result:='crt1.o'; end else - result:='gcrt1.o'; + begin + result:='gcrt1.o'; + { 10.8 and later: tell the linker to use 'start' instead of "_main" + as entry point } + if CompareVersionStrings(MacOSXVersionMin,'10.8')>=0 then + Info.ExeCmd[1]:=Info.ExeCmd[1]+' -no_new_main'; + end; end else begin @@ -258,11 +272,10 @@ begin >= 10.6: nothing } if CompareVersionStrings(MacOSXVersionMin,'10.6')>=0 then exit(''); - { iOS/simulator: < 3.1: bundle1.o - >= 3.1: nothing } -{$if defined(i386) or defined(arm)} - if {$ifdef i386}(target_info.system=system_i386_iphonesim) and{$endif} - (CompareVersionStrings(iPhoneOSVersionMin,'3.1')>=0) then + { iOS: < 3.1: bundle1.o + >= 3.1: nothing } +{$if defined(arm)} + if (CompareVersionStrings(iPhoneOSVersionMin,'3.1')>=0) then exit(''); {$endif} result:='bundle1.o'; @@ -277,11 +290,10 @@ begin exit(''); if CompareVersionStrings(MacOSXVersionMin,'10.5')>=0 then exit('dylib1.10.5.o'); - { iOS/simulator: < 3.1: dylib1.o - >= 3.1: nothing } -{$if defined(i386) or defined(arm)} - if {$ifdef i386}(target_info.system=system_i386_iphonesim) and{$endif} - (CompareVersionStrings(iPhoneOSVersionMin,'3.1')>=0) then + { iOS: < 3.1: dylib1.o + >= 3.1: nothing } +{$if defined(arm)} + if (CompareVersionStrings(iPhoneOSVersionMin,'3.1')>=0) then exit(''); {$endif} result:='dylib1.o';