Recent

Author Topic: Difference in fpc and lazarus compiling  (Read 2575 times)

tetrastes

  • Hero Member
  • *****
  • Posts: 600
Re: Difference in fpc and lazarus compiling
« Reply #30 on: October 29, 2024, 01:54:21 pm »
Generate PIC code ? Yeah ?

It make no difference to the already working fpc build.  Which way do you expect it to make a difference ?

Davo

Oh, it seems you think I talk about compiling fpc itself? No, I mean compiling OP's tst.pas with -Cg option.

dbannon

  • Hero Member
  • *****
  • Posts: 3156
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Difference in fpc and lazarus compiling
« Reply #31 on: October 30, 2024, 12:16:49 am »
(Generate PIC code)
Oh, it seems you think I talk about compiling fpc itself? No, I mean compiling OP's tst.pas with -Cg option.

Nope, its me not being clear. I can and did easily test OP's small example using just FPC both with and without -Cg.  But both work identically. Now, I see you mention that adding -Cg (as Lazarus does) breaks things, so, if thats the case, me adding -Cg to my fpc command line test would make a broken binary ?  Sorry, no.

No point me adding -Cg- to my in-Lzarus test because my plain Lazarus test produces a working binary too.

We need someone who is using an officially packaged Lazarus (ie a deb or, maybe rpm) to do that test.

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

tetrastes

  • Hero Member
  • *****
  • Posts: 600
Re: Difference in fpc and lazarus compiling
« Reply #32 on: October 30, 2024, 10:32:18 am »
Thank you for testing!
There is something weird indeed.

HotShoe

  • New Member
  • *
  • Posts: 36
Re: Difference in fpc and lazarus compiling
« Reply #33 on: October 30, 2024, 05:43:09 pm »
OK, so I can't leave stuff like this alone, so I did the following. I uninstalled the fpcupdeluxe and the .deb packaged installations completely. Including config file directories , all /usr/lib/fpc and /usr/share/lazarus, /etc config files, and config files in my home .config  and .Lazarus directories.

Then I reinstalled laz with the 3 packages on the lazarus-ide.org page by clicking the Download Now link. The installed went fine and then I had a a lazarus that brought up a new project and factory colors when run. None of my defined directories or options were in place, so it was as close to a virgin install as I can make it.

I set up my directories in fp.cfg and in fpc.cfg so that my components and stuff can be found, and set up my colors for the editor, fonts. etc. Now I had a working lazarus that can compile all the stuff I do. I am the odd one in that I am the only one in the company that works with pascal (plus c++ and java for the few android apps we still maintain).

Now when I run fpc tst.lpr I get perfect borders. It's the same when I load it into fp ide. When I compile with lazarus, I get the same bad borders as I originally did. Cool, now I can play.

First I tried adding the -Cg to the compiler commands in Laz. That did nothing, so I removed that and tried the -dDisableUTF8RTL in the options. That also did nothing. Yes I am being careful that I am using the same mode (default, debug, release) always using release mode.

Then I uninstalled and wiped the config files again and re-installed with the lazarus package from the Neon (ubuntu) repository. This is the one that worked fine, but after this install, it was back to not working (as in not giving me borders).

Right now, I am back to the official 3 package install from the lazarus site (because it's 3.6). I know that laz can create the same binary as fpc/FP IDE because it did so on this machine for a full day and night until I got cocky and decided to find out why. I will eventually stumble across the right switch or setting, it might just take a while though. :)

--- Jem

TRon

  • Hero Member
  • *****
  • Posts: 3650
Re: Difference in fpc and lazarus compiling
« Reply #34 on: October 30, 2024, 05:53:30 pm »
@HotShoe:
option -va. It is a compiler option so that works for both FPC and Lazarus.

It generates output of all that the compiler does (the log is long). It is also possible to get more detailed information on the linking stage by passing the -k--<linker-option> (search for gnu binutils ld for the manual).

That should cover all information required to determine the difference of building between FPC and Lazarus (Lazarus uses the same FPC executable, unless you have multiple installations and configured things differently).

I explicitly mention the latter because I do not know what these packages you use(d) actually contains (e.g. could be Lazarus with its own configured FPC)

There is no need to re-install over and over.

There simply seem to be a difference somewhere. Except for the -Cg option none of the compiler options made any difference for me.

It is definitely a encoding related issue but it also beats me where it originates from. Because I checked the compiler output myself (and did not notice any other differences) I would suspect a difference at linking stage.
« Last Edit: October 30, 2024, 05:56:55 pm by TRon »
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

HotShoe

  • New Member
  • *
  • Posts: 36
Re: Difference in fpc and lazarus compiling
« Reply #35 on: October 30, 2024, 06:56:34 pm »
Thanks TRon, I'll try those. One thing interesting that I have noticed is that when I compile in laz after setting everything back to stock settings, and do a build. Then when I use fpc in a terminal it rebuilds the source and dependencies, so it sees something has changed and makes some changes that it likes and then rebuilds again. I think that is where the problem (difference) lies.

--- Jem

tetrastes

  • Hero Member
  • *****
  • Posts: 600
Re: Difference in fpc and lazarus compiling
« Reply #36 on: October 30, 2024, 10:05:40 pm »
First I tried adding the -Cg to the compiler commands in Laz.

This option is already added by Lazarus, you have to add -Cg-. Or compile from terminal with fpc -Cg and see, if there are bad borders.
« Last Edit: October 30, 2024, 10:12:32 pm by tetrastes »

HotShoe

  • New Member
  • *
  • Posts: 36
Re: Difference in fpc and lazarus compiling
« Reply #37 on: October 30, 2024, 11:55:28 pm »
I just spent over an hour going through the -va outputs on both laz and fpc. then I went through all of the compiler switches being sent. Low and behold, when I added the -Cg- switch to turn off pic, the borders worked fine. I tried this switch back in the beginning when someone, (tetrastes maybe?) suggested it, but that was on the fpcup installed version.

Anyway, tetrastes is absolutely right that on this install at least, adding the -Cg- switch fixes the bad borders.

Thanks,
--- Jem

HotShoe

  • New Member
  • *
  • Posts: 36
Re: Difference in fpc and lazarus compiling
« Reply #38 on: October 31, 2024, 02:46:06 am »
Ok, time to add to the head scratching. The little tst program that I attached in an earlier post works. It doesn't matter what I change in that program, it just works. DT, my filemanager project however does not just work.

I had put in a line to print some drawing characters while testing different options to get borders to work. Going through the code now that the borders are working I found this line:

stats.WriteAC(2,20,colors(white,red),ACS_RTEE);

That is the first line after the status window is initialized and then the stats.show is called. So what you say? it's just a left over line from testing right? Right, but if I comment that line out, the dt program no longer draws pretty borders. Yep they go back to the bad borders. Un-comment the line again and everything looks just fine.

So a writeac somehow forces the character set to initialize to show drawing characters? I don't have an answer. I don't know enough about how the Laz IDE works, but it is certainly interesting.

--- Jem

TRon

  • Hero Member
  • *****
  • Posts: 3650
Re: Difference in fpc and lazarus compiling
« Reply #39 on: October 31, 2024, 11:54:59 pm »
@HotShoe:
The xxxxAC routines have some special checking against certain characters and bails out if the default used characters are not used. The bail out fallback part relies on your system termcap settings.

I checked this code/implementation before joining the discussion and initially thought that was the culprit of your issue but I removed that post because in my specific situation (and according to the test-program and description) I was able to solve it with the -Cg parameter (just as user tetrastes).

unit ocrt of ncurses contains the following comment at nWriteAC:
Quote
  Write a character from the alternate character set. A normal
  value from the alternate character set is larger than $400000.
  If the value passed here is 128..255, then we assume it to be
  the ordinal value from the IBM extended character set, and try
  to map it to curses correctly. If it does not map, then we just
  make it an alternate character and hope the output is what the
  programmer expected
. Note: this will work on the Linux console
  just fine, but for other terminals the passed value must match
  the termcap definition for the alternate character.
  Note: The cursor returns to it's original position.

Now, that still does not answer how to solve but at least provides a lead.
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

HotShoe

  • New Member
  • *
  • Posts: 36
Re: Difference in fpc and lazarus compiling
« Reply #40 on: November 01, 2024, 08:20:30 pm »
So it really is initializing the acs system, at least on linux. That's pretty cool, and good to know.

--- Jem

 

TinyPortal © 2005-2018