* * *

Author Topic: Recompile FPC units in Lazarus  (Read 1942 times)

BeanzMaster

  • Full Member
  • ***
  • Posts: 147
Recompile FPC units in Lazarus
« on: June 27, 2018, 03:47:35 pm »
Hi,

 it is possible to include (or force FPC's units) to be recompiled) in Lazarus from command "clean and compile" or another.
I'm search where is a bug (see : http://forum.lazarus.freepascal.org/index.php/topic,41674.msg289709.html#msg289709)  is. I not sure  where it is exactly and i want to make some test before report it in bugtracker.

Thanks in advance

wp

  • Hero Member
  • *****
  • Posts: 4916
Re: Recompile FPC units in Lazarus
« Reply #1 on: June 27, 2018, 05:43:55 pm »
This is a bit more difficult than recompiling LCL units, and I am not sure if I myself am doing it in the most efficient way.

First of all, get yourself fpc trunk because your issue may already have been fixed, don't waste your time on solved issues, and fpc developers usually only accept patches for the current version.

Then get yourself fpcupdeluxe and install trunk versions of fpc and Lazarus. Before doing this click "Setup+" and enter "-gl" ('l" is lowercase L) in the option boxes for fpc and Lazarus - this means that both programs will be built for the debugger. This installation does not interfere with the standard installation.

When fpcupdeluxe is finished (it puts an icon on the desktop, after some time...) you are ready to go.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

BeanzMaster

  • Full Member
  • ***
  • Posts: 147
Re: Recompile FPC units in Lazarus
« Reply #2 on: June 27, 2018, 11:57:13 pm »
This is a bit more difficult than recompiling LCL units, and I am not sure if I myself am doing it in the most efficient way.

First of all, get yourself fpc trunk because your issue may already have been fixed, don't waste your time on solved issues, and fpc developers usually only accept patches for the current version.
Same bug in Lazarus 1.9 FPC 3.1.1 revision 58201

Then get yourself fpcupdeluxe and install trunk versions of fpc and Lazarus. Before doing this click "Setup+" and enter "-gl" ('l" is lowercase L) in the option boxes for fpc and Lazarus - this means that both programs will be built for the debugger. This installation does not interfere with the standard installation.

When fpcupdeluxe is finished (it puts an icon on the desktop, after some time...) you are ready to go.

I say perfectly how work FPCUpDeluxe i've made a tutorial on it.

Thank for trick for Setup+ and -gl parameters. I don't know this.

I'll try thanks

BeanzMaster

  • Full Member
  • ***
  • Posts: 147
Re: Recompile FPC units in Lazarus
« Reply #3 on: June 28, 2018, 12:54:04 am »
Ok i've test but not worked if i make some change in FPCanvas.inc for example how force this unit to be recompile. At this time i can put whatever  in fpc source files they are never recompiled

Do I have to go through Make in the command line every time?

How to ?

Note i have also delphi installed on my pc
« Last Edit: June 28, 2018, 01:02:17 am by BeanzMaster »

PascalDragon

  • Full Member
  • ***
  • Posts: 190
  • Compiler Developer
Re: Recompile FPC units in Lazarus
« Reply #4 on: June 28, 2018, 10:32:17 pm »
Yes, you need to rebuild so that all dependencies are updated as well.

BeanzMaster

  • Full Member
  • ***
  • Posts: 147
Re: Recompile FPC units in Lazarus
« Reply #5 on: June 28, 2018, 11:51:05 pm »
Hi

Thanks PascalDragon

I'll try

wp

  • Hero Member
  • *****
  • Posts: 4916
Re: Recompile FPC units in Lazarus
« Reply #6 on: June 29, 2018, 12:29:23 am »
Rebuilding the entire fpc is a pain!
This is what Michl once told me, and it is great:
  • You need a test project - don't do this with a "real" project if possible.
  • Then add the fpc unit which you want to debug to the project. Confirm to add the path to the unit path.
  • Try to compile.
  • It will fail because other units are not found.
  • Look at the error message to learn which unit or include file is missing.
  • If you don't know where the unit is look at the uses list of the unit in which the missing unit is reported. CTRL-Click on the unit name to open it from its original place. Move the mouse over the corresponding tab of the source editor. A hint window will pop up showing the path to the missing unit.
  • Add it to the project, too.
  • Sometimes there is a version conflict or duplicate unit message. In this case do a "Run" > "Clean up and build".
  • Repeat, i.e. compile and add the missing unit to the project. Always accept to add the path.
  • In the end you will be able to compile your test project; all compiled files will go into your project's lib folder, i.e. you should not interfere with the installation (don't kill me if it does...)
  • Now go to the project options, "Additions and overrides" and add a Custom Option "-gw2". This is definitely good for Windows, maybe you have to experiment in case of other OSs (you find the -g* options on page "Debugger").
  • compile. This will rebuild the project and all required units with dwarf2 debugger information (or what you selected).
  • Debug your problem, change the fpc unit, and the changed unit will be used in your project. Test your change etc -- standard debugging...
  • Apart from the setup phase during which you must add all needed units this is like debugging and testing any other project.
Same bug in Lazarus 1.9 FPC 3.1.1 revision 58201
Still I urge you to debug with with FPC 3.1.1. Because if you can fix the issue and submit a patch the developers can more easily apply it.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Pascal

  • Hero Member
  • *****
  • Posts: 711
Re: Recompile FPC units in Lazarus
« Reply #7 on: June 29, 2018, 06:20:09 am »
Thank for trick for Setup+ and -gl parameters. I don't know this.

You should also use "-O-". This prevents strange behaviour when debugging fpc units due to
optimizations.
laz trunk - fpc trunk 32bit - Windows 10 Pro x64 (1803)

GetMem

  • Hero Member
  • *****
  • Posts: 3161
Re: Recompile FPC units in Lazarus
« Reply #8 on: June 29, 2018, 09:43:01 am »
In order to debug fpc units you must recompile fpc with the following options: "-g -gl -O-". To avoid complication just use Fpcupdeluxe(very useful application), all you have to do is to add "-g -gl -O-" to Advanced settings/FPC options, see attached image for more details. This is why I always keep a separate FPC/Lazarus install for debugging. When necessary I do a quick update, it takes only a few minutes.

BeanzMaster

  • Full Member
  • ***
  • Posts: 147
Re: Recompile FPC units in Lazarus
« Reply #9 on: June 29, 2018, 11:30:56 pm »
Hi to all

@getmem : Thanks but not working with last trunk and last fpcudeluxe 1.6.1e

returns errors :

Quote
fpcupdeluxe: info: FPC builder: Detected source version FPC: 3.1.1
fpcupdeluxe: info: FPC builder: Using FPC bootstrap compiler with version: 3.0.4
fpcupdeluxe: Start of compile error summary.
genmath.inc(2036,12) Error: Incompatible types: got "Single" expected "TExtended80Rec.Array[0..9] Of Byte"
fpcupdeluxe: Start of compile error summary.
system.pp(665) Fatal: There were 1 errors compiling module, stopping
genmath.inc(2036,12) Error: Incompatible types: got "Single" expected "TExtended80Rec.Array[0..9] Of Byte"
fpcupdeluxe: Start of compile error summary.
Fatal: Compilation aborted
system.pp(665) Fatal: There were 1 errors compiling module, stopping
fpcupdeluxe: Start of compile error summary.
fpcupdeluxe: ERROR: FPCNativeInstaller (BuildModuleCustom: FPC): Error running make for FPC failed with exit code 2
Same issue with "-g -gl", "-gl -O-", only "-gl" and also with nothing

It's seems the problem come from the Last Changed Date: 2018-06-29 22:51:32 +0200 (ven., 29 juin 2018)

So i'm just waiting a bit

@wp : I'll try with another installed trunk version i have



« Last Edit: June 30, 2018, 10:24:02 am by BeanzMaster »

GetMem

  • Hero Member
  • *****
  • Posts: 3161
Re: Recompile FPC units in Lazarus
« Reply #10 on: June 29, 2018, 11:48:31 pm »
Quote
@getmem : Thanks but not working with last trunk and last fpcudeluxe 1.6.1e
The error has nothing to do with: "-g -gl -O-". You should wait for the next fix. Such issues are normal for a dynamical system as FPC trunk.

PascalDragon

  • Full Member
  • ***
  • Posts: 190
  • Compiler Developer
Re: Recompile FPC units in Lazarus
« Reply #11 on: June 30, 2018, 10:49:38 am »
Rebuilding the entire fpc is a pain!

I don't know about you, but for me it's a simple
Code: [Select]
make clean all install FPMAKEOPT="-T <cpucount>" -j <cpucount> INSTALL_PREFIX=/whereever/I/put/my/trunk/install

wp

  • Hero Member
  • *****
  • Posts: 4916
Re: Recompile FPC units in Lazarus
« Reply #12 on: June 30, 2018, 11:15:35 am »
How long does it take?
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

BrunoK

  • Jr. Member
  • **
  • Posts: 64
Re: Recompile FPC units in Lazarus
« Reply #13 on: June 30, 2018, 02:42:23 pm »
The content of message Posted by: wp « on: June 29, 2018, 12:29:23 am is very good.

=== Windows only ===

For myself, in my FPC D:\fpc-laz-asus\FPC directory I have the following substructure :
D:\fpc-laz-asus\FPC\3_0_4               : Complete 3_0_4 source and -O2 units
D:\fpc-laz-asus\FPC\3_0_4-dbg-bak : Only units I build for debugging -O1 + some debug switches
D:\fpc-laz-asus\FPC\3_0_4-dbg        : Only units that I copied from D:\fpc-laz-asus\FPC\3_0_4-dbg-bak that interest me with the correct substructure. They have to be deleted from this directory when in non debug mode

in fpc.cfg used by fpc.exe I have AFTER the
# searchpath for units and other system dependent things
etc... block
2 additional lines :
# DEBUG searchpath for debug units
-FuD:\fpc-laz-asus\FPC\3_0_4-dbg\units\$fpctarget/*

The fpc compiler then considers that additional -FuD as overrides, for .o and .ppu's in it, BEFORE the normal -O2 in D:\fpc-laz-asus\FPC\3_0_4\units are considered.

See attachment .txt file containing the commands I copy to the command prompt for
building the FPC rtl directory.
I more or less frequently also build debug version for \packages\fcl-db with usable results.

Switches that give me reasonable success for debugging are :
FPC : OPT="-O1 -gw2 -godwarfsets -gl"
+ in lazarus : -O1  -gw2 -godwarfsets -gl
option -OoREGVAR improves speed but makes debugging slightly more difficult ...

Note 1 : Sometimes I manage to make a real mess ... that takes hours to clean up. Dont forget backups !
Note 2 : If you have made modifications to an FPC source within Lazarus editor, don't forget to save them before redoing a make, I have been catched by that a few times.

BeanzMaster

  • Full Member
  • ***
  • Posts: 147
Re: Recompile FPC units in Lazarus
« Reply #14 on: June 30, 2018, 03:30:52 pm »
Thanks Bunok, i'll test to. Those take me a little time to see what the best way for me  8-)

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus