[SOLVED] how to satisfy the system unit for the original RTL? lazarus / 64-FPC development ---------------------------------------------------------------------- Key-Real · 2024-07-16 09:03 I don't knew exactly what have to be set in the system unit to compile the standard (platform undependent) RTL. I have so far this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit system;interface{$define FPC_IS_SYSTEM}{$DEFINE FPCRTL_FILESYSTEM_SINGLE_BYTE_API} {$I systemh.inc} var  argc:longint=0;  argv:PPAnsiChar;  envp:PPAnsiChar; implementationconst    maxExitCode = 255;    AllowDirectorySeparators : set of AnsiChar = ['\','/'];    DirectorySeparator = '/';  { Default filehandles }    UnusedHandle    = $ffff;{ instead of -1, as it is a word value}    StdInputHandle  = 0;    StdOutputHandle = 1;    StdErrorHandle  = 2;    CtrlZMarksEOF: boolean = true; (* #26 is considered as end of file *)    DefaultTextLineBreakStyle : TTextLineBreakStyle = tlbsCR;    {I ../mips/setjump.inc}{$I system.inc}  procedure Randomize;beginend; function GetProcessID:LongWord;begin  result:= 0;end; function ParamCount:LongInt;begin  ParamCount:= 0;end; function ParamStr(l: LongInt):ShortString;begin  result:= '';end; procedure SysInitStdIO;beginend; function CheckInitialStkLen(stklen : SizeUInt) : SizeUInt;begin  result := stklen;end; procedure system_exit;begin  repeat  until false;end; end.  well, this hangs on fpc_initializeunits .... ideas? ---------------------------------------------------------------------- Key-Real · 2024-07-16 11:02 hm... If I do smartlinking the program runs. I mean I link with --gc- sections If not, it hangs ---------------------------------------------------------------------- Thaddy · 2024-07-16 11:25 PascalDragon has already explained that. You need to implement fpc_initializeunits / fpc_uninitializeunits in your system when you need to link the rtl statically. ---------------------------------------------------------------------- nickysn · 2024-07-16 14:49 Thaddy, fpc_initializeunits is already implemented in system.inc, which is included. Key-Real, you need to figure out where exactly it hangs by adding some sort of debug prints, or another primitive output, if you don't have a console. Are you running in an emulator, or on real hardware? Can you use a debugger? How do you debug print on your platform? ---------------------------------------------------------------------- Key-Real · 2024-07-16 17:43 the good news: I'm able to print to console (I'm using PCSX-Redux emulator) ---------------------------------------------------------------------- Key-Real · 2024-07-16 18:17 SUCCESS!!   I traced it out!! ./rtl/inc/system.inc (line 1148): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  procedure fpc_InitializeUnits;[public,alias:'FPC_INITIALIZEUNITS']; compilerproc;var  i : ALUUInt;  pt : PInitFinalTable;begin  printf('INIT UNITS'+#10);    { call cpu/fpu initialisation routine }  fpc_cpuinit; {$ifdef FPC_HAS_INDIRECT_ENTRY_INFORMATION}  pt := PInitFinalTable(EntryInformation.InitFinalTable);{$else FPC_HAS_INDIRECT_ENTRY_INFORMATION}  pt := @InitFinalTable;{$endif FPC_HAS_INDIRECT_ENTRY_INFORMATION}  with pt^ do   begin     for i:=1 to ALUUInt(TableCount) do      begin        printf('%d'+#10, ALUUInt(TableCount));        if assigned(Procs[i].InitProc) then       Procs[i].InitProc();        InitCount:=i;      end;   end;    if assigned(InitProc) then    TProcedure(InitProc)();     printf('DONE UNITS'+#10);end;   in ./rtl/inc/systemh.inc (line 516): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  ALUUInt = DWord; If I let i as ALUUInt the for loop continues till infinite! if i declare i as integer everything works!!!! IS THIS A COMPILER BUG?????????? ---------------------------------------------------------------------- Key-Real · 2024-07-16 18:29 word and integer works dword and longint not! the error have to be somethere else ---------------------------------------------------------------------- Key-Real · 2024-07-16 18:37 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i printf('sizeis = %d'+#10,sizeof(dword)); gives me 4 if it helps.... ---------------------------------------------------------------------- Key-Real · 2024-07-16 18:50 compiling system.pp he tells me: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Warning: Source OS Redefined!Free Pascal Compiler version 3.3.1 [2024/07/16] for mipselCopyright (c) 1993-2024 by Florian Klaempfl and othersTarget OS: PlayStation 1 for MIPSELCompiling ./rtl/ps1/system.ppmips.inc(191,4) Note: "assembler" not yet supported inside inline procedure/functiongeneric.inc(88,40) Warning: Converting pointers to signed integers may result in wrong comparison results and range errors, use an unsigned type instead.generic.inc(347,12) Warning: Comparison might be always true due to range of constant and expressiongeneric.inc(544,19) Note: Local variable "pendpart" not usedastrings.inc(882,48) Warning: Function result variable of a managed type does not seem to be initializedastrings.inc(1326,7) Note: Call to subroutine "procedure fpc_pchar_ansistr_intern_charmove(const src:PAnsiChar;const srcindex:LongInt;var dst:RawByteString;const dstindex:LongInt;const len:LongInt);" marked as inline is not inlinedastrings.inc(1353,5) Note: Call to subroutine "procedure fpc_pchar_ansistr_intern_charmove(const src:PAnsiChar;const srcindex:LongInt;var dst:RawByteString;const dstindex:LongInt;const len:LongInt);" marked as inline is not inlinedastrings.inc(1354,3) Note: Call to subroutine "procedure fpc_pchar_ansistr_intern_charmove(const src:PAnsiChar;const srcindex:LongInt;var dst:RawByteString;const dstindex:LongInt;const len:LongInt);" marked as inline is not inlinedastrings.inc(1356,5) Note: Call to subroutine "procedure fpc_pchar_ansistr_intern_charmove(const src:PAnsiChar;const srcindex:LongInt;var dst:RawByteString;const dstindex:LongInt;const len:LongInt);" marked as inline is not inlinedustrings.inc(580,73) Warning: Function result variable of a managed type does not seem to be initializedustrings.inc(646,66) Warning: Function result variable of a managed type does not seem to be initializedustrings.inc(767,100) Warning: Function result variable of a managed type does not seem to be initializedustrings.inc(1200,54) Warning: Function result variable of a managed type does not seem to be initializedustrings.inc(1842,5) Note: Local variable "PRECHAR" is assigned but never usedustrings.inc(2111,8) Note: Call to subroutine "function Utf8ToUnic ode(Dest:PUnicodeChar;MaxDestChars:LongWord;Source:PAnsiChar;SourceByt es:LongWord):LongWord;" marked as inline is not inlinedustrings.inc(2357,66) Warning: Function result variable of a managed type does not seem to be initializedustrings.inc(2367,56) Warning: Function result variable of a managed type does not seem to be initializeddynarr.inc(351,39) Warning: Function result variable of a managed type does not seem to be initializeddynarr.inc(759,21) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(110,38) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(117,42) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(123,36) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(129,38) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(135,36) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(141,38) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(161,33) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(167,33) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(173,33) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(179,33) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(185,33) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(191,33) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(197,36) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(203,35) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(223,34) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(229,34) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(235,34) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(243,34) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(252,34) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(259,34) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(265,34) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(271,34) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(277,34) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(283,34) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(339,36) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(353,35) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(476,32) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(482,32) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(573,38) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(831,34) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(837,34) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(921,38) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(927,38) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(933,38) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(939,38) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(945,38) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(951,38) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(957,38) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(963,38) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(969,53) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(975,53) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(981,53) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(988,39) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(994,53) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(1001,39) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(1007,39) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(1013,53) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(1069,53) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(1083,38) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(1089,31) Warning: Function result variable of a managed type does not seem to be initializedvariant.inc(1096,33) Warning: Function result variable of a managed type does not seem to be initializedrtti.inc(98,13) Warning: Case statement does not handle all possible casesrtti.inc(170,3) Warning: Case statement does not handle all possible casesrtti.inc(212,3) Warning: Case statement does not handle all possible casesrtti.inc(263,3) Warning: Case statement does not handle all possible casesrtti.inc(326,3) Warning: Case statement does not handle all possible casesheap.inc(1340,3) Note: Local variable "newsize" not usedheap.inc(1345,3) Note: Local variable "poc" not usedheap.inc(1346,3) Note: Local variable "pmcv" not usedheap.inc(1648,8) Note: Local variable "poc_next" not usedsysfile.inc(49,10) Warning: Function result does not seem to be setsysfile.inc(60,10) Warning: Function result does not seem to be setsysfile.inc(65,10) Warning: Function result does not seem to be setsystem.inc(1981,3) Note: Call to subroutine "procedure do_open(var f:;p:PAnsiChar;flags:LongInt;pchangeable:Boolean);" marked as inline is not inlinedsystem.inc(1989,3) Note: Call to subroutine "procedure do_erase(p:PAnsiChar;pchangeable:Boolean);" marked as inline is not inlinedsystem.inc(1998,3) Note: Call to subroutine "procedure do_rename(p1:PAnsiChar;p2:PAnsiChar;p1changeable :Boolean;p2changeable:Boolean);" marked as inline is not inlinedsystem.inc(2006,3) Note: Call to subroutine "procedure do_renam e(p1:PAnsiChar;p2:PAnsiChar;p1changeable:Boolean;p2changeable:Boolean) ;" marked as inline is not inlinedtext.inc(138,41) Warning: Implicit string type conversion from "RawByteString" to "UnicodeString"file.inc(73,41) Warning: Implicit string type conversion from "RawByteString" to "UnicodeString"system.pp(44,10) Warning: Function result does not seem to be setsystem.pp(53,10) Warning: Function result does not seem to be setsystem.inc(70,3) Note: Local variable "initialstklen" not usedAssembling system31093 lines compiled, 0.9 sec74 warning(s) issued17 note(s) issued  hm.... ---------------------------------------------------------------------- PascalDragon · 2024-07-16 18:51 Quote from: Key-Real on July 16, 2024, 08:17:50 pmCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  procedure fpc_InitializeUnits;[public,alias:'FPC_INITIALIZEUNITS']; compilerproc;var  i : ALUUInt;  pt : PInitFinalTable;begin  printf('INIT UNITS'+#10);    { call cpu/fpu initialisation routine }  fpc_cpuinit; {$ifdef FPC_HAS_INDIRECT_ENTRY_INFORMATION}  pt := PInitFinalTable(EntryInformation.InitFinalTable);{$else FPC_HAS_INDIRECT_ENTRY_INFORMATION}  pt := @InitFinalTable;{$endif FPC_HAS_INDIRECT_ENTRY_INFORMATION}  with pt^ do   begin     for i:=1 to ALUUInt(TableCount) do      begin        printf('%d'+#10, ALUUInt(TableCount));        if assigned(Procs[i].InitProc) then       Procs[i].InitProc();        InitCount:=i;      end;   end;    if assigned(InitProc) then    TProcedure(InitProc)();     printf('DONE UNITS'+#10);end;   in ./rtl/inc/systemh.inc (line 516): Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  ALUUInt = DWord; If I let i as ALUUInt the for loop continues till infinite! if i declare i as integer everything works!!!! It might be that TableCount is 0, considering that your System unit does not seem to have an initialization-section. There should be the initialization of some of the core functionality in there (take a look at other System-units). ---------------------------------------------------------------------- Key-Real · 2024-07-16 19:03 I put in the system.pp Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...begin  { Reset IO Error }  InOutRes:=0;end.  now tablecount is 2: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i printf('TableCount is %d'+#10, pt^.TableCount); still the same. btw. the random(123) doesn't work. can this help? ---------------------------------------------------------------------- PascalDragon · 2024-07-16 19:15 Quote from: Key-Real on July 16, 2024, 09:03:08 pmI put in the system.pp Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...begin  { Reset IO Error }  InOutRes:=0;end.  now tablecount is 2: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i printf('TableCount is %d'+#10, pt^.TableCount); still the same. Then it could be a bug in the MIPS code generator. After all the code works everywhere else... Quote from: Key-Real on July 16, 2024, 09:03:08 pmbtw. the random(123) doesn't work. can this help? What do you mean with "doesn't work"? Does it always provide the same value? Does it crash? By the way: you don't need to write '%d'+#10 as you can simply append characters to strings: '%d'#10. ---------------------------------------------------------------------- Key-Real · 2024-07-16 19:17 yes, it crashes I think the bug is in mips code, again