Recent

Author Topic: Make system unit  (Read 2289 times)

OkobaPatino

  • Jr. Member
  • **
  • Posts: 94
Re: Make system unit
« Reply #15 on: June 28, 2020, 07:19:04 pm »
You are using fpc directly. Did you try opening the Lazarus project I attached? My response was based on that.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8795
  • FPC developer.
Re: Make system unit
« Reply #16 on: June 28, 2020, 07:20:41 pm »
That sets -Us for all units in the project, that won't work.

OkobaPatino

  • Jr. Member
  • **
  • Posts: 94
Re: Make system unit
« Reply #17 on: June 28, 2020, 07:23:33 pm »
So I should compile the system unit directly and put the result in the lib directory to use with the project?
My intention is to find a way to replace system unit in a hopefully simple manner so I can work on it and test things.

PascalDragon

  • Hero Member
  • *****
  • Posts: 2262
  • Compiler Developer
Re: Make system unit
« Reply #18 on: June 29, 2020, 09:43:19 am »
For quite some time already FPC automatically applies the -Us switch to the unit named System, so you don't need the -Us switch (I didn't use it when compiling from the command line either).

OkobaPatino

  • Jr. Member
  • **
  • Posts: 94
Re: Make system unit
« Reply #19 on: June 29, 2020, 06:24:40 pm »
You are right, removeing -Us solved it. I added other types that it needed and now it want to compile objpas unit.
Any idea?
Code: Pascal  [Select][+][-]
  1. unit system;
  2. {$MODE FPC}
  3. interface
  4.  
  5. type
  6.   hresult = longint;
  7.   DWord = LongWord;
  8.   Cardinal = LongWord;
  9.   Integer = SmallInt;
  10.   UInt64 = QWord;
  11.   TTypeKind = (tkUnknown, tkInteger, tkChar, tkEnumeration, tkFloat, tkSet,
  12.     tkMethod, tkSString, tkLString, tkAString, tkWString, tkVariant, tkArray,
  13.     tkRecord, tkInterface, tkClass, tkObject, tkWChar, tkBool, tkInt64, tkQWord,
  14.     tkDynArray, tkInterfaceRaw, tkProcVar, tkUString, tkUChar, tkHelper, tkFile,
  15.     tkClassRef, tkPointer);
  16.  
  17. type
  18.   jmp_buf = packed record
  19.     rbx, rbp, r12, r13, r14, r15, rsp, rip: QWord;
  20. {$IFDEF win64}
  21.     rsi, rdi: QWord;
  22.     xmm6, xmm7, xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15: record m1,
  23.       m2: QWord;
  24.   end;
  25.  
  26. mxcsr:
  27. LongWord;
  28. fpucw:
  29. word;
  30. padding:
  31. word;
  32. {$ENDIF win64}
  33. end;
  34. pjmp_buf = ^jmp_buf;
  35. PExceptAddr = ^TExceptAddr;
  36. TExceptAddr = record buf: pjmp_buf;
  37. next:
  38. PExceptAddr;
  39. {$IFDEF CPU16}
  40. frametype:
  41. SmallInt;
  42. {$ELSE CPU16}
  43. frametype:
  44. longint;
  45. {$ENDIF CPU16}
  46. end;
  47. PGuid = ^TGuid;
  48. TGuid = packed record
  49. case Integer of
  50.   1:
  51.     (Data1: DWord;
  52.       Data2: word;
  53.       Data3: word;
  54.       Data4: array [0 .. 7] of byte;
  55.     );
  56.   2:
  57.     (D1: DWord;
  58.       D2: word;
  59.       D3: word;
  60.       D4: array [0 .. 7] of byte;
  61.     );
  62.   3:
  63.     ( { uuid fields according to RFC4122 }
  64.       time_low: DWord; // The low field of the timestamp
  65.       time_mid: word; // The middle field of the timestamp
  66.       time_hi_and_version: word;
  67.       // The high field of the timestamp multiplexed with the version number
  68.       clock_seq_hi_and_reserved: byte;
  69.       // The high field of the clock sequence multiplexed with the variant
  70.       clock_seq_low: byte; // The low field of the clock sequence
  71.       node: array [0 .. 5] of byte; // The spatially unique node identifier
  72.     );
  73. end;
  74.  
  75. var
  76.   exitCode: hresult = 0;
  77. export name 'operatingsystem_result';
  78.  
  79. implementation
  80.  
  81. procedure initializeUnits;
  82. alias:
  83. 'FPC_INITIALIZEUNITS';
  84.  
  85. begin
  86.  
  87. end;
  88.  
  89. procedure doExit;
  90. alias:
  91. 'FPC_DO_EXIT';
  92.  
  93. begin
  94.  
  95. end;
  96.  
  97. end.

PascalDragon

  • Hero Member
  • *****
  • Posts: 2262
  • Compiler Developer
Re: Make system unit
« Reply #20 on: June 30, 2020, 09:57:44 am »
That is because your project's mode is set to ObjFPC (Lazarus will pass a -MObjFPC parameter to the compiler then) which automatically leads to an insertion of the ObjPas unit. Either change your project's mode in Project Settings -> Compiler Settings -> Parsing or add a {$mode fpc} to your main program file.

OkobaPatino

  • Jr. Member
  • **
  • Posts: 94
Re: Make system unit
« Reply #21 on: June 30, 2020, 02:49:15 pm »
you were right, it solve the problem but now it can not find this:
Code: Pascal  [Select][+][-]
  1. Unknown compilerproc "fpc_initializeunits". Check if you use the correct run time library.
You pointed out very good points but wiki seams out of date, that is why it looks more complicated than it should.
I attached the project too.

PascalDragon

  • Hero Member
  • *****
  • Posts: 2262
  • Compiler Developer
Re: Make system unit
« Reply #22 on: June 30, 2020, 03:20:23 pm »
you were right, it solve the problem but now it can not find this:
Code: Pascal  [Select][+][-]
  1. Unknown compilerproc "fpc_initializeunits". Check if you use the correct run time library.

You need to add a procedure fpc_initializeunits; compilerproc; both in the interface and implementation section.

You pointed out very good points but wiki seams out of date, that is why it looks more complicated than it should.

There aren't many people that try to write their own, minimal System unit and we core devs don't care about that Wiki article, thus it only gets updates (if at all) if someone tries to do that again...

OkobaPatino

  • Jr. Member
  • **
  • Posts: 94
Re: Make system unit
« Reply #23 on: June 30, 2020, 03:29:19 pm »
You are right. I added that and some more and it now compiles, although next step is making debugger works.
I attached the project for the future.

 

TinyPortal © 2005-2018