Recent

Author Topic: getting fpc cross-compiling on Fedora Linux.  (Read 5392 times)

lazer

  • Sr. Member
  • ****
  • Posts: 269
getting fpc cross-compiling on Fedora Linux.
« on: October 13, 2022, 10:31:10 am »
Hi,

I'm using Fedora 35 and have installed Lazarus ( and hence fpc ) from distro.  Native building seems fine.

Now I need to compile for a win64 win32 targets.  Years ago I did this and it all worked out of the box, I was impressed. Now it's become a "challenge".

fpc files are installed in:
Code: Pascal  [Select][+][-]
  1. /usr/lib64/fpc/3.2.2/units/x86_64-linux/rtl
the source is in :
Code: Pascal  [Select][+][-]
  1. /usr/share/fpcsrc/packages
Code: Pascal  [Select][+][-]
  1. ls -d  /usr/share/fpcsrc/packages/rtl*
  2. /usr/share/fpcsrc/packages/rtl-console  /usr/share/fpcsrc/packages/rtl-generics  /usr/share/fpcsrc/packages/rtl-unicode
  3. /usr/share/fpcsrc/packages/rtl-extra    /usr/share/fpcsrc/packages/rtl-objpas
  4.  
This seems pretty standard but there is also :
Code: Pascal  [Select][+][-]
  1. /usr/share/fpcsrc/rtl

https://wiki.freepascal.org/Cross_compiling_for_Windows_under_Linux

It looks like I need to build the cross compiler since this is not provided in the distro pkg.

Code: Pascal  [Select][+][-]
  1. export FPCVER="3.2.2"
  2. cd /usr/share/fpcsrc/"$FPCVER"/
  3. make clean all OS_TARGET=win64 CPU_TARGET=x86_64
  4. make clean all OS_TARGET=win32 CPU_TARGET=i386
  5.  
There is a deviation here since $FPCVER seems to be "package" in this installation. In anycase I set that value and cd to that directory.

Code: Pascal  [Select][+][-]
  1. make clean all OS_TARGET=win64 CPU_TARGET=x86_64
...

Code: Pascal  [Select][+][-]
  1. make[1]: Leaving directory '/usr/share/fpcsrc/packages/fpmkunit'
  2. ./fpmake clean --localunitdir=.. --os=win64 --cpu=x86_64 -o -Twin64 -o -XPx86_64-win64- -o -Xr -o -dx86_64 --compiler=/usr/bin/ppcx64 -bu -scp
  3. ./fpmake compile --localunitdir=.. --os=win64 --cpu=x86_64 -o -Twin64 -o -XPx86_64-win64- -o -Xr -o -dx86_64 --compiler=/usr/bin/ppcx64 -bu -scp
  4. The installer encountered the following error:
  5. Could not find unit directory for dependency package "rtl" required for package "bzip2"
  6. make: *** [Makefile:1721: all] Error 1
  7.  
  8.  

I'm suspecting that the slightly non-standard tree is the cause. Maybe I need to symlink the rtl dir , can anyone advise ?

TIA.
« Last Edit: October 13, 2022, 10:51:13 am by lazer »

dbannon

  • Hero Member
  • *****
  • Posts: 3741
    • tomboy-ng, a rewrite of the classic Tomboy
Re: getting fpc cross-compiling on Fedora Linux.
« Reply #1 on: October 13, 2022, 11:29:24 am »

Hmm, the instructions you are following were written assuming a FPC installed as described. Sadly, distro packages like to move things around. You could try some symlinks in the appropriate place I guess but as I don't use Fedora, no guarantees.

I suspect you might need to follow whats happening a bit more closely, there is no magic in the recipe provided, it just uses the supplied Makefile with a suitable parameter.  You must however end up with things such as RTL in a place defined in the fpc.cfg file. In theory, anywhere you like but a lot easier if you follow conventions.

The fpc.cfg typically has a $VER in the various paths but I see no intrinsic reason why it could not be "package" but if you could replicate the original structure, again, life would be easier.

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

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: getting fpc cross-compiling on Fedora Linux.
« Reply #2 on: October 13, 2022, 11:39:41 am »
I suggest uninstalling distro packages and use distro agnostic tar archive instead. The situation is similar with Debian derivatives, no idea why the package maintainer does that (changing the directory hierarchy around).

dbannon

  • Hero Member
  • *****
  • Posts: 3741
    • tomboy-ng, a rewrite of the classic Tomboy
Re: getting fpc cross-compiling on Fedora Linux.
« Reply #3 on: October 13, 2022, 12:13:22 pm »
in fact Leledumbo, the wiki howto used the SourceForge FPC, but a deb not an RPM package. Like you, I prefer a Tar install of FPC but wrote the howto based on the SourceForge package because more new user prefer that model. Its easily adapted to the Tar model and that would be better as it would be far more uniform between distros ...

On the other hand, its definitely not easily adapted easily to either the Debian produced deb, nor, I suspect the distro preferred RPM.

Laser, in short, Leledumbo is sort of right, get the official FPC fpc and life will be easier still !

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

lazer

  • Sr. Member
  • ****
  • Posts: 269
Re: getting fpc cross-compiling on Fedora Linux.
« Reply #4 on: October 13, 2022, 04:56:07 pm »
Thanks for all the replies.

I prefer to use distro pkgs where possible since the that is the point of a distro. If I install fpc by hand I then have to do Lazarus by hand to fiddle with distro config so that it knows I'm supposed to be in charge of that and ignores any deps.

I have a small number pkgs which I run this way but I aim to keep it as small as is really necessary.

I suspect there is trivial tweak here like defining something in fpc.cfg or making a sym link.


PascalDragon

  • Hero Member
  • *****
  • Posts: 6355
  • Compiler Developer
Re: getting fpc cross-compiling on Fedora Linux.
« Reply #5 on: October 14, 2022, 03:53:24 pm »
I prefer to use distro pkgs where possible since the that is the point of a distro. If I install fpc by hand I then have to do Lazarus by hand to fiddle with distro config so that it knows I'm supposed to be in charge of that and ignores any deps.

Then at least don't use the sources as provided by the distro. Download the sources for FPC 3.2.2 and do your make crossall OS_TARGET=win32 CPU_TARGET=i386 followed by make crossinstall OS_TARGET=win32 CPU_TARGET=i386 INSTALL_PREFIX=/path/where/it/should/install (and similar for x86_64-win64) inside its top level directory.

lazer

  • Sr. Member
  • ****
  • Posts: 269
Re: getting fpc cross-compiling on Fedora Linux.
« Reply #6 on: October 15, 2022, 10:57:26 am »
Thanks
I have discovered that Fedora do not even include 386 fpc ( like they don't for any other packages ) .
Code: Pascal  [Select][+][-]
  1. Error: ppc386 can't be executed, error message: Failed to execute "ppc386", error code: 127

So I tried to build from github. All went well until I installed and discovered I got 3.3.1 
Code: Pascal  [Select][+][-]
  1. make[4]: Entering directory '/svn/FPCSource-main/packages'
  2. ./fpmake install --localunitdir=.. --os=win32 --cpu=i386 -o -Twin32 -o -Pi386 -o -XPi386-win32- -o -Ur -o -Xs -o -O2 -o -n -o -di386 -o -dRELEASE --compiler=/svn/FPCSource-main/compiler/ppcross386 -bu -scp --prefix=/usr --baseinstalldir=/usr/lib/fpc/3.3.1
  3.  

Let's see how far that gets.


« Last Edit: October 15, 2022, 11:44:31 am by lazer »

lazer

  • Sr. Member
  • ****
  • Posts: 269
Re: getting fpc cross-compiling on Fedora Linux.
« Reply #7 on: October 15, 2022, 03:03:02 pm »
Quote
The project uses target OS=win32 and CPU=x86_64.
The system.ppu for this target was not found in the FPC binary directories.
Make sure fpc is installed correctly for this target and the fpc.cfg contains the right directories.

Clearly mixing versions is not going to work well.

Where can I get official fpc source for version 3.2.2. ?

Thx.

lazer

  • Sr. Member
  • ****
  • Posts: 269
Re: getting fpc cross-compiling on Fedora Linux.
« Reply #8 on: October 15, 2022, 03:33:58 pm »
https://gitlab.com/freepascal.org/fpc/source/-/archive/release_3_2_2/source-release_3_2_2.tar.bz2

OK I built 3.2.2.

Native still compiles fine.
If I which TARGET to Win32 or Win64  and click "Test"  , it fails to find all RTL units:

Quote
Error: RTL unit not found: sysutils.ppu

If continue and try to compile , I get :
Quote
The project uses target OS=win32 and CPU=x86_64.
The system.ppu for this target was not found in the FPC binary directories.
Make sure fpc is installed correctly for this target and the fpc.cfg contains the right directories.

Quote
Fatal: Cannot find system used by fcllaz. Make sure all ppu files of a package are in its output directory. ppu in wrong directory=/usr/lib/fpc/3.2.2/units/x86_64-win64/rtl/system.ppu..

Code: Pascal  [Select][+][-]
  1. grep Fu /etc/fpc.cfg
  2. -Fu/usr/lib64/fpc/$fpcversion/units/$fpctarget
  3. -Fu/usr/lib64/fpc/$fpcversion/units/$fpctarget/*
  4. -Fu/usr/lib64/fpc/$fpcversion/units/$fpctarget/rtl
  5. -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget
  6. -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
  7. -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
  8. -Fu/usr/units/$fpctarget/$fpcsubarch-$fpcmemorymodel
  9. -Fu/usr/units/$fpctarget/$fpcsubarch-$fpcmemorymodel/*
  10. -Fu/usr/units/$fpctarget/$fpcsubarch-$fpcmemorymodel/rtl
  11. -Fu/usr/lib64/fpc/$fpcversion/units/$fpctarget/httpd13/
  12. -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd13/
  13. -Fu/usr/lib64/fpc/$fpcversion/units/$fpctarget/httpd20/
  14. -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd20/
  15. -Fu/usr/lib64/fpc/$fpcversion/units/$fpctarget/httpd22/
  16. -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/httpd22/
  17. -Fu~/.fppkg/lib/fpc/$fpcversion/units/$FPCTARGET/*
  18.  

Full disclosure :
Code: Pascal  [Select][+][-]
  1. ls /usr/units/
  2. ls: cannot access '/usr/units/': No such file or directory
  3.  

~/.fppkg/lib/fpc/  does not exist either.
« Last Edit: October 15, 2022, 03:45:25 pm by lazer »

lazer

  • Sr. Member
  • ****
  • Posts: 269
Re: getting fpc cross-compiling on Fedora Linux.
« Reply #9 on: October 15, 2022, 04:57:11 pm »
It still can't find anything... even if it is there.
Quote
ls -ail /usr/lib/fpc/3.2.2/units/x86_64-linux/rtl/system.ppu
1464493 -rw-r--r--. 1 root root 888064 Oct 15 16:09 /usr/lib/fpc/3.2.2/units/x86_64-linux/rtl/system.ppu
« Last Edit: October 15, 2022, 04:59:08 pm by lazer »

Thaddy

  • Hero Member
  • *****
  • Posts: 18792
  • Glad to be alive.
Re: getting fpc cross-compiling on Fedora Linux.
« Reply #10 on: October 15, 2022, 05:03:17 pm »
Fedora is at release 37, not 35. You may not be able to install FPC from Fedora's repository. You are using an old distro, with an old FPC as a result. You may be able to bootstrap the sources to compile it yourself, but make sure the bootstrap compiler is at least up-to-date. (requires FPC 3.2.0)
Recovered from removal of tumor in tongue following tongue reconstruction with a part from my leg.

lazer

  • Sr. Member
  • ****
  • Posts: 269
Re: getting fpc cross-compiling on Fedora Linux.
« Reply #11 on: October 15, 2022, 05:11:10 pm »
The distroF35 is still maintained. 
If you read what I posted you will see it provides 3.2.2  so it is not "old".

That is the "bootstrap" with which I just rebuilt 3.2.2 and 3.3.1 without any build issues.

The problem is Lazarus can't find RTL files which are present in the standard place. I don't see what that has to do with fpc version.

« Last Edit: October 15, 2022, 05:27:49 pm by lazer »

Thaddy

  • Hero Member
  • *****
  • Posts: 18792
  • Glad to be alive.
Re: getting fpc cross-compiling on Fedora Linux.
« Reply #12 on: October 15, 2022, 05:36:00 pm »
The bootstrap compiler is usually the current release minus 2.
The fact that Lazarus - basically fpc itself can't find certain units is because the rtl is versioned.
FPC needs the proper rtl, NOT old stuff.
Recovered from removal of tumor in tongue following tongue reconstruction with a part from my leg.

lazer

  • Sr. Member
  • ****
  • Posts: 269
Re: getting fpc cross-compiling on Fedora Linux.
« Reply #13 on: October 15, 2022, 05:59:57 pm »
Quote
dnf info fpc-src
Last metadata expiration check: 0:00:11 ago on Sat 15 Oct 2022 17:53:59 CEST.
Installed Packages
Name         : fpc-src
Version      : 3.2.2
Release      : 3.fc35
Architecture : noarch
Size         : 244 M
Source       : fpc-3.2.2-3.fc35.src.rpm
Repository   : @System
From repo    : fedora
Summary      : Free Pascal Compiler - sources
URL          : http://www.freepascal.org/
License      : GPLv2+ and LGPLv2+ with exceptions
Description  : The fpc-src package contains the sources of Free Pascal, for documentation or
             : automatical-code generation purposes.


I already stated that F35 supplies 3.2.2  , so trying to build and install 3.2.2 with 3.2.2   is  NOT OLD STUFF.

Plus I also stated that went without a problem.

The problem is that Lazarus is unable to configure using the new file locations. Even after adjusting fpc.cfg and pointing the start-up dlg to the correct location.    It can't see what is already there.

Close all windows, if that does work reboot, if that doesn't work reinstall operating system.   LOL

« Last Edit: October 15, 2022, 07:15:46 pm by lazer »

dbannon

  • Hero Member
  • *****
  • Posts: 3741
    • tomboy-ng, a rewrite of the classic Tomboy
Re: getting fpc cross-compiling on Fedora Linux.
« Reply #14 on: October 16, 2022, 11:48:42 am »
Lazer, I really think it would be a lot easier if you stick with just one approach. We have established that the Fedora Repo does not support 32bit so, perhaps, dropping the Fedora one might be a good start.

Now you are left with installing FPC by one of three ways -
* Build it from source.
* Install from a Tarball
* Install from a RPM, Fedora's native package model.

They are listed, incidentally, hardest from the top, easiest at the bottom.  I suggest the Tarball if you want to build cross compilers, it has everything you need and can be installed in userspace, making the process easier and safer.

And its still reasonably hard and you seem to like that. Installing from the RPM is dead easy but a bit harder to build the cross compiler  :)  The one issue you will encounter is that Fedora likes its libraries in different places and you may need to manually edit the config file accordingly.

In most cases, you need to edit that config file, each platform has its own section, I suspect that the Fedora Repo version has the 32bit section removed. Makes sense, they don't do 32bit. Anyway, its pretty normal to edit the config file when building cross compilers, do not assume the defaults will always work because the various Linux Distributions like to put things in different places.

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

 

TinyPortal © 2005-2018