Recent

Author Topic: [Solved] lazbuild failed when building 64bit MacOS app (-Px86_64 not supported)  (Read 787 times)

FangQ

  • Full Member
  • ***
  • Posts: 134
My GUI compiled on macos-10.15 with Lazarus 2.0.8 stopped working on macos-12. It does run OK on macos-10.15.

After reading this page (https://wiki.freepascal.org/Installing_Lazarus_on_macOS), I want to build the app with 64bit support.

I upgraded my lazarus to 2.2.6, and then changed from my lazbuild command from

Code: [Select]
lazbuild --build-mode=release mcxshow.lpi
to

Code: [Select]
lazbuild --build-mode=release --ws=cocoa --cpu=x86_64 mcxshow.lpi
however, the --cpu=x86_64 flag seems has caused lazbuild to fail with the following error:

Code: [Select]
$ lazbuild --build-mode=release --ws=cocoa --cpu=x86_64 mcxshow.lpi
Hint: (lazarus) [RunTool] "/usr/local/bin/ppc386" "-iWTOTP" "-Px86_64"
Hint: (lazarus) [RunTool] "/usr/local/bin/ppc386" "-va" "compilertest.pas" "-Px86_64"
Warning: [TPCTargetConfigCache.Update] no unit paths: /usr/local/bin/ppc386 -Px86_64
Warning: [TPCTargetConfigCache.Update] invalid fpc: Compiler="/usr/local/bin/ppc386" Options="-Px86_64" RealCompiler="/usr/local/lib/fpc/3.2.2/ppcx64" missing FPC_FULLVERSION
Hint: (lazarus) Last compile was incomplete for FCL 1.0.1
  State file="/Applications/Lazarus/packager/units/x86_64-darwin/FCL.compiled"
Hint: (lazarus) normal output directory of package FCL 1.0.1 is not writable: "/Applications/Lazarus/packager/units/x86_64-darwin/"
...
Warning: (lazarus) Duplicate unit "easylazfreetype" in "LazUtils 1.0", orphaned ppu "/Users/fangq/.lazarus/lib/LazUtils/lib/x86_64-darwin/easylazfreetype.ppu"
Hint: (11030) Start of reading config file /etc/fpc.cfg
Hint: (11031) End of reading config file /etc/fpc.cfg
Error: (11059) Unsupported target architecture -Px86_64, invoke the "fpc" compiler driver instead.
Error: (lazarus) Compile package FCL 1.0.1: stopped with exit code 1
Error: (lazarus) [TLazPackageGraph.CompileRequiredPackages] "Exit code 1"
Error: (lazbuild) Project dependencies of /Users/fangq/space/git/Project/github/mcx/mcxstudio/mcxshow.lpi

my fpc version is 3.2.2 for x86_64 and my lazbuild is 2.2.6. Let me know if this is a commonly known problem and if there is a workaround?

my app (mcxstudio) source code can be accessed here: https://github.com/fangq/mcx/tree/master/mcxstudio

thanks
« Last Edit: September 21, 2023, 12:39:51 am by FangQ »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11935
  • FPC developer.
Re: lazbuild failed when building 64bit MacOS app (Unsupported target -Px86_64)
« Reply #1 on: September 17, 2023, 10:30:05 pm »
Sounds like you have configured a "ppc<x>" binary as your compiler, when you should have configure the "fpc" binary for crosscompiling (?)

FangQ

  • Full Member
  • ***
  • Posts: 134
Re: lazbuild failed when building 64bit MacOS app (Unsupported target -Px86_64)
« Reply #2 on: September 17, 2023, 11:43:53 pm »
Sounds like you have configured a "ppc<x>" binary as your compiler, when you should have configure the "fpc" binary for crosscompiling (?)

sorry, how do I "configure the "fpc" binary for crosscompiling"? only used the default setting from the installation.

TRon

  • Hero Member
  • *****
  • Posts: 3623
Re: lazbuild failed when building 64bit MacOS app (Unsupported target -Px86_64)
« Reply #3 on: September 18, 2023, 07:20:35 am »
@FangQ:
As indicated by marcov, from your output
Code: [Select]
Hint: (lazarus) [RunTool] "/usr/local/bin/ppc386" "-iWTOTP" "-Px86_64"
Hint: (lazarus) [RunTool] "/usr/local/bin/ppc386" "-va" "compilertest.pas" "-Px86_64"
Warning: [TPCTargetConfigCache.Update] no unit paths: /usr/local/bin/ppc386 -Px86_64
Warning: [TPCTargetConfigCache.Update] invalid fpc: Compiler="/usr/local/bin/ppc386" Options="-Px86_64" RealCompiler="/usr/local/lib/fpc/3.2.2/ppcx64" missing FPC_FULLVERSION

You can conclude that it is ppc386 that is being used/setup as compiler for Lazarus. The warning "invalid fpc:" is a dead giveaway.

You can check that by starting lazarus IDE then open the menu View/IDE Internals/About FPC which will open a dialog.

In the tab "FPC values used by IDE" you should be able to locate two entries
- "Default CompilerFilename=<your fpc>"
- "Resolved default compilerFilename=<path and filename to your fpc>"

Those should point to your FPC executable/softlink/script (not ppcXXX). Actually the first one should point to your FPC script/link/executable (directories can be lacking) while the second should be the actual fpc
executable as located on your disk (including full directory name).

On the other tab on that dialog "FPC output" you can see if Lazarus is able to correctly locate/compile things. Have a look at it and try to understand what it reads there.

You can change the compiler by menu/Tools/Options which show the "IDE options" dialog. At the first entry environment/file you can set the fpc compiler under "Compiler Executable".
Your current setting probably shows "/usr/local/bin/ppc386" or ppc386.

If that is not the case then the only other thing that currently comes to mind is that you have an environment variable set somewhere that interferes with the "normal" flow for lazarus/lazbuild.

edit: for the IDE options dialog see also this wiki entry (first picture).
« Last Edit: September 18, 2023, 07:35:33 am by TRon »
This tagline is powered by AI (AI advertisement: Free Pascal the only programming language that matters)

FangQ

  • Full Member
  • ***
  • Posts: 134
Re: lazbuild failed when building 64bit MacOS app (Unsupported target -Px86_64)
« Reply #4 on: September 19, 2023, 08:24:31 pm »
thank you @TRon. I see the problem.

it looks like the old lazarus 2.0.8 for macos does not provide ppx64 (or lazbuild could not find it). I updated it to 2.0.12, I was able to run `lazbuild` with --cpu=x86_64 to invoke ppx64.

I started experiencing other issues when compiling my code with `cocoa` widgetset, but I will create a new thread to detail the problem.

 

TinyPortal © 2005-2018