View Issue Details

IDProjectCategoryView StatusLast Update
0036689LazarusLCLpublic2020-02-20 10:12
ReporterAlfredAssigned ToMattias Gaertner 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version2.1 (SVN)Product Build 
Target VersionFixed in Version 
Summary0036689: FPC proxy canot be found if name is not exactly FPC.
DescriptionSometimes it is necessary to replace the standard FPC binary with something else, like a proxy for better install isolation.
At the moment, this is not possible due to unintended code-limitations.
The included simple patches for trunk and fixes solve this issue.
TagsNo tags attached.
Fixed in Revision62651 62652
LazTarget-
Widgetset
Attached Files
  • lazpatch_definetemplates_fixes_2_0_7.patch (541 bytes)
    Index: components/codetools/definetemplates.pas
    ===================================================================
    --- components/codetools/definetemplates.pas	(revision 62599)
    +++ components/codetools/definetemplates.pas	(working copy)
    @@ -3874,7 +3883,7 @@
     
       // check fpc<something>
       // Note: fpc.exe is just a wrapper, it can call pas2js
    -  if CompareFilenames(ShortFilename,'fpc')=0 then
    +  if IsFPCExecutable(AFilename,ErrorMsg,Run) then
         exit(true);
     
       ErrorMsg:='fpc executable should start with fpc or ppc';
    
  • lazpatch_definetemplates_trunk.patch (541 bytes)
    Index: components/codetools/definetemplates.pas
    ===================================================================
    --- components/codetools/definetemplates.pas	(revision 62598)
    +++ components/codetools/definetemplates.pas	(working copy)
    @@ -4006,7 +4006,7 @@
     
       // check fpc<something>
       // Note: fpc.exe is just a wrapper, it can call pas2js
    -  if CompareFilenames(ShortFilename,'fpc')=0 then
    +  if IsFPCExecutable(AFilename,ErrorMsg,Run) then
         exit(true);
     
       ErrorMsg:='fpc executable should start with fpc or ppc';
    

Activities

Alfred

2020-02-10 09:27

reporter  

lazpatch_definetemplates_fixes_2_0_7.patch (541 bytes)
Index: components/codetools/definetemplates.pas
===================================================================
--- components/codetools/definetemplates.pas	(revision 62599)
+++ components/codetools/definetemplates.pas	(working copy)
@@ -3874,7 +3883,7 @@
 
   // check fpc<something>
   // Note: fpc.exe is just a wrapper, it can call pas2js
-  if CompareFilenames(ShortFilename,'fpc')=0 then
+  if IsFPCExecutable(AFilename,ErrorMsg,Run) then
     exit(true);
 
   ErrorMsg:='fpc executable should start with fpc or ppc';
lazpatch_definetemplates_trunk.patch (541 bytes)
Index: components/codetools/definetemplates.pas
===================================================================
--- components/codetools/definetemplates.pas	(revision 62598)
+++ components/codetools/definetemplates.pas	(working copy)
@@ -4006,7 +4006,7 @@
 
   // check fpc<something>
   // Note: fpc.exe is just a wrapper, it can call pas2js
-  if CompareFilenames(ShortFilename,'fpc')=0 then
+  if IsFPCExecutable(AFilename,ErrorMsg,Run) then
     exit(true);
 
   ErrorMsg:='fpc executable should start with fpc or ppc';

Juha Manninen

2020-02-11 19:27

developer   ~0121016

It does not look right. Your patch makes function IsCompilerExecutable call function IsFPCExecutable.
However IsFPCExecutable already calls IsCompilerExecutable. There is a potential for an eternal loop.
IsFPCExecutable is not called from any Lazarus sources. I guess it is meant to be called from user programs.
IsCompilerExecutable on the other hand is called from many places. Which one of the calls poses the problem in your use case?
I think the code should be refactored somehow.
There is also function IsPas2JSExecutable which is similar to IsFPCExecutable. Mattias may have created this whole set of functions when Pas2JS support was added.

Juha Manninen

2020-02-11 19:40

developer   ~0121018

Last edited: 2020-02-11 19:41

View 2 revisions

FYI: usually a separate patch for the SVN fixes branch is not needed. The "patch" command and the related Subversion tools are good in merging stuff. In this case it would be a clean merge with some offset.
Another question is which changes are backported to fixes branch.
In this case the problem description is fuzzy. No steps to reproduce. Will there be side-effects (after the eternal loop issue is solved)?
Most likely if would not be backported.

Alfred

2020-02-12 07:48

reporter   ~0121034

As maintainer of fpcupdeluxe, I am always looking for better isolation of an install of FPC and Lazarus.
On UNIX, a script is created named fpc.sh that calls fpc with the config-file as a parameter (together with -n). I call this a FPC proxy.
On Windows, I want to do the same.
However.
The Makefile of Lazarus does not allow a bat-file to be used as a proxy for FPC.
E.g. fpc.bat is renamed as fpc.bat.exe : the Makefile only accepts *.exe as name for a FPC executable.
That caused me to create a proxy called fpcproxy.exe for Windows.
But fpcproxy.exe is rejected by the line I proposed to patch.

Conclusion:
My patch was not good: I overlooked the circular call you detected.
It would be nice if Lazarus would accept a FPC proxy with names like fpc*.sh and fpc*.bat and fpc*.exe
The Lazarus Makefile needs a change to accept anything other than *.exe (like *.bat). But I wanted to propose this change after review of this bug-report.

Juha Manninen

2020-02-16 16:36

developer   ~0121126

Last edited: 2020-02-16 16:43

View 2 revisions

I am back at my main development machine again and I tested this issue.
You didn't give any steps to reproduce the problem. Explaining makefile issues is not useful here because the patch affects function IsCompilerExecutable() in Codetools which has nothing to do with makefiles.

I created a file fpcproxy.sh with contents "fpc" and set its executable flag. Then I selected it as a compiler in Lazarus Options -> Files -> Compiler executable.
I get the following warning:
  The compiler file "/home/juha/SW/lazarus_trunk/fpcproxy.sh" does not look correct:
  Unusual compiler file name. Usually it starts with fpc, ppc or ppcross.
After that compilation fails with a "Panic: ..." message.
I get the same behavior with or without your patch! So please explain in what situation your patch fixes something.
In general try to be specific when reporting any bug.
BTW, function IsFPCExecutable() is deprecated since a year ago. Adding calls to deprecated functions is a bad idea in any case.

I am testing with Manjaro Linux with KDE, 64-bit.

Mattias Gaertner

2020-02-20 10:12

manager   ~0121172

IsCompilerExecutable should allow fpc*, as the comments in the code explained. I fixed that bug.
As Juha explained, it must not call IsFPCExecutable.

Issue History

Date Modified Username Field Change
2020-02-10 09:27 Alfred New Issue
2020-02-10 09:27 Alfred File Added: lazpatch_definetemplates_fixes_2_0_7.patch
2020-02-10 09:27 Alfred File Added: lazpatch_definetemplates_trunk.patch
2020-02-11 19:27 Juha Manninen Note Added: 0121016
2020-02-11 19:40 Juha Manninen Note Added: 0121018
2020-02-11 19:41 Juha Manninen Note Edited: 0121018 View Revisions
2020-02-12 07:48 Alfred Note Added: 0121034
2020-02-16 16:19 Juha Manninen Assigned To => Juha Manninen
2020-02-16 16:19 Juha Manninen Status new => assigned
2020-02-16 16:36 Juha Manninen Status assigned => feedback
2020-02-16 16:36 Juha Manninen LazTarget => -
2020-02-16 16:36 Juha Manninen Note Added: 0121126
2020-02-16 16:43 Juha Manninen Note Edited: 0121126 View Revisions
2020-02-20 10:12 Mattias Gaertner Assigned To Juha Manninen => Mattias Gaertner
2020-02-20 10:12 Mattias Gaertner Status feedback => resolved
2020-02-20 10:12 Mattias Gaertner Resolution open => fixed
2020-02-20 10:12 Mattias Gaertner Fixed in Revision => 62651 62652
2020-02-20 10:12 Mattias Gaertner Note Added: 0121172