Recent

Author Topic: [SOLVED] dynarray hangs  (Read 991 times)

Key-Real

  • Sr. Member
  • ****
  • Posts: 362
[SOLVED] dynarray hangs
« on: July 26, 2024, 11:10:26 am »
How to explicitly do dynarrays work?



Code: Pascal  [Select][+][-]
  1. var
  2.         i : array of longint;
  3. begin
  4.         printf('pre'#10);
  5.         SetLength(i, 1);                                  <---   this hangs here
  6.         printf('post'#10);
  7.  
  8.         printf('%d'#10, length(i));
  9. end.   
  10.  


what I need for initialization?
« Last Edit: July 28, 2024, 09:22:51 pm by Key-Real »

MarkMLl

  • Hero Member
  • *****
  • Posts: 7518
Re: dynarray hangs
« Reply #1 on: July 26, 2024, 11:25:52 am »
Code: [Select]
scratch.pas(5,71) Fatal: Syntax error, ";" expected but "identifier HANGS" found

Post a compilable example, and give information on what compiler you're using etc. in the body of the message (i.e. not in your forum signature.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Key-Real

  • Sr. Member
  • ****
  • Posts: 362
Re: dynarray hangs
« Reply #2 on: July 26, 2024, 11:30:30 am »
....Still porting FPC to PS1

to "post" the compiler, first have to setup the rtl, the way You told me (You don't like my hacks):

https://forum.lazarus.freepascal.org/index.php/topic,68017.0.html
« Last Edit: July 26, 2024, 11:47:24 am by Key-Real »

MarkMLl

  • Hero Member
  • *****
  • Posts: 7518
Re: dynarray hangs
« Reply #3 on: July 26, 2024, 11:45:17 am »
Fine, so what's that got to do with it? Was the fragment you posted supposed to compile with your host compiler (in which case, apart from the obvious error I highlighted plus the fact that printf() is not a standard function there appears nothing wrong with it), or with a customised compiler you were attempting to test?

/If/ you were using a host compiler, then the version might be significant, as might also be the unit's mode set by a directive at the start (which you've omitted). I /think/ that by default the compiler will be in a mode that allows dynamic arrays, but this is definitely not something I'd assume early in the porting process since it obviously relies heavily on a reliable heap implementation etc.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Key-Real

  • Sr. Member
  • ****
  • Posts: 362
Re: dynarray hangs
« Reply #4 on: July 26, 2024, 12:01:33 pm »
Fine, so what's that got to do with it?
I posted the source of my compiler but I was told to setup the makefiles first. OK, I'll try (need help).

Was the fragment you posted supposed to compile with your host compiler (in which case, apart from the obvious error I highlighted plus the fact that printf() is not a standard function there appears nothing wrong with it), or with a customised compiler you were attempting to test?
Its from my build of the crosscompiler I'm porting.

I /think/ that by default the compiler will be in a mode that allows dynamic arrays, but this is definitely not something I'd assume early in the porting process since it obviously relies heavily on a reliable heap implementation etc.

Heap is initialized in the initialization part of the system unit and getmem works correctly.

I think there is some flags to set to allow dynlibs, but I'm just guessing.

MarkMLl

  • Hero Member
  • *****
  • Posts: 7518
Re: dynarray hangs
« Reply #5 on: July 26, 2024, 12:52:57 pm »
I posted the source of my compiler but I was told to setup the makefiles first. OK, I'll try (need help).

I'm no fan of Git, and when I was looking at MIPS some years ago I was doing so in the context of either a downloaded archive (fpcbuild?) or Subversion. However my recollection is that the fundamental makefiles etc. came with it, and basically "all" I had to do was follow the standard build instructions: I've previously given you a link to the notes that I put in the wiki.

These days, that is obviously documented at https://www.freepascal.org/docs-html/current/prog/progsu218.html#x331-347000F.3.1 etc., which then goes on to cross-builds. I must stress that the manual contains (or at least is supposed to contain) definitive information, and that details might have changed since I was involved in this stuff.

As I've previously said, I got things to the state where the compiler (and RTL?) would build, but it failed some of the test programs... in order to be confident in your build /all/ of these must pass. At that point, I basically ran out of time even though we (as a company) were generally interested in non-PC platforms, in addition to which development hardware promised by the Chinese manufacturer failed to arrive so I lost a lot of time due to relatively-slow target emulation.

Quote
Its from my build of the crosscompiler I'm porting.

I think there's two questions to ask at this point. (a) Does your test code work in the context of an unmodified compiler? (I'm concerned, in retrospect, about those printf()s etc.) and (b) Does your compiler pass all the test cases before you apply it to your own code?

Quote
Heap is initialized in the initialization part of the system unit and getmem works correctly.

I think there is some flags to set to allow dynlibs, but I'm just guessing.

Again, do the test cases pass? Is this a modified compiler/RTL you're building, since I'd not expect dynamic libraries to be relevant until both were completed.

I would stress that the above is my own personal position. If you were talking directly to the core compiler maintainers you might do better, and to do that you really should be on the fpc-devel mailing list: but expect them to have their own agenda, and to be even less tolerant of e.g. incomplete examples than the forum :-)

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

PascalDragon

  • Hero Member
  • *****
  • Posts: 5649
  • Compiler Developer
Re: dynarray hangs
« Reply #6 on: July 28, 2024, 06:30:05 pm »
How to explicitly do dynarrays work?

[snip]

what I need for initialization?

Dynamic arrays require a working heap implementation. This requires either the default heap implementation and the low level functions SysOSAlloc and SysOSFree or you need to use TinyHeap which requires a bit of setup if you don't have the possibility for allocations available.

Key-Real

  • Sr. Member
  • ****
  • Posts: 362
Re: dynarray hangs
« Reply #7 on: July 28, 2024, 09:22:39 pm »
Yes the correct Heap setup make it works.

thx

 

TinyPortal © 2005-2018