Recent

Author Topic: Cross-platform - how to target Linux  (Read 6212 times)

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: Cross-platform - how to target Linux
« Reply #45 on: October 17, 2024, 03:14:33 pm »
So what is the correct target?
The installed lazarus on your Mac, the one that you have been showing us so far, is x86_64. The FPC compiler it uses is compiled for X86_64.

By 'rebuilding' Lazarus to arch, it has now become an aarch application. Because of how FPCUpDeluxe has things set up the aarch Lazarus will now use the x86_64 compiled FPC command-line compiler and that is exactly the mix that should not happen.

If you think about that for a moment then you hopefully are able to come to the same conclusion as me when trying to figure out what such a mix actually does behind the scenes: making my head hurt  :D

fwiw: the correct target for lazarus of your current setup is x86_64.

Quote
The fact that the CPU drop down lists arm and aarch64 as two distinct options doesn't help matter!
That is because strict technically I was wrong naming it arm.

Whenever you see arm the first thought should be 32-bit. Whenever you require 64 bit arm then translate that for yourself to aarch64. The reason to refer to arm was in context to point out that your mac's processor is an arm processor (not a intel/amd/ibm one).


Quote
If you, or anyone, could explain to me, in terms no more complex linguistically than "the cat sat on the mat", exactly how I can do this, that would make life a lot easier!
In theory: Just pick what you prefer to use, stick to it and use cross-compiling for all other targets.

The reason I say in theory is because in practice that might be easier said than actually done (cross-target not supported, missing bintools, bugs, etc etc.).

E.g. do note the remarks that Don made about that what he stated that sometimes (cross-)targets are not supported (yet) for certain (host) platforms/architectures. That is either because of Lazarus/FPC itself or due to FPCUpDeluxe not being up to date (at least the version you/we are currently using)


You have at least two targets (windows and linux) running inside a VM based on arm architecture (aarch64 to be correct). Those you can easily test/verify so my initial thought would be to install the aarch64 version of Lazarus with its accompanied (aarch64) FPC command-line compiler (on your mac).

Again in theory (because I lack the hardware in order to test) you should be able to accomplish that by downloading the aarch64 darwin version of FPCUpDeluxe and setup things as you have done before.

If for whatever reason you need/want to cross-compile to windows x86_64 or any other target then you can add the corresponding cross compiler as you have done before (FPCUpDeluxe -> cross tab).


And you can do something similar for x86_64, if you so wish to do so by using the x86_64 darwin version of FPCUpDeluxe and in case wanting to create a setup for both architectures at the same time you can opt for that as well but keep those two installations completely separated form each other. That means that whenever you f.e. want to add another component to Lazarus' toolbar that you would have to do so twice (one for each architecture). In case wanting to add a new cross-compiler for another target and you wish to use that target for both compiler you would have to install that cross-compiler twice. That also mean you have to be very careful to configure FPCUpDeluxe to use the correct Lazarus installation path.
« Last Edit: October 17, 2024, 03:47:17 pm by TRon »
Today is tomorrow's yesterday.

MarkMLl

  • Hero Member
  • *****
  • Posts: 8563
Re: Cross-platform - how to target Linux
« Reply #46 on: October 17, 2024, 03:43:56 pm »
By 'rebuilding' Lazarus to arch, it has now become an aarch application. Because of how FPCUpDeluxe has things set up the aarch Lazarus will now use de x86_64 compiled FPC command-line compiler and that is exactly the mix that should not happen.

If you think about that for a moment then you hopefully are able to come to the same conclusion as me when trying to figure out what such a mix actually does behind the scenes: making my head hurt  :D

And that's why one of the things I said rather earlier in this thread is that the first thing to do is to run  fpc -h  in order to check that the executable actually works on the host, before even beginning to speculate on whether it can build code for the expected target. Then try  ppcx64 -h  and so on.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Logitech, TopSpeed & FTL Modula-2 on bare metal (Z80, '286 protected mode).
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

carl_caulkett

  • Hero Member
  • *****
  • Posts: 654
Re: Cross-platform - how to target Linux
« Reply #47 on: October 17, 2024, 03:49:32 pm »
Again in theory (because I lack the hardware in order to test) you should be able to accomplish that by downloading the aarch64 darwin version of FPCUpDeluxe and setup things as you have done before.

At last! This was the missing key! I'd not realised that the version of the fcpupdeluxe would be so crucial, especially since the cross-compiler facility can build for such a wide range of targets.

With respect, some of the explanations I have been given have been the equivalent of saying "turn to the left through 270 degrees" rather than "take a right hand turn through 90 degrees"

UPDATE: The aarch64 darwin version of FPCUpDeluxe failed... Lucky I backed up my /Applications/Lazarus_trunk folder  :o
Code: Pascal  [Select][+][-]
  1. (3104) Compiling buildprojectdlg.pas
  2. (3104) Compiling cocoaideformconfig.pas
  3. (3104) Compiling codecreationdlg.pas
  4. (3104) Compiling ideinstances.pas
  5. (9022) Compiling resource /Applications/Lazarus_trunk/lazarus/units/aarch64-darwin/cocoa/lazarus.or
  6. (9015) Linking ../lazarus
  7. -macosx_version_min has been renamed to -macos_version_min
  8. ld: -pie requires targetting a newer minimum version
  9. Error: (9013) Error while linking
  10. Fatal: (10026) There were 1 errors compiling module, stopping
  11. make[1]: *** [ide] Error 2
  12. make: *** [ide] Error 2
  13. Fatal: (1018) Compilation aborted
  14. Error: /Applications/Lazarus_trunk/fpc/bin/aarch64-darwin/ppca64 returned an error exitcode
  15. Error: (lazarus) Build IDE: stopped with exit code 2
  16. Error: (lazbuild) Building IDE: Building IDE failed
  17.  
  18. fpcupdeluxe: ERROR: Lazarus Native Installer (BuildModuleCustom: UserIDE): lazbuild returned error code 512
  19. Details: .
  20.  
  21.  
  22. ERROR: Fpcupdeluxe fatal error !
  23. Sequencer (UserIDE): Failure running fpcupdeluxe: error executing sequence UserIDE
  24. Sequencer (Lazarus): Failure running fpcupdeluxe: error executing sequence Lazarus
  25. Sequencer (Default): Failure running fpcupdeluxe: error executing sequence Default
  26.  
"It builds... ship it!"

carl_caulkett

  • Hero Member
  • *****
  • Posts: 654
Re: Cross-platform - how to target Linux
« Reply #48 on: October 17, 2024, 03:56:06 pm »
Anyhow.
The cross-compiling from M1 should work.
Would be good to try to solve the issue !

Hello again, DonAlfredo!

Any idea why the aarch64 darwin version of FPCUpDeluxe failed on me?

To give you some context, I selected FPC 3.3.1 and Lazarus 3.99 and chose the option to install both. This worked perfectly with the x86_64 darwin version of FPCUpDeluxe...

Code: Pascal  [Select][+][-]
  1. (3104) Compiling buildprojectdlg.pas
  2. (3104) Compiling cocoaideformconfig.pas
  3. (3104) Compiling codecreationdlg.pas
  4. (3104) Compiling ideinstances.pas
  5. (9022) Compiling resource /Applications/Lazarus_trunk/lazarus/units/aarch64-darwin/cocoa/lazarus.or
  6. (9015) Linking ../lazarus
  7. -macosx_version_min has been renamed to -macos_version_min
  8. ld: -pie requires targetting a newer minimum version
  9. Error: (9013) Error while linking
  10. Fatal: (10026) There were 1 errors compiling module, stopping
  11. make[1]: *** [ide] Error 2
  12. make: *** [ide] Error 2
  13. Fatal: (1018) Compilation aborted
  14. Error: /Applications/Lazarus_trunk/fpc/bin/aarch64-darwin/ppca64 returned an error exitcode
  15. Error: (lazarus) Build IDE: stopped with exit code 2
  16. Error: (lazbuild) Building IDE: Building IDE failed
  17.  
  18. fpcupdeluxe: ERROR: Lazarus Native Installer (BuildModuleCustom: UserIDE): lazbuild returned error code 512
  19. Details: .
  20.  
  21.  
  22. ERROR: Fpcupdeluxe fatal error !
  23. Sequencer (UserIDE): Failure running fpcupdeluxe: error executing sequence UserIDE
  24. Sequencer (Lazarus): Failure running fpcupdeluxe: error executing sequence Lazarus
  25. Sequencer (Default): Failure running fpcupdeluxe: error executing sequence Default
  26.  
« Last Edit: October 17, 2024, 04:18:12 pm by carl_caulkett »
"It builds... ship it!"

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: Cross-platform - how to target Linux
« Reply #49 on: October 17, 2024, 05:39:30 pm »
@MarkMLI:
True though on the other hand I do not expect someone new to this starting to change the default IDE build-options and/or manually stuff all kinds of things into directories created by FPCUpDeluxe and/or mixing different archs into the same directory (I can only take a guess of what might have happened).

As long as you leave all that alone you should be good to go.

@carl:
That looks like a xtools related issue to me. My knowledge is too impractical but at first sight your xtools are either too new or too old (I can never remember which one it is). See also wiki

fwiw: the directions go all over the place from left to right because you are behind the steering wheel and you seem to have skipped a few driving lessons  :) (that is not a problem but it complicates things especially because the instructor is blind).
« Last Edit: October 17, 2024, 05:58:43 pm by TRon »
Today is tomorrow's yesterday.

carl_caulkett

  • Hero Member
  • *****
  • Posts: 654
Re: Cross-platform - how to target Linux
« Reply #50 on: October 17, 2024, 06:49:37 pm »
@MarkMLI:
True though on the other hand I do not expect someone new to this starting to change the default IDE build-options and/or manually stuff all kinds of things into directories created by FPCUpDeluxe and/or mixing different archs into the same directory (I can only take a guess of what might have happened).

As long as you leave all that alone you should be good to go.

I created a new folder called /Applications/Lazarus_aarch64 and tried the install again. It worked this time, though I would have hoped that the process would be sufficiently self-contained not to be affected by the presence of existing files, but what do I know? Not a lot, apparently, despite my 40 year career as a professional programmer!

Now I just need to find a quick and easy way for the new Lazarus installation to pick up the config from my existing installation...
"It builds... ship it!"

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: Cross-platform - how to target Linux
« Reply #51 on: October 17, 2024, 08:18:03 pm »
Not a lot, apparently, despite my 40 year career as a professional programmer!
fwiw: it has nothing to do with either your or my experiences as a developer. Every programmer has its expertise and I have seen enough people (which once included myself) to have no knowledge whatsoever on how a compiler works let alone how a specific compiler needs to be setup, configured and/or created.

There is a steep learning curve there and it is nigh impossible to take shortcuts in order to get even a basic understanding on how things work. I simply was in luck to have been able to follow this project (FPC compiler) for a longer period of time and got myself at least a little acquainted (and I consider myself a rookie in that regards).

At least these days there is documentation such as the build-faq and a wiki stuffed full with information (be it helpful or not).

FPCUpdeluxe is a whole other chapter.

Ask me anything mac related and I know diddly squat (other than what I am able to read/understand and or are able to test myself (the latter which is nothing at all)).

Quote
Now I just need to find a quick and easy way for the new Lazarus installation to pick up the config from my existing installation...
On your own responsibility: don't point it to the same location but copy your existing lazarus configuration directory (that is the --pcp directory) over to the configuration directory of your new installation (actually that should be done before firing up the new installed lazarus for the first time). Then change the compiler options inside lazarus to point to the correct FPC compiler script. Then save your config.

edit: Also Make sure that the default build options for building the IDE itself does use the correct target and then you should be able to rebuild your IDE using your new (custom) options.
« Last Edit: October 17, 2024, 08:34:43 pm by TRon »
Today is tomorrow's yesterday.

carl_caulkett

  • Hero Member
  • *****
  • Posts: 654
Re: Cross-platform - how to target Linux
« Reply #52 on: October 18, 2024, 12:05:38 am »
On your own responsibility: don't point it to the same location but copy your existing lazarus configuration directory (that is the --pcp directory) over to the configuration directory of your new installation (actually that should be done before firing up the new installed lazarus for the first time). Then change the compiler options inside lazarus to point to the correct FPC compiler script. Then save your config.

All sorted now. My aarch64 version of Lazarus is now resplendent in shades of black, and I have zipped and backed up the old versions and will delete them soon. I can cross compile to any flavour of Mac or Windows, while for Linux, I just update the relevant repos in Github and the pull them into Lazarus 3.3.1/3.99 (aka 4.99 ;)) installed on a Ubuntu VM in VMWare Fusion. It's a good workflow and I'm being strict about only making changes on my Mac and pushing them to Linux, rather than vice versa!

Thanks for your help @TRon 🙏🏽
"It builds... ship it!"

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: Cross-platform - how to target Linux
« Reply #53 on: October 22, 2024, 12:48:56 pm »
I don't know if you already have something in mind for Linux but perhaps this is able to provide you with the functionality that your code requires ?
Today is tomorrow's yesterday.

 

TinyPortal © 2005-2018