Recent

Author Topic: Best approach for universal binaries (32 bit, 64 bit releases)  (Read 626 times)

cpicanco

  • Hero Member
  • *****
  • Posts: 534
  • Programmer and Behavioral Scientist
    • Portfolio
TLDR
What one should do to realease 32 bit "universal" binaries and 64 bit "universal" binaries?

Background

Apple has completely dropped all 32 bit support from macOS 10.15 Catalina (released in October 2019).

Apple has already discontinued production of Intel-based Macs, and the company has stated that it plans to transition its entire Mac lineup to its own custom silicon chips.

Universal 2 binaries

To create an Universal 2 binary with support for both Intel x86_x64 and M1 arm64 architectures, you need to compile your code separately for each architecture, and then use the "lipo" command to create a single binary that includes both versions. ChatGPT may tell you:

Quote
Here are the steps to follow:

1. Open your Lazarus project in the Lazarus IDE.

2. Click on "Project" in the menu bar, and then click on "Compiler Options".

3. In the Compiler Options dialog box, click on the "Target OS" drop-down menu and select "Darwin".

4. In the "Target CPU" drop-down menu, select "x86_64" for 64-bit support.

5. Click on "Configure Build Lazarus" in the "Build Modes" tab, and select "Release" as the build mode.

6. In the "Path Settings" tab, make sure that the "FPC Source Directory" and "FPC Binary Directory" are set to the correct paths.

7. Click on "OK" to save the changes.

8. Click on "Project" in the menu bar, and then click on "Clean All".

9. Click on "Project" again, and then click on "Build".

10. Once the build process is complete, your Intel binary should be located in the directory of your Lazarus project.

11. Now, repeat steps 3-10, but this time select "arm64" in the "Target CPU" drop-down menu.

12. Once the build process is complete, your M1 binary should be located in the directory of your Lazarus project.

13. Open a Terminal window and navigate to the directory containing the two binaries.

14. Use the "lipo" command to create the Universal 2 binary:

Quote
lipo -create -output universal_binary intel_binary arm_binary

This will create a single binary file named "universal_binary" that contains both the Intel and M1 versions of your application.

Note that you may need to adjust your project's source code to ensure that it is compatible with both architectures. Additionally, you should test the Universal 2 binary on both Intel and M1 hardware to ensure that it works correctly on both platforms.

Right now, I am successfully creating MyApp.app bundles with Intel-M1-Cocoa "universal" binaries (althoug no "universal" label is shown in the file type column", I am missing something?)

Ok, but what about old 32bit machines? The "universal binary" wikipedia page mentions that people were building different sorts of universal binaries. What is the best approach for 32 bit machines? Creating a i386-Carbon with some sort of backward compatibility?

Also, is it possible to extend backward compatibility with Carbon to "MacOSX"?

Resources

https://wiki.freepascal.org/Installing_Lazarus_on_macOS

https://en.wikipedia.org/wiki/Universal_binary

https://en.wikipedia.org/wiki/MacOS_version_history

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Best approach for universal binaries (32 bit, 64 bit releases)
« Reply #1 on: May 12, 2023, 01:58:53 pm »
There is no need to release Intel 32 bit binaries at all - every Intel Mac computer is 64 bit capable except for the original 2006 Mac mini with the Core Solo CPU.

VTwin

  • Hero Member
  • *****
  • Posts: 1211
  • Former Turbo Pascal 3 user
Re: Best approach for universal binaries (32 bit, 64 bit releases)
« Reply #2 on: May 14, 2023, 03:38:53 am »
Just a comment. I know I can create universal apps, but I have been releasing separate 64 bit Intel and 64 bit ARM (M1/M2) releases. It just seems easier, and smaller downloads. No 32 bit releases since leaving Carbon behind.

If you want to go way back to legacy 32 bit Carbon code, that is a vanishing small segment, deprecated 2012. There is also a MacOS option, but I think that takes you even further back to 9. 
« Last Edit: May 14, 2023, 04:18:52 am by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

 

TinyPortal © 2005-2018