From 12e8645889e985a56ac2d3e8d8b8b081a10d54d0 Mon Sep 17 00:00:00 2001 From: micha Date: Thu, 2 Nov 2006 21:19:24 +0000 Subject: [PATCH] * fix cross-compiling from i386/linux git-svn-id: trunk@5186 - --- compiler/fpcdefs.inc | 3 - compiler/globals.pas | 2 + compiler/pmodules.pas | 10 ++-- compiler/systems/t_linux.pas | 110 +++++++++++------------------------ 4 files changed, 42 insertions(+), 83 deletions(-) diff --git a/compiler/fpcdefs.inc b/compiler/fpcdefs.inc index 84ccd40b0e..43eaac8b1b 100644 --- a/compiler/fpcdefs.inc +++ b/compiler/fpcdefs.inc @@ -45,9 +45,6 @@ {$define SUPPORT_MMX} {$define cpumm} {$define fewintregisters} - {$ifdef linux} - {$define has_internal_sysinit} - {$endif} {$endif i386} {$ifdef x86_64} diff --git a/compiler/globals.pas b/compiler/globals.pas index 62ab397ffb..f791f0853e 100644 --- a/compiler/globals.pas +++ b/compiler/globals.pas @@ -68,6 +68,8 @@ interface macmodeswitches : tmodeswitches= [m_mac,m_all,m_result,m_cvar_support,m_mac_procvar]; + internal_sysinit_systems = [system_i386_linux]; + { maximum nesting of routines } maxnesting = 32; diff --git a/compiler/pmodules.pas b/compiler/pmodules.pas index 39bd40185e..9928230ae6 100644 --- a/compiler/pmodules.pas +++ b/compiler/pmodules.pas @@ -1395,12 +1395,12 @@ implementation { do we need to add the variants unit? } maybeloadvariantsunit; -{$ifdef has_internal_sysinit} linker.initsysinitunitname; - - { add start/halt unit } - AddUnit('si_'+linker.sysinitunit); -{$endif} + if target_info.system in internal_sysinit_systems then + begin + { add start/halt unit } + AddUnit('si_'+linker.sysinitunit); + end; {$ifdef arm} { Insert .pdata section for arm-wince. diff --git a/compiler/systems/t_linux.pas b/compiler/systems/t_linux.pas index ffe0c0180c..3b6b0a34bf 100644 --- a/compiler/systems/t_linux.pas +++ b/compiler/systems/t_linux.pas @@ -45,17 +45,16 @@ interface tlinkerlinux=class(texternallinker) private libctype:(libc5,glibc2,glibc21,uclibc); -{$ifdef has_internal_sysinit} + cprtobj, + gprtobj, + prtobj : string[80]; reorder : boolean; linklibc: boolean; -{$endif} Function WriteResponseFile(isdll:boolean) : Boolean; public constructor Create;override; procedure SetDefaultInfo;override; -{$ifdef has_internal_sysinit} procedure InitSysInitUnitName;override; -{$endif} function MakeExecutable:boolean;override; function MakeSharedLibrary:boolean;override; function postprocessexecutable(const fn : string;isdll:boolean):boolean; @@ -314,8 +313,6 @@ Begin end; End; -{$ifdef has_internal_sysinit} - Procedure TLinkerLinux.InitSysInitUnitName; var csysinitunit, @@ -335,63 +332,6 @@ begin sysinitunit:='dll'; csysinitunit:='dll'; gsysinitunit:='dll'; - end - else - begin - sysinitunit:='prc'; - case libctype of - glibc21: - begin - csysinitunit:='c21'; - gsysinitunit:='c21g'; - end; - uclibc: - begin - csysinitunit:='uc'; - gsysinitunit:='ucg'; - end - else - csysinitunit:='c'; - gsysinitunit:='g'; - end; - end; - if cs_profile in current_settings.moduleswitches then - begin - sysinitunit:=gsysinitunit; - linklibc:=true; - end - else - begin - if linklibc then - sysinitunit:=csysinitunit; - end; -end; - -{$endif} - -Function TLinkerLinux.WriteResponseFile(isdll:boolean) : Boolean; -Var - linkres : TLinkRes; - i : longint; -{$ifndef has_internal_sysinit} - cprtobj, - gprtobj, - prtobj : string[80]; - reorder, - linklibc : boolean; -{$endif} - HPath : TStringListItem; - s,s1,s2 : string; - found1, - found2 : boolean; -begin - result:=False; -{ set special options for some targets } -{$ifndef has_internal_sysinit} - linklibc:=(SharedLibFiles.Find('c')<>nil); - reorder := linklibc and ReOrderEntries; - if isdll then - begin prtobj:='dllprt0'; cprtobj:='dllprt0'; gprtobj:='dllprt0'; @@ -399,39 +339,61 @@ begin else begin prtobj:='prt0'; + sysinitunit:='prc'; case libctype of glibc21: begin cprtobj:='cprt21'; gprtobj:='gprt21'; + csysinitunit:='c21'; + gsysinitunit:='c21g'; end; uclibc: begin cprtobj:='ucprt0'; gprtobj:='ugprt0'; + csysinitunit:='uc'; + gsysinitunit:='ucg'; end else cprtobj:='cprt0'; gprtobj:='gprt0'; + csysinitunit:='c'; + gsysinitunit:='g'; end; end; -{$endif} if cs_profile in current_settings.moduleswitches then begin -{$ifndef has_internal_sysinit} prtobj:=gprtobj; -{$endif} - if not(libctype in [glibc2,glibc21]) then - AddSharedLibrary('gmon'); - AddSharedLibrary('c'); + sysinitunit:=gsysinitunit; linklibc:=true; end else begin -{$ifndef has_internal_sysinit} if linklibc then - prtobj:=cprtobj; -{$endif} + begin + prtobj:=cprtobj; + sysinitunit:=csysinitunit; + end; + end; +end; + +Function TLinkerLinux.WriteResponseFile(isdll:boolean) : Boolean; +Var + linkres : TLinkRes; + i : longint; + HPath : TStringListItem; + s,s1,s2 : string; + found1, + found2 : boolean; +begin + result:=False; +{ set special options for some targets } + if cs_profile in current_settings.moduleswitches then + begin + if not(libctype in [glibc2,glibc21]) then + AddSharedLibrary('gmon'); + AddSharedLibrary('c'); end; { Open link.res file } @@ -453,11 +415,9 @@ begin end; StartSection('INPUT('); -{$ifndef has_internal_sysinit} { add objectfiles, start with prt0 always } - if prtobj<>'' then + if not (target_info.system in internal_sysinit_systems) and (prtobj<>'') then AddFileName(maybequoted(FindObjectFile(prtobj,'',false))); -{$endif} { try to add crti and crtbegin if linking to C } if linklibc then begin