apple: Support building on Linux through Limbo

This commit is contained in:
Ole André Vadla Ravnås authored and Ole André Vadla Ravnås committed 2026-10-20 12:17:43 +02:00
1 parent d127b2fb06
commit 3fc6b6ccb9
2 files changed
+35 -2

No files matched your search

+11
View File
@@ -64,3 +64,14 @@ $ sudo apt-get install g++-arm-linux-gnueabihf
$ ./configure --host=arm-linux-gnueabihf
$ make
```
### Apple OSes from Linux
Install [Limbo](https://github.com/oleavr/limbo) with its binfmt
handlers and a sysroot containing Xcode, then point releng at the sysroot:
```sh
$ export LIMBO_SYSROOT=$HOME/macos
$ ./configure --host=macos-arm64e
$ make
```
+24 -2
View File
@@ -2,7 +2,7 @@ from configparser import ConfigParser
from pathlib import Path
import shlex
import subprocess
from typing import Callable, Dict, List, Optional
from typing import Callable, Dict, List, Optional, Tuple
from .machine_file import strv_to_meson
from .machine_spec import MachineSpec
@@ -27,15 +27,22 @@ def init_machine_config(machine: MachineSpec,
except KeyError:
raise Xcode11NotFoundError("for arm64eoabi support, XCODE11 must be set to the location of your Xcode 11 app bundle")
(xcrun_argv, limbo_sysroot) = detect_xcrun(build_machine, environ)
if limbo_sysroot is not None:
outenv["LIMBO_SYSROOT"] = limbo_sysroot
def xcrun(*args):
try:
return subprocess.run(["xcrun"] + list(args),
path = subprocess.run(xcrun_argv + list(args),
env=xcenv,
capture_output=True,
encoding="utf-8",
check=True).stdout.strip()
except subprocess.CalledProcessError as e:
raise XCRunError("\n\t| ".join(e.stderr.strip().split("\n")))
if limbo_sysroot is not None:
return limbo_sysroot + path
return path
clang_arch = APPLE_CLANG_ARCHS.get(machine.arch, machine.arch)
@@ -147,6 +154,17 @@ def init_machine_config(machine: MachineSpec,
options["b_lundef"] = "true"
def detect_xcrun(build_machine: MachineSpec, environ: Dict[str, str]) -> Tuple[List[str], Optional[str]]:
if build_machine.is_apple:
return (["xcrun"], None)
try:
sysroot = Path(environ["LIMBO_SYSROOT"]).resolve().as_posix()
except KeyError:
raise LimboSysrootNotFoundError("to build for Apple OSes on this machine, LIMBO_SYSROOT must be set to the location of your Limbo sysroot")
return ([sysroot + "/usr/bin/xcrun"], sysroot)
class XCRunError(Exception):
pass
@@ -155,6 +173,10 @@ class Xcode11NotFoundError(Exception):
pass
class LimboSysrootNotFoundError(Exception):
pass
APPLE_SDKS = {
"macos": "macosx",
"ios": "iphoneos",