Recent

Author Topic: How to patch FPC Library ?  (Read 5600 times)

valerife

  • New Member
  • *
  • Posts: 10
How to patch FPC Library ?
« on: September 15, 2016, 05:49:42 pm »
Hello everyone,

I'm new to FPC and I want to patch a few things in the library fcl-web/fphttpclient.pp

However all of my modifications aren't taken in consideration when the project is built.

My first instinct was to guess it was a .ppu issue. The sources i am modifying are not the one getting build. I went to the /etc/fpc.cfg conf and update some path.
I replace this
Quote
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
by this
Quote
-Fu/usr/share/fpcsrc/$fpcversion/
-Fu/usr/share/fpcsrc/$fpcversion/*
-Fu/usr/share/fpcsrc/$fpcversion/rtl
-Fu/usr/share/fpcsrc/$fpcversion/packages/fcl-web/src/base/fphttpclient.pp
(I am updating my files in /usr/share/fpcsrc/...)
The compiler can't build anymore and tell me it doesn't find the fphttpclient.pp (Even if i put the path in my fpc.cfg).
Error message :
Quote
Free Pascal Compiler version 3.0.0 [2015/12/05] for x86_64
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling testupdatehttp.lpr
testupdatehttp.lpr(9,22) Fatal: Can't find unit fphttpclient used by testupdatehttp
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode

i ran a strace and the interesting thing is it looks like it s opening the folder:
Quote
[pid   477] open("/usr/share/fpcsrc/3.0.0/packages/fcl-web/src/base/", O_RDONLY|O_LARGEFILE) = 4                                                             
[pid   477] close(4)

In am on a Linux neon, installed all of fpc fpcsrc and lazarus with the .deb

Any pointer for where to look at would be much appreciated,
Thanks

Leledumbo

  • Hero Member
  • *****
  • Posts: 8746
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: How to patch FPC Library ?
« Reply #1 on: September 15, 2016, 06:05:52 pm »
I replace this
Quote
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
-Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
by this
Quote
-Fu/usr/share/fpcsrc/$fpcversion/
-Fu/usr/share/fpcsrc/$fpcversion/*
-Fu/usr/share/fpcsrc/$fpcversion/rtl
-Fu/usr/share/fpcsrc/$fpcversion/packages/fcl-web/src/base/fphttpclient.pp
You might want to read the documentation what -Fu means. Certainly it's NOT an option to point specific unit path. And even worse, you should NEVER point it to source code, only compiled units.

If you need to update certain fpc shipped source code, after modification execute make in the corresponding directory. In your case, it's fcl-web (might fail when you haven't built its dependencies as well). Or if that's too difficult, execute it in top level source directory which is /usr/share/fpcsrc. Note that you'll need to be root or chmod the whole fpcsrc as the script will build everything under that directory. If make goes fine, you'll need to install the compiled units, each is build inside their own package directory. You can simply cp them to /usr/lib/fpc/$fpcversion/units/$fpctarget/fcl-web (or use make install INSTALL_PREFIX=/usr). Note that executing make install at the top level directory will reinstall everything, which might or might not be desirable.

MikeOnline

  • Newbie
  • Posts: 1
Re: How to patch FPC Library ?
« Reply #2 on: March 06, 2021, 09:22:03 am »
The steps in the previous post helped me patch FPC 3.2.0, specifically patching packages/fcl-web/src/openssl.pas, on macOS, with a code change posted at https://forum.lazarus.freepascal.org/index.php/topic,50350.msg374104.html#msg374104.  I was unsuccessful building and copying individual packages, but doing the whole thing worked fine.

The following commands worked reliably from Terminal:

Code: Bash  [Select][+][-]
  1. sudo su -
  2. cd /usr/local/share/fpcsrc/packages/fcl-web/src
  3. nano openssl.pas   # see link, above, for the fpc 3.2.0 patch needed to support https with fphttpclient and opensslsockets on newer macOS versions
  4. cd /usr/local/share/fpcsrc
  5. make all
  6. make install    # no prefix required
  7. cd /Applications/Lazarus
  8. make clean all
  9. cd /usr/local/bin
  10. unlink lazbuild
  11. ln -s /Applications/Lazarus/lazbuild
  12. exit
  13.  

 

TinyPortal © 2005-2018