Re: [fpc-pascal] Cache-line alignment for records

2023-03-28 Thread Matias Ezequiel Vara Larsen via fpc-pascal
Hello,

On Mon, Mar 27, 2023 at 09:35:38PM +0200, Jonas Maebe via fpc-pascal wrote:
> On 27/03/2023 21:25, denisgolovan via fpc-pascal wrote:
> 
> > But it's still not possible to attach alignment to type itself instead of 
> > variable, right?
> 
> It is possible 
> (https://gitlab.com/freepascal.org/fpc/source/-/blob/main/tests/test/talignrec1.pp),
> but it is subject to the same limitations when declaring variables of those
> types.
> 

Thanks, this is what I was looking for, however, when the type is
defined as an array, only the [0] element is aligned. I was expecting
that each element in the array would be aligned. 

Matias
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-03-28 Thread Ralf Quint via fpc-pascal

On 3/28/2023 3:12 AM, Marco van de Voort via fpc-pascal wrote:


On 28-3-2023 11:33, Karoly Balogh via fpc-pascal wrote:


Probably yes, but there might be an alternative, see below. But as 
far as

I understand, Unit is a Turbo Pascal concept, so any Pascal programming
dialect that predates it, probably don't understand it.


True, and before units in Turbo Pascal(*) and Modules in Extended 
Pascal, nothing was standardized about breaking up the source into 
multiple parts.


Most dialects either adopted some form of C "extern" like handling, 
and the more advanced ones some form of Modula2 derived modules, 
either directly, or via the lengthy Extended Pascal standardization 
process.


(*) Turbo Pascal was strictly not a standard, but influential enough 
to set one.


Units was actually something that was taken over from UCSD Pascal, which 
had them for more than a decade before Anders Hejlsberg introduced them 
with Turbo Pascal 4.0. They were omitted from the earlier versions due 
to space constraints on CP/M, then the CP/M versions were translated 
more or less 1:1 from Z80 to 8086 code and they were added when Turbo 
Pascal 4.0 was pretty much rewritten from scratch...



Ralf


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-03-28 Thread Ralf Quint via fpc-pascal

On 3/27/2023 2:45 AM, Jacob Kroon via fpc-pascal wrote:

Hi,

I have some old Pascal code that was compiled in a CPM environment 
using the Pascal/MT+ compiler from Digital Research. I'm trying to get 
this project to build in a modern environment, for a start using 
FreePascal.


First, is anyone aware of a tool for converting this dialect of Pascal 
to something that FreePascal will accept ?


Well, it is a very long time since I used Pascal MT+ the last time, and 
that was already on the x86 version (+30 years now), but the same things 
should still apply.


First of all, Pascal MT+ is more or less ISO7185 compatible, so you 
would have to use that mode in FPC if you don't want to change all those 
file reference (that's what's mostly different to a "real" Pascal :P )


As for the "external" vars (and possibly procedures/functions), it is 
not quite the same as the units in UCSD/Turbo/Delphi/FreePascal, but it 
had the possibility (due to source code size restrictions, you had only 
64KB for OS, compiler and source code together) to compile different 
source files into separate object files, which then could be linked 
together with the linker. It is more of an "forward" declaration. In 
most cases, I would assume that you could actually copy all those source 
files that are being referenced into a single source file. Using units 
could work in a lot of cases, but which way to go might depend on your 
actual use case...



Ralf



Second, the old code contains a lot of:

var
foobar : external integer;

in sources that reference 'foobar', then there is a declaration in one 
of them:


var
foobar : integer;

As I understand it, in order to translate this to something that 
FreePascal understands, the variable needs to go in a "unit" and be 
part of its interface. Then, pascal sources that needs to reference 
the variable should use this unit. Is this the easiest way forward ?


I thought maybe I instead could adapt the syntax like:

var
foobar : integer; external;

but with this I still get undefined references when linking. Using 
units seems ok.


Bets regards
Jacob
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal



___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Fpc 3.2.2 fails to "make install" on RPi4 to local directory

2023-03-28 Thread Bo Berglund via fpc-pascal
On Tue, 28 Mar 2023 13:47:30 +0200, Marco van de Voort via fpc-pascal
 wrote:

>
>On 28-3-2023 13:43, Bo Berglund via fpc-pascal wrote:
>> make install prefix="$HOME" FPC="$HOME/dev/fpc/3.2.2/compiler/ppcarm"
>
>It is install_prefix= not install prefix=  iow, insert a underscore
>

No, the problem was *case sensitivity*!
the command should be:

make install PREFIX="$HOME" FPC="$HOME/dev/fpc/3.2.2/compiler/ppcarm"

Stupid confusion of case sensitive OS with Windows where case does not come into
play...

-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Fpc 3.2.2 fails to "make install" on RPi4 to local directory

2023-03-28 Thread Marco van de Voort via fpc-pascal


On 28-3-2023 13:43, Bo Berglund via fpc-pascal wrote:

make install prefix="$HOME" FPC="$HOME/dev/fpc/3.2.2/compiler/ppcarm"


It is install_prefix= not install prefix=  iow, insert a underscore

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Fpc 3.2.2 fails to "make install" on RPi4 to local directory

2023-03-28 Thread Bo Berglund via fpc-pascal
I have a RaspberryPi4 where I have installed several versions of Lazarus/Fpc
over some time.
The latest versions are (fpc from Tools/Options/Compiler_executable):

Laz 2.0.8  with Fpc 3.0.4 set to use fpc: fpc
Laz 2.0.10 with Fpc 3.2.0 set to use fpc: /home/pi/lib/fpc/3.2.0/ppcarm
Laz 2.0.12 with Fpc 3.2.0 set to use fpc: /home/pi/lib/fpc/3.2.0/ppcarm

Now I wanted to add a new Lazarus version and update my FPC to 3.2.2 as well.

So I have done what I always do, gotten the fpc sources from GitLab into a new
dir ~/dev/fpc/3.2.2, then executed inside that dir using fpc 3.2.0 as seed:

make clean FPC="/home/pi/dev/fpc/3.2.0/compiler/ppcarm"
make all   FPC="/home/pi/dev/fpc/3.2.0/compiler/ppcarm"

And then after that succeeded:

make install prefix="$HOME" FPC="$HOME/dev/fpc/3.2.2/compiler/ppcarm"
which throws an error! So I tried without $HOME:

make install prefix="/home/pi" FPC="/home/pi/dev/fpc/3.2.2/compiler/ppcarm"
which also throws the error, it displays this sequence:

make installbase FPC=/home/pi/dev/fpc/3.2.2/compiler/ppcarm
ZIPDESTDIR=/home/pi/dev/fpc/3.2.2
FPCMAKE=/home/pi/dev/fpc/3.2.2/utils/fpcm/bin/arm-linux/fpcmake
make[1]: Entering directory '/home/pi/dev/fpc/3.2.2'
/usr/bin/install -m 755 -d /usr/local/lib/fpc/3.2.2
/usr/bin/install: cannot create directory ‘/usr/local/lib/fpc’: Permission
denied
make[1]: *** [Makefile:2858: installbase] Error 1
make[1]: Leaving directory '/home/pi/dev/fpc/3.2.2'
make: *** [Makefile:2875: installall] Error 2

This has *never* happened before to me and I do not understand why it brings up
/usr/bin/ and /usr/local/lib/, the whole point of my use of the argument
prefix="/home/pi"
is to install *locally* below the home dir and not to a global location where
you nhave to be sudo to do anything...

Note:
my $HOME/.fpc.cfg from 2019 contains exclusively paths looking like this:

#ifndef VER2
-FM/home/pi/lib/fpc/../../share/fpc/$fpcversion/unicode/
#endif
# searchpath for units and other system dependent things
-Fu/home/pi/lib/fpc/$fpcversion/units/$fpctarget
-Fu/home/pi/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/home/pi/lib/fpc/$fpcversion/units/$fpctarget/rtl


Is this a new behaviour for Fpc 3.2.2 different from that of Fpc 3.2.0 where it
did not happen???

If not, what could have happened and in both cases how do I fix it?


-- 
Bo Berglund
Developer in Sweden

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-03-28 Thread Marco van de Voort via fpc-pascal



On 28-3-2023 11:33, Karoly Balogh via fpc-pascal wrote:


Probably yes, but there might be an alternative, see below. But as far as
I understand, Unit is a Turbo Pascal concept, so any Pascal programming
dialect that predates it, probably don't understand it.


True, and before units in Turbo Pascal(*) and Modules in Extended 
Pascal, nothing was standardized about breaking up the source into 
multiple parts.


Most dialects either adopted some form of C "extern" like handling, and 
the more advanced ones some form of Modula2 derived modules, either 
directly, or via the lengthy Extended Pascal standardization process.


(*) Turbo Pascal was strictly not a standard, but influential enough to 
set one.


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-03-28 Thread Tomas Hajny via fpc-pascal

On 2023-03-28 11:33, Karoly Balogh via fpc-pascal wrote:


Hi,

 .
 .

You might wanna consider this approach, because if units somehow end up
cross-referencing each other, then you might run into difficulties
restructuring the code to use Units. Also, it is possible to
cross-reference units from eachother, but there are some caveats.

With the external way, you only need to change the declarations of
variables, no need to restructure the code, although for long-term
maintenance, that might be still beneficial.


Since some changes would be necessary anyway even if using imports (not 
only adding public names plus changing the external references, also 
some changes necessary to get multiple object files linked into the same 
final program), I'd suggest biting the bullet and changing the code to 
units, but yes, an alternative exists.


Tomas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-03-28 Thread Karoly Balogh via fpc-pascal
Hi,

On Mon, 27 Mar 2023, Jacob Kroon via fpc-pascal wrote:

> As I understand it, in order to translate this to something that FreePascal
> understands, the variable needs to go in a "unit" and be part of its
> interface. Then, pascal sources that needs to reference the variable should
> use this unit. Is this the easiest way forward ?

Probably yes, but there might be an alternative, see below. But as far as
I understand, Unit is a Turbo Pascal concept, so any Pascal programming
dialect that predates it, probably don't understand it.

> I thought maybe I instead could adapt the syntax like:
>
> var
> foobar : integer; external;
>
> but with this I still get undefined references when linking. Using units seems
> ok.

Yes, because all symbols in a Pascal unit are stored as mangled names,
which includes the Unit name. This way you can have "foobar" defined in
two different units, and can still reference them as Unit1.foobar; and
Unit2.foobar;. But of course it will cause linker errors, because the
compiler has no way of knowing the right mangled name. External is
normally used to link against C libraries, which don't use name mangling.

If you want to export a variable without name mangling, you must declare a
public name for it, something like:

var
  foobar: integer; public name '_myfoobar';

Then reference it as:

var
  foobar: integer; external name '_myfoobar';

You might wanna consider this approach, because if units somehow end up
cross-referencing each other, then you might run into difficulties
restructuring the code to use Units. Also, it is possible to
cross-reference units from eachother, but there are some caveats.

With the external way, you only need to change the declarations of
variables, no need to restructure the code, although for long-term
maintenance, that might be still beneficial.

Charlie
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-03-28 Thread Tomas Hajny via fpc-pascal

On 2023-03-27 11:45, Jacob Kroon via fpc-pascal wrote:


Hi,


I have some old Pascal code that was compiled in a CPM environment
using the Pascal/MT+ compiler from Digital Research. I'm trying to get
this project to build in a modern environment, for a start using
FreePascal.

First, is anyone aware of a tool for converting this dialect of Pascal
to something that FreePascal will accept ?


Sorry, no idea.



Second, the old code contains a lot of:

var
foobar : external integer;

in sources that reference 'foobar', then there is a declaration in one 
of them:


var
foobar : integer;

As I understand it, in order to translate this to something that
FreePascal understands, the variable needs to go in a "unit" and be
part of its interface. Then, pascal sources that needs to reference
the variable should use this unit. Is this the easiest way forward ?


Yes, most likely.



I thought maybe I instead could adapt the syntax like:

var
foobar : integer; external;

but with this I still get undefined references when linking. Using
units seems ok.


Indeed - while using the keyword 'external' as outlined in your modified 
example would be possible (even for importing a variable from another 
FPC compiled unit), it's primary purpose is for importing variables 
coming from object files compiled using different compilers (e.g. C, 
etc.) and there's no reason for using it for variables declared in a FPC 
unit in most cases (let's put some special cases aside for now).


Tomas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


[fpc-pascal] Converting old pascal written for Pascal/MT+ compiler

2023-03-28 Thread Jacob Kroon via fpc-pascal

Hi,

I have some old Pascal code that was compiled in a CPM environment using 
the Pascal/MT+ compiler from Digital Research. I'm trying to get this 
project to build in a modern environment, for a start using FreePascal.


First, is anyone aware of a tool for converting this dialect of Pascal 
to something that FreePascal will accept ?


Second, the old code contains a lot of:

var
foobar : external integer;

in sources that reference 'foobar', then there is a declaration in one 
of them:


var
foobar : integer;

As I understand it, in order to translate this to something that 
FreePascal understands, the variable needs to go in a "unit" and be part 
of its interface. Then, pascal sources that needs to reference the 
variable should use this unit. Is this the easiest way forward ?


I thought maybe I instead could adapt the syntax like:

var
foobar : integer; external;

but with this I still get undefined references when linking. Using units 
seems ok.


Bets regards
Jacob
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal