Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8528f4ec authored by Dan Willemsen's avatar Dan Willemsen
Browse files

Add Darwin+Arm64 toolchain support

This just sets up the toolchain and allows Darwin+Arm64 to be specified
as a HostCross target. These variants will not be exported to Make, or
be installed on a Soong-only build. A future CL will add support for
universal binaries using these variants.

This config is a bit stranger than the regular 64/32 multilib, as it's
two primary 64-bit configs. And on a Darwin/X86 machine, the Arm64
versions are HostCross (doesn't work on the current machines), while a
Darwin/Arm64 machine, either version works (if Rosetta is installed).

Bug: 203607969
Change-Id: Iacaed77d267773672da027cd74917e33fb1c1e94
parent 1caea352
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -921,6 +921,11 @@ func shouldSkipAndroidMkProcessing(module *ModuleBase) bool {
		return true
	}

	// Only expose the primary Darwin target, as Make does not understand Darwin+Arm64
	if module.Os() == Darwin && module.Target().HostCross {
		return true
	}

	return !module.Enabled() ||
		module.commonProperties.HideFromMake ||
		// Make does not understand LinuxBionic
+6 −1
Original line number Diff line number Diff line
@@ -308,7 +308,7 @@ var (
	// LinuxMusl is the OS for the Linux kernel plus the musl runtime.
	LinuxMusl = newOsType("linux_musl", Host, false, X86, X86_64)
	// Darwin is the OS for MacOS/Darwin host machines.
	Darwin = newOsType("darwin", Host, false, X86_64)
	Darwin = newOsType("darwin", Host, false, Arm64, X86_64)
	// LinuxBionic is the OS for the Linux kernel plus the Bionic libc runtime, but without the
	// rest of Android.
	LinuxBionic = newOsType("linux_bionic", Host, false, Arm64, X86_64)
@@ -696,6 +696,11 @@ func archMutator(bpctx blueprint.BottomUpMutatorContext) {
	for i, m := range modules {
		addTargetProperties(m, targets[i], multiTargets, i == 0)
		m.base().setArchProperties(mctx)

		// Install support doesn't understand Darwin+Arm64
		if os == Darwin && targets[i].HostCross {
			m.base().commonProperties.SkipInstall = true
		}
	}
}

+2 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ const (
	osArchAndroidArm64      = "android_arm64"
	osArchAndroidX86        = "android_x86"
	osArchAndroidX86_64     = "android_x86_64"
	osArchDarwinArm64       = "darwin_arm64"
	osArchDarwinX86_64      = "darwin_x86_64"
	osArchLinuxX86          = "linux_glibc_x86"
	osArchLinuxX86_64       = "linux_glibc_x86_64"
@@ -96,6 +97,7 @@ var (
		osArchAndroidArm64:         "//build/bazel/platforms/os_arch:android_arm64",
		osArchAndroidX86:           "//build/bazel/platforms/os_arch:android_x86",
		osArchAndroidX86_64:        "//build/bazel/platforms/os_arch:android_x86_64",
		osArchDarwinArm64:          "//build/bazel/platforms/os_arch:darwin_arm64",
		osArchDarwinX86_64:         "//build/bazel/platforms/os_arch:darwin_x86_64",
		osArchLinuxX86:             "//build/bazel/platforms/os_arch:linux_glibc_x86",
		osArchLinuxX86_64:          "//build/bazel/platforms/os_arch:linux_glibc_x86_64",
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ bootstrap_go_package {
        "x86_device.go",
        "x86_64_device.go",

        "x86_darwin_host.go",
        "darwin_host.go",
        "x86_linux_host.go",
        "x86_linux_bionic_host.go",
        "x86_windows_host.go",
+43 −9
Original line number Diff line number Diff line
@@ -174,19 +174,43 @@ type toolchainDarwin struct {
	toolchain64Bit
}

func (t *toolchainDarwin) Name() string {
type toolchainDarwinX86 struct {
	toolchainDarwin
}

type toolchainDarwinArm struct {
	toolchainDarwin
}

func (t *toolchainDarwinArm) Name() string {
	return "arm64"
}

func (t *toolchainDarwinX86) Name() string {
	return "x86_64"
}

func (t *toolchainDarwin) GccRoot() string {
func (t *toolchainDarwinArm) GccRoot() string {
	panic("unimplemented")
}

func (t *toolchainDarwinArm) GccTriple() string {
	panic("unimplemented")
}

func (t *toolchainDarwinArm) GccVersion() string {
	panic("unimplemented")
}

func (t *toolchainDarwinX86) GccRoot() string {
	return "${config.DarwinGccRoot}"
}

func (t *toolchainDarwin) GccTriple() string {
func (t *toolchainDarwinX86) GccTriple() string {
	return "${config.DarwinGccTriple}"
}

func (t *toolchainDarwin) GccVersion() string {
func (t *toolchainDarwinX86) GccVersion() string {
	return darwinGccVersion
}

@@ -194,7 +218,11 @@ func (t *toolchainDarwin) IncludeFlags() string {
	return ""
}

func (t *toolchainDarwin) ClangTriple() string {
func (t *toolchainDarwinArm) ClangTriple() string {
	return "aarch64-apple-darwin"
}

func (t *toolchainDarwinX86) ClangTriple() string {
	return "x86_64-apple-darwin"
}

@@ -230,12 +258,18 @@ func (t *toolchainDarwin) ToolPath() string {
	return "${config.MacToolPath}"
}

var toolchainDarwinSingleton Toolchain = &toolchainDarwin{}
var toolchainDarwinArmSingleton Toolchain = &toolchainDarwinArm{}
var toolchainDarwinX86Singleton Toolchain = &toolchainDarwinX86{}

func darwinArmToolchainFactory(arch android.Arch) Toolchain {
	return toolchainDarwinArmSingleton
}

func darwinToolchainFactory(arch android.Arch) Toolchain {
	return toolchainDarwinSingleton
func darwinX86ToolchainFactory(arch android.Arch) Toolchain {
	return toolchainDarwinX86Singleton
}

func init() {
	registerToolchainFactory(android.Darwin, android.X86_64, darwinToolchainFactory)
	registerToolchainFactory(android.Darwin, android.Arm64, darwinArmToolchainFactory)
	registerToolchainFactory(android.Darwin, android.X86_64, darwinX86ToolchainFactory)
}
Loading