Recent

Author Topic: Make system unit  (Read 5963 times)

Okoba

  • Sr. Member
  • ****
  • Posts: 301
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

  • Administrator
  • Hero Member
  • *
  • Posts: 9981
  • 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.

Okoba

  • Sr. Member
  • ****
  • Posts: 301
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: 4005
  • 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).

Okoba

  • Sr. Member
  • ****
  • Posts: 301
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: 4005
  • 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.

Okoba

  • Sr. Member
  • ****
  • Posts: 301
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: 4005
  • 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...

Okoba

  • Sr. Member
  • ****
  • Posts: 301
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.

Mussel

  • Newbie
  • Posts: 4
Re: Make system unit
« Reply #24 on: January 07, 2022, 01:03:25 pm »
I am stuck in the same situation:

It says "Internal type "TEXCEPTADDR" was not found" when trying to compile system.pas.

I have followed the rules set out by https://wiki.freepascal.org/System_unit, and although my system.pas derived from https://wiki.osdev.org/Pascal_Bare_Bones

What have I done wrong?

The following are compilation errors. I installed fpc-3.2.0.i386-linux (overwriting fpc-3.2.0-x86_64-linux).
Code: Text  [Select][+][-]
  1. boo@debian:~$ fpc -Us  -vut system.pas
  2. Configfile search: /home/boo/.fpc.cfg
  3. Reading options from file /home/boo/.fpc.cfg
  4. Path "./fpc/lib/fpc/3.2.0/units/i386-linux/" not found
  5. Path "./fpc/lib/fpc/3.2.0/units/i386-linux/*/" not found
  6. Path "./fpc/lib/fpc/3.2.0/units/i386-linux/rtl/" not found
  7. Path "./fpc/lib/fpc/3.2.0/units/i386-linux/httpd22/" not found
  8. Path "./.fppkg/lib/fpc/3.2.0/units/i386-linux/*/" not found
  9. Path "./fpc/lib/fpc/3.2.0/lib/i386-linux/" not found
  10. Free Pascal Compiler version 3.2.0 [2020/06/09] for i386
  11. Copyright (c) 1993-2020 by Florian Klaempfl and others
  12. Searching file /lib/ld-linux.so.2... found
  13. Path "/usr/X11R6/lib/" not found
  14. Compiler: /usr/lib/fpc/3.2.0/ppc386
  15. Target OS: Linux for i386
  16. Using executable path: /usr/lib/fpc/3.2.0/
  17. Using unit path: /usr/lib/fpc/3.2.0/units/i386-linux/rtl/
  18. Using unit path: /usr/lib/fpc/3.2.0/
  19. Using library path: /usr/lib/i386-linux-gnu/
  20. Using library path: /lib/
  21. Using library path: /usr/lib/
  22. Using library path: /usr/lib/gcc/x86_64-linux-gnu/10/
  23. Using library path: /usr/lib/fpc/3.2.0/units/i386-linux/rtl/
  24. Using library path: /usr/lib/fpc/3.2.0/
  25. Using object path: /usr/lib/fpc/3.2.0/units/i386-linux/rtl/
  26. Using object path: /usr/lib/fpc/3.2.0/
  27. Compiling system.pas
  28. Searching file system.pas... found
  29. (SYSTEM)   Loading interface units from SYSTEM
  30. system.pas(5,1) (system)   Parsing interface of unit system
  31. (system)   Loading implementation units from SYSTEM
  32. system.pas(18,1) (system)   Parsing implementation of SYSTEM
  33. system.pas(18,1) Fatal: Internal type "TEXCEPTADDR" was not found. Check if you use the correct run time library.
  34. Fatal: Compilation aborted
  35. Error: /usr/bin/ppc386 returned an error exitcode
  36.  

AlexTP

  • Hero Member
  • *****
  • Posts: 1765
    • UVviewsoft
Re: Make system unit
« Reply #25 on: January 07, 2022, 01:52:03 pm »
I just added the info from @PascalDragon and @Okoba to the wiki
https://wiki.freepascal.org/System_unit

ccrause

  • Hero Member
  • *****
  • Posts: 568
Re: Make system unit
« Reply #26 on: January 07, 2022, 01:58:32 pm »
I am stuck in the same situation:

It says "Internal type "TEXCEPTADDR" was not found" when trying to compile system.pas.

I have followed the rules set out by https://wiki.freepascal.org/System_unit, and although my system.pas derived from https://wiki.osdev.org/Pascal_Bare_Bones

What have I done wrong?

Look in the attachment of @Okoba...

The compiler expects some system defined types to be defined when parsing a subroutine such as the implementation section of system.pas.  This means you have to add some type definitions to system.pas.

It appears that this check was added to 3.2.0, so it is perhaps time to update the osdev example by some knowledgeable person  :-[

Edit: Thanks @Alextp, I see you where quicker and already updated the freepascal wiki.
« Last Edit: January 07, 2022, 02:00:26 pm by ccrause »

 

TinyPortal © 2005-2018