Recent

Author Topic: [SOLVED] Why does $fpctarget not work in fpc.cfg?  (Read 6384 times)

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1353
  • Professional amateur ;-P
[SOLVED] Why does $fpctarget not work in fpc.cfg?
« on: July 14, 2025, 05:24:04 pm »
Hey Y'All,

First: Not really sure if this is the right topic, so please move if necessary.

For the past hour or so, I've been banging my head against a wall, and not even the bots helped me !!!

I'm trying to cross-compile to i8086-msdos with trunk updated today, After a bit of fumbling, learned that the provide units were compiled with -WmMedium.
The thing I'm trying to cross-compile needs -WmLarge.
I had a quick look at the fpc.cfg and found this:
Code: Bash  [Select][+][-]
  1. # Search for $fpctarget/$fpcsubarch-$fpcmemorymodel/ subdirectory first
  2. # for i8086 CPU
  3. #ifdef cpui8086
  4. -Fu/home/gcarreno/FreePascal/fpc/units/$fpctarget/$fpcsubarch-$fpcmemorymodel
  5. -Fu/home/gcarreno/FreePascal/fpc/units/$fpctarget/$fpcsubarch-$fpcmemorymodel/*
  6. -Fu/home/gcarreno/FreePascal/fpc/units/$fpctarget/$fpcsubarch-$fpcmemorymodel/rtl
  7. #endif
I made absolute sure that those variables/macros where not put there by fpcupdeluxe. And fpc.cfg is littered with more of that.

Alas... They don't work AT ALL!!!

What am I missing here???

Cheers,
Gus
« Last Edit: July 17, 2025, 04:51:04 pm by Gustavo 'Gus' Carreno »

dbannon

  • Hero Member
  • *****
  • Posts: 3826
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Why does $fpctarget not work in fpc.cfg?
« Reply #1 on: July 15, 2025, 09:12:31 am »
For the past hour or so, I've been banging my head against a wall, and not even the bots helped me !!!
Gus, you get the bots to help you bang your head on the wall ? Wow.

Gus, can you tell use where the units you expect to use are actually ?  I'm guessing

Code: [Select]
/home/gcarreno/FreePascal/fpc/units/i386-msdos/<MEMORYMODEL>
I assume your "$fpcsubarch" is nil but have no idea how the memory model is described. Anyway, how does what is there compare with the stanza in fpc.cfg ?

You can, put fpc in verbose mode, capture the output and look to see where it is actually looking for your units, again to get some idea of how that compares with reality.  Its pretty wordy, best saved to a file ....

I have never found a way to get FPC to tell me what env variable it sets, would make thing a lot easier IMHO.

Davo

Lazarus 4, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1353
  • Professional amateur ;-P
Re: Why does $fpctarget not work in fpc.cfg?
« Reply #2 on: July 15, 2025, 02:17:12 pm »
Hey Davo,

I thank you very much for you input!! I ultimately solved the unit search thang.

But my main question is:
Why are things like $fpctarget, $fpcsubarch and $fpcmemorymodel present in fpc.cfg, if they don't contain anything at all?

In essence what I want to know is if that is some remnant of something old, or was it dropped by fpcupdeluxe.
I suspect that fpcupdeluxe is not the one putting that there, but I could be inserting foot in mouth.

In the end, why on earth did the core team left that on fpc.cfg, or why the heck does fpcupdeluxe thinks that it works?
That's the more pressing question after all!!

Cheers,
Gus

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1877
Re: Why does $fpctarget not work in fpc.cfg?
« Reply #3 on: July 15, 2025, 02:31:48 pm »
This is not a leftover from fpcupdeluxe.
Look at the FPC sources that contain the standard settings for fpc.cfg file [fpccfg.inc].
Its all there. And it works.

dbannon

  • Hero Member
  • *****
  • Posts: 3826
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Why does $fpctarget not work in fpc.cfg?
« Reply #4 on: July 15, 2025, 02:40:37 pm »
But my main question is:
Why are things like $fpctarget, $fpcsubarch and $fpcmemorymodel present in fpc.cfg, if they don't contain anything at all?


No, those "replaceable parameters are a "good thing". They are set by the FPC process when it reads the cfg file so, with a little bit of tuning, you can use multiple versions of the compiler with the same cfg file. In each case, pointing to the appropriate units fo that compiler.

It great !

Davo
Lazarus 4, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Thaddy

  • Hero Member
  • *****
  • Posts: 19272
  • Glad to be alive.
Re: Why does $fpctarget not work in fpc.cfg?
« Reply #5 on: July 15, 2025, 02:41:17 pm »
Yes, it works. Although I frequently edit my fpc.cfg to conform to my own way of installing.
Then again: fpc.cfg is sufficiently documented.
objects are fine constructs. You can even initialize them with constructors.

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1353
  • Professional amateur ;-P
Re: Why does $fpctarget not work in fpc.cfg?
« Reply #6 on: July 15, 2025, 02:52:00 pm »
Hey Davo, Thaddy,

Ok... Both of you just got me even more confused !!!

For me they are NOT working!!!

Is this a thing of cross-compiling versus not cross-compiling?!?!?!?

I noticed this issue while cross-compiling and have not tested in a non cross-compiling context.

In my case this WORKS:
Code: Bash  [Select][+][-]
  1. #IFDEF FPC_CROSSCOMPILING
  2. #IFDEF MSDOS
  3. #IFDEF CPUI8086
  4. -FD/home/gcarreno/FreePascal/cross/bin/i8086-msdos
  5. -Fu/home/gcarreno/FreePascal/fpc/units/i8086-msdos
  6. -Fu/home/gcarreno/FreePascal/fpc/units/i8086-msdos/*
  7. -XP
  8. -XX
  9. -CX
  10. -Xs
  11. #ENDIF CPUI8086
  12. #ENDIF MSDOS
  13. #ENDIF FPC_CROSSCOMPILING

And this WORKS NOT:
Code: Bash  [Select][+][-]
  1. #IFDEF FPC_CROSSCOMPILING
  2. #IFDEF MSDOS
  3. #IFDEF CPUI8086
  4. -FD/home/gcarreno/FreePascal/cross/bin/$fpctarget
  5. -Fu/home/gcarreno/FreePascal/fpc/units/$fpctarget
  6. -Fu/home/gcarreno/FreePascal/fpc/units/$fpctarget/*
  7. -XP
  8. -XX
  9. -CX
  10. -Xs
  11. #ENDIF CPUI8086
  12. #ENDIF MSDOS
  13. #ENDIF FPC_CROSSCOMPILING

And just to make clear: FPC/Lazarus trunk, updated yesterday.

Cheers,
Gus

dbannon

  • Hero Member
  • *****
  • Posts: 3826
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Why does $fpctarget not work in fpc.cfg?
« Reply #7 on: July 15, 2025, 03:05:52 pm »
OK, so cross compiling, in your case means target = i8086-msdos ? FPC will have its own idea of what to replace $fpctarget with, and in this case when it has CPUI8086 defined.

I don't work with i8086 (and have not for some time) so don't know what FPC will replace $fpctarget with, I would have expected "i8086-msdos" but maybe not ?  You, by not using the replaceable parameter, override FPC and force it to use the files you have installed in /home/gcarreno/FreePascal/cross/bin/i8086-msdos

Thats OK, it will work apparently. And probably cause you no problem. So, don't worry, be happy !

(as I said, the only way I have been able to work out what FPC is using for a replaceable parameter is to closely watch the verbose output from a failed compile.)

Davo
Lazarus 4, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1353
  • Professional amateur ;-P
Re: Why does $fpctarget not work in fpc.cfg?
« Reply #8 on: July 15, 2025, 03:32:38 pm »
Hey Davo,

OK, so cross compiling, in your case means target = i8086-msdos ? FPC will have its own idea of what to replace $fpctarget with, and in this case when it has CPUI8086 defined.

Welp, apparently, in my case, fpc's idea is to NOT put anything in there :D

I don't work with i8086 (and have not for some time) so don't know what FPC will replace $fpctarget with, I would have expected "i8086-msdos" but maybe not ?  You, by not using the replaceable parameter, override FPC and force it to use the files you have installed in /home/gcarreno/FreePascal/cross/bin/i8086-msdos

The -FD is put in there when I install a cross-compiler via fpcupdeluxe.
The -Fu lines are mine and were missing for some reason I can't fathom.

Thats OK, it will work apparently. And probably cause you no problem. So, don't worry, be happy !

(as I said, the only way I have been able to work out what FPC is using for a replaceable parameter is to closely watch the verbose output from a failed compile.)

The bots did suggest fpc -va. When I tried that, none of  $fpctarget, $fpcsubarch or $fpcmemorymodel were ever reported. Hence my utter despair and frustration!!

Cheers,
Gus

PascalDragon

  • Hero Member
  • *****
  • Posts: 6398
  • Compiler Developer
Re: Why does $fpctarget not work in fpc.cfg?
« Reply #9 on: July 15, 2025, 09:39:14 pm »
For i8086-msdos the placeholders will contain the following values:

$fpctarget: msdos (NOT i8086-msdos!)
$fpcsubarch: one of 8086, 80186, 80286 or 80386
$fpcmemorymodel: one of tiny, small, medium, compact, large or huge.

If you installed the built compiler using make install (and suitable options) then the units will already be installed in the correct location. Don't know about fpcupdeluxe.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12905
  • FPC developer.
Re: Why does $fpctarget not work in fpc.cfg?
« Reply #10 on: July 15, 2025, 09:44:46 pm »
Afaik whatever the substitutions are, you should see them in -va output, at least during the parsing of the CFG phase.

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1353
  • Professional amateur ;-P
Re: Why does $fpctarget not work in fpc.cfg?
« Reply #11 on: July 15, 2025, 11:17:14 pm »
Hey PascalDragon,

For i8086-msdos the placeholders will contain the following values:

$fpctarget: msdos (NOT i8086-msdos!)
$fpcsubarch: one of 8086, 80186, 80286 or 80386
$fpcmemorymodel: one of tiny, small, medium, compact, large or huge.

I WILL take your word for it!! And I'm now suspecting that it's something fishy with my fpcupdeluxe install.
Why?
Welp, I tried this, with no success:
Code: Bash  [Select][+][-]
  1. -Fu/home/gcarreno/FreePascal/fpc/units/$fpctarget-msdos
  2. -Fu/home/gcarreno/FreePascal/fpc/units/$fpctarget-msdos/*

I tried this, with no success:
Code: Bash  [Select][+][-]
  1. -Fu/home/gcarreno/FreePascal/fpc/units/$fpctarget-i8086
  2. -Fu/home/gcarreno/FreePascal/fpc/units/$fpctarget-i8086/*

That's why I'm so bloody frustrated!!! Especially because I always got zilch when using fpc -va!!!
So... this is now, really, giving me the ick!!!
I'll need to confirm it's not a fpcupdeluxe-ism!! I need to look at all the other 7 installs I made with fpcupdeluxe to see if it's only in the trunk install, or if all installs suffer from this.
On a side note: I also noticed that any stable install I make with fpcupdeluxe, which is done with a shallow git clone, Lazarus will not have any icons on the menus, just the icons on the components bar. BUT... the fpcupdeluxe of trunk, that one has all the icons... Again, rather frustrating!!! And it even goes back to the days of SVN!!! Two of my early installs are from that era.
Huummm.... Could be a fpclazup issue... Again, more testing is needed, but this is not relevant to this subject, just a side note!!

If you installed the built compiler using make install (and suitable options) then the units will already be installed in the correct location. Don't know about fpcupdeluxe.

Yes, fpcupdeluxe does drop the necessary -WmMedium compiled units under <install folder>/fpc/units/i8086-msdos.
And @_skrzyp_ was kind to point out the download URL for the other memory models: https://downloads.freepascal.org/fpc/snapshot/trunk/i8086-msdos/
So, I'm golden in this matter!!

It's the damned thing of not being able to confirm what $fpctarget, $fpcsubarch or $fpcmemorymodel contain, or not contain, that's driving me up the walls :D

Cheers,
Gus

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1353
  • Professional amateur ;-P
Re: Why does $fpctarget not work in fpc.cfg?
« Reply #12 on: July 15, 2025, 11:27:16 pm »
Hey Marco,

Afaik whatever the substitutions are, you should see them in -va output, at least during the parsing of the CFG phase.

Very good advice!! I do, really, appreciate it every time you chime in!! Really !!
Even the bloody bots gave me that pearl :D

Alas, every time I tried it: ZILCH!!!

You see, I believe you and @PascalDragon when you say: This is what happens....
But I haven't been able to reproduce it under my fpcupdeluxe trunk install that was updated yesterday( 14 Jul 2025 ).
And that's driving me utterly NUTS!!! As you can imagine!!

But before I go to the GitLab issues and cry WOLF, I need to determine if this is a me problem, or a core team problem. It's only fair, I guess, amirite?!

Welp, even if it's a me problem... I then would need to understand what is making it so... Maybe then, and only then, should I go to the GitLab issues and cry WOLF ;)

Cheers,
Gus
« Last Edit: July 15, 2025, 11:48:58 pm by Gustavo 'Gus' Carreno »

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1353
  • Professional amateur ;-P
Re: Why does $fpctarget not work in fpc.cfg?
« Reply #13 on: July 15, 2025, 11:35:15 pm »
Hey PascalDragon,

OK, reset, lets start over!!

For i8086-msdos the placeholders will contain the following values:

$fpctarget: msdos (NOT i8086-msdos!)
$fpcsubarch: one of 8086, 80186, 80286 or 80386
$fpcmemorymodel: one of tiny, small, medium, compact, large or huge.

So, my next question is: In what, possible, conditions would fpc not fill out those placeholders/macros?

If I understand this, I guess I can either report it to @DonAlfredo or at the GitLab issues. Depending on my findings, of course. ( I'll leave the icons' issue for another spelunken adventure ;) )
It does not make sense to go cry WOLF at anyone, unless I have a grasp of the what's real, amirite?! :D

Cheers,
Gus

dbannon

  • Hero Member
  • *****
  • Posts: 3826
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Why does $fpctarget not work in fpc.cfg?
« Reply #14 on: July 16, 2025, 02:42:01 am »
Nice, PascalDragon has filled in the missing information (my guess was pretty bad). PD, how do you know those parameters ?  Is it doc'ed somewhere or you looked (or wrote) in the code ?

Gus, like I said, in verbose mode, you should see (a whole lot of stuff including) the compiler parsing the config file and then searching, in what it thinks is the right place for eg units. If you have replaceable parameters in the cfg file you will see it looking in the place it derived by putting that parameter into the config line in question.  Here is an example (64bit linux of course) 

Code: [Select]
dbannon@dell:~/Pascal/CLI$ fpc -va tsetdemo.pas > dump.txt
dbannon@dell:~/Pascal/CLI$ ls -l dump.txt
-rw-r--r-- 1 dbannon dbannon 462519 Jul 16 10:30 dump.txt
dbannon@dell:~/Pascal/CLI$

Some interesting lines from dump.txt , note number on left is a line number added by my view utility, you may not see that -

Code: [Select]
42 [0.004] Configfile search: /home/dbannon/.fpc.cfg
43 [0.004] Reading options from file /home/dbannon/.fpc.cfg
44 [0.004] Hint: Start of reading config file /home/dbannon/.fpc.cfg

342 [0.027] Using unit path: /home/dbannon/fpc-3.2.4/lib/fpc/3.2.4/units/x86_64-linux/rtl/
743 [0.035] Unitsearch: /home/dbannon/fpc-3.2.4/lib/fpc/3.2.4/units/x86_64-linux/httpd22/system.ppu

752 [0.035] Unitsearch: /home/dbannon/fpc-3.2.4/lib/fpc/3.2.4/units/x86_64-linux/rtl/system.ppu
753 [0.035] Searching file /home/dbannon/fpc-3.2.4/lib/fpc/3.2.4/units/x86_64-linux/rtl/system.ppu... found

Davo
Lazarus 4, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018