chore: remove dead {$IFDEF FPC} blocks, --cache-dir, and migrate_full.py
The compiler has been self-hosting since v0.7.0 and FPC is no longer
part of the toolchain. Remove the last FPC-conditional code paths:
- Blaise.pas: drop CacheKeyForFile, LoadCachedIR, StoreCachedIR and
both {$IFDEF FPC} whole-program IR cache blocks; remove --cache-dir
flag and CacheDir/UnitIR/UnitName/UnitPath locals; collapse the
ReadProcessChunk FPC/Blaise fork to the Blaise implementation only;
drop the poUsePipes/poStderrToOutPut Options block.
- tools/migrate_full.py: deleted — the Python migration analyser is no
longer needed now that the toolchain is fully Blaise-native.
This commit is contained in:
parent
8136fcaff7
commit
506ada7916
|
|
@ -45,7 +45,6 @@ begin
|
|||
WriteLn(' --target <id> linux-x86_64 (default), macos-arm64');
|
||||
WriteLn(' --emit-ir Print QBE IR to stdout and exit');
|
||||
WriteLn(' --debug-opdf Emit OPDF debug info (.opdf.s companion file)');
|
||||
WriteLn(' --cache-dir <dir> Directory for per-unit IR cache (speeds up incremental builds)');
|
||||
WriteLn('');
|
||||
WriteLn('Configuration:');
|
||||
WriteLn(' Unit search paths can also be set in blaise.cfg (one unit-path=<dir>');
|
||||
|
|
@ -109,7 +108,7 @@ begin
|
|||
else if StrHead(Arg, 3) = '-FE' then
|
||||
OutDir := StrCopyTail(Arg, 3)
|
||||
else if StrHead(Arg, 3) = '-FU' then
|
||||
{ unit cache directory — ignored in Phase 1 }
|
||||
{ unit output directory — ignored }
|
||||
else if StrHead(Arg, 3) = '-Fu' then
|
||||
SearchPaths.Add(StrCopyTail(Arg, 3))
|
||||
else if StrHead(Arg, 2) = '-o' then
|
||||
|
|
@ -182,8 +181,7 @@ function ParseArgs(
|
|||
out OutputFile: string;
|
||||
out EmitIR: Boolean;
|
||||
out OPDFEnabled: Boolean;
|
||||
out SearchPaths: TStringList;
|
||||
out CacheDir: string): Boolean;
|
||||
out SearchPaths: TStringList): Boolean;
|
||||
var
|
||||
I: Integer;
|
||||
Arg: string;
|
||||
|
|
@ -193,7 +191,6 @@ begin
|
|||
OutputFile := '';
|
||||
EmitIR := False;
|
||||
OPDFEnabled := False;
|
||||
CacheDir := '';
|
||||
SearchPaths := TStringList.Create;
|
||||
|
||||
I := 1;
|
||||
|
|
@ -215,11 +212,6 @@ begin
|
|||
Inc(I);
|
||||
SearchPaths.Add(ParamStr(I));
|
||||
end
|
||||
else if (Arg = '--cache-dir') and (I < ParamCount) then
|
||||
begin
|
||||
Inc(I);
|
||||
CacheDir := ParamStr(I);
|
||||
end
|
||||
else if Arg = '--emit-ir' then
|
||||
EmitIR := True
|
||||
else if Arg = '--debug-opdf' then
|
||||
|
|
@ -256,100 +248,10 @@ begin
|
|||
Result := True;
|
||||
end;
|
||||
|
||||
{$IFDEF FPC}
|
||||
{ Returns a cache key string for the given source file: "<mtime>:<size>".
|
||||
Returns '' if the file cannot be stat'd. }
|
||||
function CacheKeyForFile(const APath: string): string;
|
||||
var
|
||||
SR: TSearchRec;
|
||||
begin
|
||||
Result := '';
|
||||
if FindFirst(APath, faAnyFile, SR) = 0 then
|
||||
begin
|
||||
Result := IntToStr(SR.Time) + ':' + IntToStr(SR.Size);
|
||||
FindClose(SR);
|
||||
end;
|
||||
end;
|
||||
|
||||
{ Try to load cached IR for a unit. Returns '' on cache miss. }
|
||||
function LoadCachedIR(const ACacheDir, AUnitName, ASourcePath: string): string;
|
||||
var
|
||||
IRFile, KeyFile: string;
|
||||
StoredKey, CurrentKey: string;
|
||||
SL: TStringList;
|
||||
begin
|
||||
Result := '';
|
||||
if ACacheDir = '' then Exit;
|
||||
IRFile := IncludeTrailingPathDelimiter(ACacheDir) + AUnitName + '.ssa';
|
||||
KeyFile := IRFile + '.key';
|
||||
if not FileExists(IRFile) or not FileExists(KeyFile) then Exit;
|
||||
CurrentKey := CacheKeyForFile(ASourcePath);
|
||||
if CurrentKey = '' then Exit;
|
||||
SL := TStringList.Create;
|
||||
try
|
||||
SL.LoadFromFile(KeyFile);
|
||||
StoredKey := Trim(SL.Text);
|
||||
finally
|
||||
SL.Free;
|
||||
end;
|
||||
if StoredKey <> CurrentKey then Exit;
|
||||
SL := TStringList.Create;
|
||||
try
|
||||
SL.LoadFromFile(IRFile);
|
||||
Result := SL.Text;
|
||||
finally
|
||||
SL.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
{ Write IR and its cache key to the cache directory. }
|
||||
procedure StoreCachedIR(const ACacheDir, AUnitName, ASourcePath, AIR: string);
|
||||
var
|
||||
IRFile, KeyFile: string;
|
||||
Key: string;
|
||||
SL: TStringList;
|
||||
begin
|
||||
if ACacheDir = '' then Exit;
|
||||
if not ForceDirectories(ACacheDir) then Exit;
|
||||
Key := CacheKeyForFile(ASourcePath);
|
||||
if Key = '' then Exit;
|
||||
IRFile := IncludeTrailingPathDelimiter(ACacheDir) + AUnitName + '.ssa';
|
||||
KeyFile := IRFile + '.key';
|
||||
SL := TStringList.Create;
|
||||
try
|
||||
SL.Text := AIR;
|
||||
SL.SaveToFile(IRFile);
|
||||
finally
|
||||
SL.Free;
|
||||
end;
|
||||
SL := TStringList.Create;
|
||||
try
|
||||
SL.Text := Key;
|
||||
SL.SaveToFile(KeyFile);
|
||||
finally
|
||||
SL.Free;
|
||||
end;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
function ReadProcessChunk(AProc: TProcess): string;
|
||||
{$IFDEF FPC}
|
||||
const
|
||||
BufSize = 4096;
|
||||
var
|
||||
Buf: array[0..4095] of Byte;
|
||||
N: Integer;
|
||||
begin
|
||||
N := AProc.Output.Read(Buf, BufSize);
|
||||
Result := '';
|
||||
if N > 0 then
|
||||
Result := StrHead(string(PChar(@Buf[0])), N);
|
||||
end;
|
||||
{$ELSE}
|
||||
begin
|
||||
Result := AProc.ReadOutput
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
function RunProcess(const AExe: string; AArgs: TStringList;
|
||||
out AOutput: string): Integer;
|
||||
|
|
@ -361,9 +263,6 @@ begin
|
|||
Proc := TProcess.Create(nil);
|
||||
try
|
||||
Proc.Executable := AExe;
|
||||
{$IFDEF FPC}
|
||||
Proc.Options := [poUsePipes, poStderrToOutPut];
|
||||
{$ENDIF}
|
||||
for I := 0 to AArgs.Count - 1 do
|
||||
Proc.Parameters.Add(AArgs.Strings[I]);
|
||||
Proc.Execute;
|
||||
|
|
@ -458,7 +357,6 @@ var
|
|||
EmitIR: Boolean;
|
||||
OPDFEnabled: Boolean;
|
||||
OPDFAsmFile: string;
|
||||
CacheDir: string;
|
||||
Source: TStringList;
|
||||
Lexer: TLexer;
|
||||
Parser: TParser;
|
||||
|
|
@ -470,16 +368,12 @@ var
|
|||
Units: TObjectList;
|
||||
I: Integer;
|
||||
IR: string;
|
||||
UnitIR: string;
|
||||
IRFile: string;
|
||||
UnitName: string;
|
||||
UnitPath: string;
|
||||
|
||||
begin
|
||||
SearchPaths := nil;
|
||||
OPDFEnabled := False;
|
||||
OPDFAsmFile := '';
|
||||
CacheDir := '';
|
||||
if IsFPCStyleInvocation then
|
||||
begin
|
||||
if not ParseFPCArgs(SourceFile, OutputFile, SearchPaths, OPDFEnabled) then
|
||||
|
|
@ -491,7 +385,7 @@ begin
|
|||
end
|
||||
else
|
||||
begin
|
||||
if not ParseArgs(SourceFile, OutputFile, EmitIR, OPDFEnabled, SearchPaths, CacheDir) then
|
||||
if not ParseArgs(SourceFile, OutputFile, EmitIR, OPDFEnabled, SearchPaths) then
|
||||
begin
|
||||
PrintUsage;
|
||||
Halt(1);
|
||||
|
|
@ -578,83 +472,21 @@ begin
|
|||
end;
|
||||
|
||||
try
|
||||
{$IFDEF FPC}
|
||||
{ IR caching — FPC-only; uses TSearchRec etc. not available under Blaise }
|
||||
if CacheDir <> '' then
|
||||
begin
|
||||
UnitIR := CacheKeyForFile(SourceFile);
|
||||
if Units <> nil then
|
||||
for I := 0 to Units.Count - 1 do
|
||||
begin
|
||||
UnitName := TUnit(Units.Items[I]).Name;
|
||||
UnitPath := TUnit(Units.Items[I]).SourceFile;
|
||||
UnitIR := UnitIR + '|' + UnitName + ':' + CacheKeyForFile(UnitPath);
|
||||
end;
|
||||
|
||||
IRFile := IncludeTrailingPathDelimiter(CacheDir) + '__full__.ssa';
|
||||
Source := TStringList.Create;
|
||||
try
|
||||
if FileExists(IRFile) and FileExists(IRFile + '.key') then
|
||||
begin
|
||||
Source.LoadFromFile(IRFile + '.key');
|
||||
if Trim(Source.Text) = UnitIR then
|
||||
begin
|
||||
Source.LoadFromFile(IRFile);
|
||||
IR := Source.Text;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
Source.Free;
|
||||
Source := nil;
|
||||
end;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
{ Full codegen (or fallback if caching was skipped/missed) }
|
||||
if IR = '' then
|
||||
begin
|
||||
CG := TCodeGenQBE.Create;
|
||||
try
|
||||
if (Units <> nil) and (Units.Count > 0) then
|
||||
begin
|
||||
CG.SetSymbolTable(Prog.SymbolTable);
|
||||
for I := 0 to Units.Count - 1 do
|
||||
CG.AppendUnit(TUnit(Units.Items[I]));
|
||||
CG.AppendProgram(Prog);
|
||||
end
|
||||
else
|
||||
CG.Generate(Prog);
|
||||
IR := CG.GetOutput;
|
||||
finally
|
||||
CG.Free;
|
||||
CG := nil;
|
||||
end;
|
||||
|
||||
{$IFDEF FPC}
|
||||
if CacheDir <> '' then
|
||||
CG := TCodeGenQBE.Create;
|
||||
try
|
||||
if (Units <> nil) and (Units.Count > 0) then
|
||||
begin
|
||||
if ForceDirectories(CacheDir) then
|
||||
begin
|
||||
IRFile := IncludeTrailingPathDelimiter(CacheDir) + '__full__.ssa';
|
||||
Source := TStringList.Create;
|
||||
try
|
||||
Source.Text := IR;
|
||||
Source.SaveToFile(IRFile);
|
||||
finally
|
||||
Source.Free;
|
||||
Source := nil;
|
||||
end;
|
||||
Source := TStringList.Create;
|
||||
try
|
||||
Source.Text := UnitIR;
|
||||
Source.SaveToFile(IRFile + '.key');
|
||||
finally
|
||||
Source.Free;
|
||||
Source := nil;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
{$ENDIF}
|
||||
CG.SetSymbolTable(Prog.SymbolTable);
|
||||
for I := 0 to Units.Count - 1 do
|
||||
CG.AppendUnit(TUnit(Units.Items[I]));
|
||||
CG.AppendProgram(Prog);
|
||||
end
|
||||
else
|
||||
CG.Generate(Prog);
|
||||
IR := CG.GetOutput;
|
||||
finally
|
||||
CG.Free;
|
||||
CG := nil;
|
||||
end;
|
||||
|
||||
if OPDFEnabled then
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue