diff --git a/compiler/ncnv.pas b/compiler/ncnv.pas index 20942a4c0c..4a58772252 100644 --- a/compiler/ncnv.pas +++ b/compiler/ncnv.pas @@ -2947,7 +2947,7 @@ implementation end; notn: result:=docheckremoveinttypeconvs(tunarynode(n).left); - addn,muln,divn,modn,andn: + addn,muln,divn,modn,andn,shln: begin if n.nodetype in [divn,modn] then gotdivmod:=true; @@ -2986,7 +2986,7 @@ implementation tempnode: ttempcreatenode; begin case n.nodetype of - subn,addn,muln,divn,modn,xorn,andn,orn: + subn,addn,muln,divn,modn,xorn,andn,orn,shln: begin exclude(n.flags,nf_internal); if not forceunsigned and @@ -3341,20 +3341,20 @@ implementation to 64 bit } if (resultdef.size <= 4) and is_64bitint(left.resultdef) and - (left.nodetype in [subn,addn,muln,divn,modn,xorn,andn,orn,notn,unaryminusn]) and + (left.nodetype in [subn,addn,muln,divn,modn,xorn,andn,orn,notn,unaryminusn,shln]) and checkremovebiginttypeconvs(left,foundsint,[s8bit,u8bit,s16bit,u16bit,s32bit,u32bit],int64(low(longint)),high(cardinal)) then doremoveinttypeconvs(left,generrordef,not foundsint,s32inttype,u32inttype); {$if defined(cpu16bitalu)} if (resultdef.size <= 2) and (is_32bitint(left.resultdef) or is_64bitint(left.resultdef)) and - (left.nodetype in [subn,addn,muln,divn,modn,xorn,andn,orn,notn,unaryminusn]) and + (left.nodetype in [subn,addn,muln,divn,modn,xorn,andn,orn,notn,unaryminusn,shln]) and checkremovebiginttypeconvs(left,foundsint,[s8bit,u8bit,s16bit,u16bit],int64(low(smallint)),high(word)) then doremoveinttypeconvs(left,generrordef,not foundsint,s16inttype,u16inttype); {$endif defined(cpu16bitalu)} {$if defined(cpu8bitalu)} if (resultdef.sizeOS) then + UseBinutilsPrefix:=true; + if (Defaults.SourceCPU<>CPU) then + begin + { we need to accept 32<->64 conversion } + { expect for OpenBSD which does not allow this } + if not( + ((Defaults.SourceCPU=aarch64) and (CPU=arm)) or + ((Defaults.SourceCPU=powerpc64) and (CPU=powerpc)) or + ((Defaults.SourceCPU=x86_64) and (CPU=i386)) or + ((Defaults.SourceCPU=riscv64) and (CPU=riscv32)) or + ((Defaults.SourceCPU=sparc64) and (CPU=sparc)) or + ((CPU=aarch64) and (Defaults.SourceCPU=arm)) or + ((CPU=powerpc64) and (Defaults.SourceCPU=powerpc)) or + ((CPU=x86_64) and (Defaults.SourceCPU=i386)) or + ((CPU=riscv64) and (Defaults.SourceCPU=riscv32)) or + ((CPU=sparc64) and (Defaults.SourceCPU=sparc)) + ) or (Defaults.SourceOS=openbsd) then + UseBinutilsPrefix:=true; + end; + if not UseBinutilsPrefix then + CrossPrefix:='' + else if Sysutils.GetEnvironmentVariable('BINUTILSPREFIX')<>'' then + CrossPrefix:=Sysutils.GetEnvironmentVariable('BINUTILSPREFIX') + else + CrossPrefix:=CPUToString(CPU)+'-'+OSToString(OS)+'-'; if OS in [freebsd, openbsd, dragonfly] then - result := '/usr/local/lib' + begin + if CrossPrefix='' then + result := '/usr/local/lib' + end else if OS = netbsd then - result := '/usr/pkg/lib' + begin + if CrossPrefix='' then + result := '/usr/pkg/lib' + end else if OS = linux then case CPU of i386: result := GetGccDirArch('cpui386','-m32'); @@ -5017,6 +5064,27 @@ begin OS:=StringToOS({$I %FPCTARGETOS%}); if FCompilerVersion='' then FCompilerVersion:={$I %FPCVERSION%}; +{$endif HAS_UNIT_PROCESS} + end; + if (FSourceOS=osNone) then + begin +{$ifdef HAS_UNIT_PROCESS} + // Detect compiler version/target from -i option + infosl:=TStringList.Create; + infosl.Delimiter:=' '; + infosl.DelimitedText:=GetCompilerInfo(GetCompiler,'-iDWSPSO', False, True); + if infosl.Count<>4 then + Raise EInstallerError.Create(SErrInvalidFPCInfo); + FCompilerDate:=infosl[0]; + FFullCompilerVersion:=infosl[1]; + FSourceCPU:=StringToCPU(infosl[2]); + FSourceOS:=StringToOS(infosl[3]); +{$else HAS_UNIT_PROCESS} + // Defaults taken from compiler used to build fpmake + FSourceCPU:=StringToCPU({$I %FPCTARGETCPU%}); + FSourceOS:=StringToOS({$I %FPCTARGETOS%}); + FFullCompilerVersion:={$I %FPCFULLVERSION%}; + FCompilerDate:={$I %FPCDATE%}; {$endif HAS_UNIT_PROCESS} end; end;