Recent

Author Topic: Possible to use a Package without source (only ppu and .o)?  (Read 2298 times)

af0815

  • Hero Member
  • *****
  • Posts: 560
Possible to use a Package without source (only ppu and .o)?
« on: November 29, 2019, 12:16:11 pm »
Is it possible to use a package in Lazarus if i provide only the packagefiles and the ppu and o files but not the source files.? For install in Lazarus and use with Lazarus.

It is clear for me, to use the same major version of fpc (and Lazarus), so the compiles ppu's have the same version. Actual i have Problems, because Lazarus want always to recompile (incompatible ppu) the ppu's and this didn't work without the sources.




 

« Last Edit: November 29, 2019, 12:18:00 pm by af0815 »
regards
Andreas

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8621
  • FPC developer.
Re: Possible to use a Package without source (only ppu and .o)?
« Reply #1 on: November 29, 2019, 12:48:38 pm »
Yes it should be possible provided same version etc and same architecture and all params.

But to avoid that the "source changed and is newer than ppu" which is based on timestamp protection triggers in, the base package must be compiled with -Ur:

Quote from: manual
-Ur Generate release unit files. These files will not be
recompiled, even when the sources are available. This is useful when making
release distributions. This also overrides the -B option for release
mode units.

af0815

  • Hero Member
  • *****
  • Posts: 560
Re: Possible to use a Package without source (only ppu and .o)?
« Reply #2 on: November 29, 2019, 07:27:47 pm »
THX for the tip.

Can i see this in the Unit flags - is this the flag 'release' ?

regards
Andreas

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8621
  • FPC developer.
Re: Possible to use a Package without source (only ppu and .o)?
« Reply #3 on: November 29, 2019, 08:00:27 pm »
Yes, I think so.

af0815

  • Hero Member
  • *****
  • Posts: 560
Re: Possible to use a Package without source (only ppu and .o)?
« Reply #4 on: December 04, 2019, 12:26:40 pm »
I have now a package from this thread https://forum.lazarus.freepascal.org/index.php/topic,46562.0.html with the release flag set, but it doesnt work. Lazzarus tried to recompile, but it fails without sources.

Edit:
Quote
Messages, Warnings: 1
Warning: other unit files search path (aka unit path) of "RVMediaLaz 1.0" contains "/home/andi/data/RVMediaTrialLazarusLinux/Source", which belongs to package "RVMediaLaz_Dsgn"
Compile package RVMediaLaz 1.0: Exit code 1, Errors: 1, Warnings: 1
Warning: Recompiling MRVInet, checksum changed for LCLIntf
rvmedialaz.pas(11,3) Fatal: Cannot find MRVInet used by RVMediaLaz, incompatible ppu=/home/andi/data/RVMediaTrialLazarusLinux/Source/lib/x86_64-linux/MRVInet.ppu, package RVMediaLaz
Quote
PPU-Analyser Version 3.0.4
Copyright (c) 1998-2013 by the Free Pascal Development Team

Analyzing /home/andi/data/RVMediaTrialLazarusLinux/Source/lib/x86_64-linux/MRVInet.ppu (v173)

Header
-------
Compiler version        : 3.0.4
Target processor        : x86_64
Target operating system : Linux-x86-64
Unit flags              : init, final, static_linked, little_endian, release, has_debug_info, dwarf_debug_info, local_symtable
FileSize (w/o header)   : 26952
Checksum                : 5365C3D0
Interface Checksum      : 5EE9DBCF
Indirect Checksum       : FB2F3219
Definitions stored      : 476
Symbols stored          : 709

Interface section
------------------
Module Name: MRVInet
« Last Edit: December 04, 2019, 12:30:34 pm by af0815 »
regards
Andreas

af0815

  • Hero Member
  • *****
  • Posts: 560
Re: Possible to use a Package without source (only ppu and .o)?
« Reply #5 on: December 04, 2019, 12:35:41 pm »
If create a package by myself it hase the same flags, compilerversion,....

Quote
PPU-Analyser Version 3.0.4
Copyright (c) 1998-2013 by the Free Pascal Development Team

Analyzing /home/andi/data/dummy/lib/x86_64-linux/newpackage.ppu (v173)

Header
-------
Compiler version        : 3.0.4
Target processor        : x86_64
Target operating system : Linux-x86-64
Unit flags              : init, static_linked, little_endian, release, has_debug_info, dwarf_debug_info, local_symtable
FileSize (w/o header)   : 1234
Checksum                : 813A276D
Interface Checksum      : 5E9D3734
Indirect Checksum       : 5C7C6389
Definitions stored      : 6
Symbols stored          : 9

Interface section
------------------
Module Name: NewPackage

It looks something goes wrong
regards
Andreas

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6471
    • wiki
Re: Possible to use a Package without source (only ppu and .o)?
« Reply #6 on: December 06, 2019, 12:39:05 am »
What are the full errors? Messages window, copy > copy all/original messages?  (just the last 20 or so lines).

If inclusive try with -va
Then the first 200 and last 200 lines.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6471
    • wiki
Re: Possible to use a Package without source (only ppu and .o)?
« Reply #7 on: December 06, 2019, 12:41:35 am »
Not sure, Lazarus also looks at the <name>.compiled file. If you do not want the IDE to do that, you may need to change something.... Not sure, never done that

af0815

  • Hero Member
  • *****
  • Posts: 560
Re: Possible to use a Package without source (only ppu and .o)?
« Reply #8 on: December 06, 2019, 07:11:12 pm »
Open the package, and use install. The following lines are copied out of the messagewindows. I think the line  Warning: Recompiling MRVInet, checksum changed for LCLIntf says why it tries to recompile.

Quote
....
Messages, Warnings: 1
Warning: other unit files search path (aka unit path) of "RVMediaLaz 1.0" contains "/home/andi/data/RVMediaTrialLazarusLinux/Source", which belongs to package "RVMediaLaz_Dsgn"
Compile package RVMediaLaz 1.0: Exit code 1, Errors: 1, Warnings: 1
Warning: Recompiling MRVInet, checksum changed for LCLIntf
rvmedialaz.pas(11,3) Fatal: Cannot find MRVInet used by RVMediaLaz, incompatible ppu=/home/andi/data/RVMediaTrialLazarusLinux/Source/lib/x86_64-linux/MRVInet.ppu, package RVMediaLaz
regards
Andreas

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6471
    • wiki
Re: Possible to use a Package without source (only ppu and .o)?
« Reply #9 on: December 06, 2019, 07:24:30 pm »
Open the package, and use install. The following lines are copied out of the messagewindows. I think the line  Warning: Recompiling MRVInet, checksum changed for LCLIntf says why it tries to recompile.

Quote
....
Messages, Warnings: 1
Warning: other unit files search path (aka unit path) of "RVMediaLaz 1.0" contains "/home/andi/data/RVMediaTrialLazarusLinux/Source", which belongs to package "RVMediaLaz_Dsgn"
Compile package RVMediaLaz 1.0: Exit code 1, Errors: 1, Warnings: 1
Warning: Recompiling MRVInet, checksum changed for LCLIntf
rvmedialaz.pas(11,3) Fatal: Cannot find MRVInet used by RVMediaLaz, incompatible ppu=/home/andi/data/RVMediaTrialLazarusLinux/Source/lib/x86_64-linux/MRVInet.ppu, package RVMediaLaz

Well, yes.
Any unit, that is used by your ppu, must be kept unchanged.

If unit A uses unit B, and unit B changes, then unit A must be recompiled. The ppu is no longer valid. That has nothing todo with how the path are set https://forum.lazarus.freepascal.org/index.php/topic,47582.msg341809.html#msg341809

You need the exact version of Lazarus against which RVMediaLaz  was compiled. If you use the installer, then it comes with all pre-build ppu (exactly so that 3rd party packages can be installed).

In theory, you should be able to re-build the lazarus packages, and they should end up with the same checksums.
But I do not know the exact details on how fpc computes them.
I would guess that changing optimization level, if it for example changes inline-ability, could change the checksum. I also am not sure, which checksums must match interface, or also implementation....

Also note: checksums are passed up recursively: A uses B uses C => C changes, then B will recompile, and even if B sources did not change, the checksum for B will (as it includes the checksum of all used packages). And the same A changes, as B then has changed.

So if you have ppu only packages there is no touching any of the used packages. No minor fixes, nothing. (This may even mean: no CLEAN rebuild of the IDE, not sure I would think checksums should be the same afterward, but.....)
« Last Edit: December 06, 2019, 07:26:38 pm by Martin_fr »

af0815

  • Hero Member
  • *****
  • Posts: 560
Re: Possible to use a Package without source (only ppu and .o)?
« Reply #10 on: December 06, 2019, 07:39:33 pm »
So it is not possible to use precompiled packagesfor Lazarus with depencies to any parts of Lazarus.

Because the LCLIntf or something else in Lazarus can make a checksum change. A simple patch eg. svn number change and a recompile can change this. So developer can not produce packages without source as Delphi can without having problems (Eg. test the component before buy).

It is confusing for me, because it looks like the other flags are only used as 'decoration' and the actual ppu format can only used with more fixed part like the fpc and not for dynamic parts like Lazarus.
« Last Edit: December 06, 2019, 07:45:21 pm by af0815 »
regards
Andreas

Handoko

  • Hero Member
  • *****
  • Posts: 3665
  • My goal: build my own game engine using Lazarus
Re: Possible to use a Package without source (only ppu and .o)?
« Reply #11 on: December 06, 2019, 07:52:37 pm »
I ever thought to write some free libraries but not open source. I haven't tried but I believe it can. First you write the module and compile it into Windows dll and Linux so files, then the source code to call the library's functions. By doing so you can make the library free while keeping the algorithm secret.

af0815

  • Hero Member
  • *****
  • Posts: 560
Re: Possible to use a Package without source (only ppu and .o)?
« Reply #12 on: December 06, 2019, 08:00:14 pm »
libraries dll and so have nothing to do with ppu's. And try to use a dll for installing components in Lazarus - no way (as far i see).
regards
Andreas

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6471
    • wiki
Re: Possible to use a Package without source (only ppu and .o)?
« Reply #13 on: December 06, 2019, 09:46:01 pm »
So it is not possible to use precompiled packagesfor Lazarus with depencies to any parts of Lazarus.

Because the LCLIntf or something else in Lazarus can make a checksum change. A simple patch eg. svn number change and a recompile can change this. So developer can not produce packages without source as Delphi can without having problems (Eg. test the component before buy).

It is confusing for me, because it looks like the other flags are only used as 'decoration' and the actual ppu format can only used with more fixed part like the fpc and not for dynamic parts like Lazarus.

Well that depends on what parts are fixed. If your fpc is on fpcupdeluxe, then that wont work either.

If you install a released Lazarus version, then that should not change.
But as Lazarus releases several times a year, the 3rd party would need to create new ppu-releases for their package each time Lazarus releases.

To a point that is expected.
Say your code depends on an Lcl function. If that function changes, by adding an extra param (albeit with default value), then your code still compiles. But the ppu would no longer work. Because the default param changes the asm code generated for your code.

Of course, if the interface did not change, then in theory your code should not depend on that, and keep working (that of course is, only if nothing was inlined).
I do not know, if Fpc is currently that clever.

Ultimately on Delphi (from what I know...) you have dynamic packages. If your code was build against a specific rtl or dcl package, then it will only run with that one (Or is there some magic, that I do not know). Though maybe (no idea here) Delphi is smarter in what changes it allows to be compatible (e.g. implementation might be allowed to change?) No idea.


marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8621
  • FPC developer.
Re: Possible to use a Package without source (only ppu and .o)?
« Reply #14 on: December 06, 2019, 10:02:57 pm »
Ultimately on Delphi (from what I know...) you have dynamic packages. If your code was build against a specific rtl or dcl package, then it will only run with that one (Or is there some magic, that I do not know). Though maybe (no idea here) Delphi is smarter in what changes it allows to be compatible (e.g. implementation might be allowed to change?) No idea.

It is not just that. Delphi is reluctant to recompile certain DCUs, just like FPC implements with -Ur. Keep in mind that Delphi also has dcu/dcr's for dynamic packages.

IOW I wouldn't throw the towel into the ring to quickly and try to build up both ends (the package generation side, and the package consuming side) as much as possible with -Ur.

If package X doesn't only depends on FPC, but also on Lazarus units (like lclintf), then that just means those ALSO compile those units with -Ur on both sides.

 

TinyPortal © 2005-2018