Recent

Author Topic: Make system unit  (Read 7712 times)

Okoba

  • Hero Member
  • *****
  • Posts: 528
Make system unit
« on: April 20, 2020, 07:41:09 am »
Hi,

I wanted to try making a new system unit for a test, as explained here:
https://wiki.freepascal.org/System_unit
I made a system.pas unit into a blank project without any package and added the code explained in the wiki page, but In the last stable Lazarus and also Trunk, it gives an error on the "interface" line and says:
Quote
system.pas(3,1) Error: Internal error 2016060303

Am I missing something?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: Make system unit
« Reply #1 on: April 20, 2020, 10:07:46 am »
Yes, look at the parameters:

e:\archive>fpc -h |grep -i system
     -T<x>  Target operating system:
      -Us        Compile a system unit
      -Xn        Use target system native linker instead of GNU ld (Solaris, AIX)

A system unit must be compiled with -Us, since it must not implicitely  import the system unit obviously.

Okoba

  • Hero Member
  • *****
  • Posts: 528
Re: Make system unit
« Reply #2 on: April 20, 2020, 10:12:04 am »
If you mean adding -Us to project custom options I did it already.
To be more precise I did these:
  • Make a new black project in FPC and Lazarus Trunk
  • Add a new unit called system.pas
  • Add the code from the wiki page
  • Add -Usto custom options in project options
  • Compile and get the error at the interface with this number 2016060303

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Make system unit
« Reply #3 on: April 20, 2020, 11:56:30 am »
I wanted to try making a new system unit for a test, as explained here:
https://wiki.freepascal.org/System_unit
I made a system.pas unit into a blank project without any package and added the code explained in the wiki page, but In the last stable Lazarus and also Trunk, it gives an error on the "interface" line and says:
Quote
system.pas(3,1) Error: Internal error 2016060303

I wouldn't advice to use that article as a base. There is quite some functionality required inside the System unit that the compiler expects to be there.

What exactly are you trying to achieve in the end?

Okoba

  • Hero Member
  • *****
  • Posts: 528
Re: Make system unit
« Reply #4 on: April 20, 2020, 12:03:55 pm »
Learning.
As I read the Docs I found out the System unit is the only unit added if we use FPC mode, and we can make our own if we have the requirements, so I like to do that.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Make system unit
« Reply #5 on: April 20, 2020, 12:27:05 pm »
I suggest you to take a look at the Embedded target then. It has a more minimal System unit. Best try to remove stuff until things don't compile to find out what's required and what is not.
Also depending on the platform it's not true that no further unit is added, because for example on Windows the SysInit unit is also used, because that contains the entry point for the binary.

Okoba

  • Hero Member
  • *****
  • Posts: 528
Re: Make system unit
« Reply #6 on: April 20, 2020, 12:32:05 pm »
Interesting point on Sysinit. But I think there is another problem, as I said it will give error on interface and not the code. It seems something else is missing.
Maybe @marcov knows about it.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Make system unit
« Reply #7 on: April 20, 2020, 01:10:35 pm »
The internal error occurs when the compiler tries to create its internal types for use inside the System unit, but it already exists. Try to compile with -vut to check whether it really does not try to use the distributed System unit. Or pass -n so that the compiler does not use its configuration file (where the search paths are defined).

Okoba

  • Hero Member
  • *****
  • Posts: 528
Re: Make system unit
« Reply #8 on: April 20, 2020, 01:56:44 pm »
If I add -n it gives an error for fpintres but I added that too and it goes back to the error.
I attached a sample project for test.

Okoba

  • Hero Member
  • *****
  • Posts: 528
Re: Make system unit
« Reply #9 on: June 28, 2020, 12:19:41 am »
Any idea on this will help.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11382
  • FPC developer.
Re: Make system unit
« Reply #10 on: June 28, 2020, 03:00:59 pm »
Hmm, seems 3.2.0 gives more verbose errors in such case:

Quote
D:\Testing\minrtl>fpc -Us system
Free Pascal Compiler version 3.2.0 [2020/06/04] for i386
Copyright (c) 1993-2020 by Florian Klaempfl and others
Target OS: Win32 for i386
Compiling system.pas
system.pas(12,1) Fatal: Internal type "TEXCEPTADDR" was not found. Check if you use the correct run time library.
Fatal: Compilation aborted
Error: d:\FPC\3.2.0\bin\i386-Win32\ppc386.exe returned an error exitcode

Okoba

  • Hero Member
  • *****
  • Posts: 528
Re: Make system unit
« Reply #11 on: June 28, 2020, 03:16:39 pm »
If I try to run the project with Lazarus it gives the error I said before.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Make system unit
« Reply #12 on: June 28, 2020, 04:53:09 pm »
You must not manually add the unit fpintres to the uses clause, that is done by the compiler (and it's automatically removed again if not needed, but the compiler simply needs the unit available).

Okoba

  • Hero Member
  • *****
  • Posts: 528
Re: Make system unit
« Reply #13 on: June 28, 2020, 06:06:15 pm »
Thanks for the point. I removed it but the error is still the same.

PascalDragon

  • Hero Member
  • *****
  • Posts: 5446
  • Compiler Developer
Re: Make system unit
« Reply #14 on: June 28, 2020, 06:59:19 pm »
I get the following:

Code: [Select]
Free Pascal Compiler version 3.0.4 [2020/04/11] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Win64 for x64
Compiling .\project1.lpr
Linking project1.exe
project1.lpr(5,1) Error: Entrypoint _mainCRTStartup not defined
project1.lpr(5,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
Error: C:\lazarus\2.0.8\fpc\3.0.4\bin\x86_64-win64\ppcx64.exe returned an error exitcode

And with FPC 3.2.0 or newer I get the error that marcov mentioned.

 

TinyPortal © 2005-2018