User:Brecht/macOS Maintenance

= macOS Libraries =

Notes from Campbell are very relevant if you ignore the Linux specific stuff: User:Ideasman42/BlenderLibsForLinux

In particular SVN configuration and how to svn add/rm are important.

Arm
The basic thing to build libraries is to run `make deps`, which will download and compile all libraries in `../build_darwin/deps`.

Most likely it will tell you that you are missing some tools, and give you homebrew command to install them.

Äfter this is done it will automatically install the updated libraries to `lib/darwin_arm64` from where they can be committed.

However note that it will likely update all libraries even those that had no change, as we do not have reproducible builds. So I often `svn revert` parts that effectively stayed the same.

Cross-Compiling x86_64
x86_64 libraries are currently cross compiled on Arm, which is convenient to have on a single machine but it is a kludge.

Homebrew
This requires two homebrew install, one for arm and one for x86_64. They will be in different folders automatically.

macOS supports dropping into a x86_64 terminal like this.

From here you can install homebrew a second time.

I then added the following in `~/.zshrc`, so it automatically picks up the right homebrew install depending on the arch.

This probably replaces some existing code put there by homebrew.

Old SDK
For x86_64 you need to build with an older SDK than the one that comes by default. The reasons are not fully clear, as generally you should be able to use newer versions but it's currently failing otherwise.

I download the old 10.15 SDK from: https://github.com/phracker/MacOSX-SDKs/releases/download/11.3/MacOSX10.15.sdk.tar.xz

The annoying pat now is that getting all the libraries to pick this up is difficult, I have to move the newer SDKs out of the way whenever I build the x86_64 libraries.

So the regular SDK folder for me is (this is for command line tools, Xcode has a different path):

And I added another one next to it:

There I put the MacOSX10.15.sdk folder, and a MacOSX.sdk symlink to it.

And then whenever I need to build, I swap it out with the regular SDKs folder (see below).

Building
So always drop into the x86_64 terminal first.

Setting up the build should be something like this, modify paths as needed:

And then I have this script to build:

LTS and CVEs
We committed to updating libraries when security issues for them are found, both for master and 3.3 LTS.

Checking for such issues is automated by "make cve_check" in the libraries build folder.

If you have enough disk space you may consider setting up an entirely separate build and lib folder for 3.3 since switching with master is painful, as you will need to clear the entire build folder for it to rebuild correctly.