Recent

Author Topic: MacOS. x86_64 to aarch64  (Read 1467 times)

Seenkao

  • Hero Member
  • *****
  • Posts: 546
    • New ZenGL.
MacOS. x86_64 to aarch64
« on: February 15, 2023, 01:40:38 pm »
Как мне скомпилировать на MacOS из архитектуры x86_64 в архитектуру aarch64?

Я установил кросс-компилятор aarch64-darwin. Но ни какие опции (MacOS+aarch64 / darwin+aarch64 / default+aarch64) не позволяют мне скомпилировать проект под MacOS-aarch64.
Прерывается, как я понимаю, на стадии сборки проекта.

Google translate:
How can I compile on MacOS from x86_64 architecture to aarch64 architecture?

I installed the aarch64-darwin cross compiler. But none of the options (MacOS+aarch64 / darwin+aarch64 / default+aarch64) allow me to compile the project under MacOS-aarch64.
It is interrupted, as I understand it, at the project assembly stage.

Quote
Error: ld: symbol(s) not found for architecture arm64
« Last Edit: February 15, 2023, 01:51:12 pm by Seenkao »
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

Seenkao

  • Hero Member
  • *****
  • Posts: 546
    • New ZenGL.
Re: MacOS. x86_64 to aarch64
« Reply #1 on: February 16, 2023, 10:40:42 am »
Есть хотя бы варианты, по какой причине, я не могу собрать проект под ARM процессоры дл MacOS?
Может из-за того, что я использую High Sierra? И сборка полностью зависит от версии Xcode?

Неужели ни кто не собирает кроссплатформенные приложения на MacOS?

Google translate:
There are at least options, for what reason, I can not build a project for ARM processors for MacOS?
Maybe because I'm using High Sierra? And the build is completely dependent on the Xcode version?

Really no one collects cross-platform applications on MacOS?
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

Seenkao

  • Hero Member
  • *****
  • Posts: 546
    • New ZenGL.
Re: MacOS. x86_64 to aarch64
« Reply #2 on: February 16, 2023, 11:50:37 pm »
Я оказался прав. ld лезет в Xcode, а XCode у меня 10-й. Для поддержки кросскомпиляции под ARM нужен Xcode >= 12.2.
Если я не прав и есть решение, просьба поправить.

Google translate:
I turned out to be right. ld climbs into Xcode, and I have XCode 10th. To support cross-compilation under ARM, Xcode >= 12.2 is required.
If I'm wrong and there is a solution, please correct me.
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

ChrisR

  • Full Member
  • ***
  • Posts: 247
Re: MacOS. x86_64 to aarch64
« Reply #3 on: February 17, 2023, 01:39:37 pm »
I always debug using the FPC compiler for the native architecture. However, for distribution I use LLVM and use `lipo` to create a universal binary that supports both aarch64 and x86:

Code: [Select]
APPNAME=myApp
LPR_PTH=/path/to/lpr
lazbuild -B --compiler=~/fpcllvm86/lib/fpc/3.3.1/ppcx64 --ws=cocoa  --cpu=x86_64 ${LPR_PTH}/${APPNAME}.lpi
mv ${LPR_PTH}/${APPNAME} ${LPR_PTH}/${APPNAME}X86
strip ${LPR_PTH}/${APPNAME}X86

lazbuild -B --compiler=~/fpcllvm86/lib/fpc/3.3.1/ppca64 --ws=cocoa  --cpu=aarch64 ${LPR_PTH}/${APPNAME}.lpi
mv ${LPR_PTH}/${APPNAME} ${LPR_PTH}/${APPNAME}ARM
strip ${LPR_PTH}/${APPNAME}ARM

lipo -create -output ${LPR_PTH}/${APPNAME} ${LPR_PTH}/${APPNAME}ARM ${LPR_PTH}/${APPNAME}X86

You can use the `file` command to check the architecture of your executable, with a Universal binary listing more than one, e.g.

Code: [Select]
file ./MRIcroGL
./MRIcroGL: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64]
./MRIcroGL (for architecture x86_64): Mach-O 64-bit executable x86_64
./MRIcroGL (for architecture arm64): Mach-O 64-bit executable arm64

For details on getting Lazarus projects to compile with LLVM, see https://wiki.freepascal.org/LLVM

[Edited to add code tags]
« Last Edit: May 12, 2023, 02:07:36 pm by trev »

Bogen85

  • Hero Member
  • *****
  • Posts: 595
Re: MacOS. x86_64 to aarch64
« Reply #4 on: February 17, 2023, 01:46:12 pm »
@ChrisR, This forum does not use mark down formatting.

It would be nice if it did, and it is annoying (the forum is annoying) that it does not...

(This is the forum's fault, not yours...)

Please put your code in between code tags. See the # mark button in the forum post editing tool bar area. It creates the code tags for you.

The tags created are an opening and closing code tag set.

code=pascal
// your code goes here
[/code

Do not modify what is betweenandbut you can change the pascal to some other language (such as shell or text) if applicable.

In your case @ChrisR, shell  :D

Seenkao

  • Hero Member
  • *****
  • Posts: 546
    • New ZenGL.
Re: MacOS. x86_64 to aarch64
« Reply #5 on: March 15, 2023, 12:17:56 pm »
Если столкнётесь с подобной проблемой, то на системе x86_64 вы должны использовать минимальную версию Mac - Big Sur. Версии ниже (на системе x86_64) не будут компилировать код под ARM процессоры M1/M2.

Google translate:
If you encounter a similar problem, then on an x86_64 system, you should use the minimum version of Mac - Big Sur. Versions below (on an x86_64 system) will not compile code for ARM M1/M2 processors.
Rus: Стремлюсь к созданию минимальных и достаточно быстрых приложений.

Eng: I strive to create applications that are minimal and reasonably fast.
Working on ZenGL

 

TinyPortal © 2005-2018