From: Apple Date: Fri, 18 Dec 2020 07:18:26 +0000 (+0000) Subject: system_cmds-880.60.2.tar.gz X-Git-Tag: macos-112^0 X-Git-Url: https://git.saurik.com/apple/system_cmds.git/commitdiff_plain/0813f9a61ea926dc2b5d6747467d2a1a4cae012e system_cmds-880.60.2.tar.gz --- diff --git a/arch.tproj/arch.1 b/arch.tproj/arch.1 index daad0af..234b339 100644 --- a/arch.tproj/arch.1 +++ b/arch.tproj/arch.1 @@ -86,8 +86,20 @@ argument must be one of the currently supported architectures: 64-bit intel .It x86_64h 64-bit intel (haswell) +.It arm64 +64-bit arm +.It arm64e +64-bit arm (Apple Silicon) .El .Pp +If the binary does not contain code for +.Ar arch_name , +the +.Nm arch +command may try to select a close match. If arm64 is specified and not found, +arm64e will be tried next. If this happens, the order the architectures will +be tried is not guaranteed. +.Pp Either prefix the architecture with a hyphen, or (for compatibility with other commands), use .Fl arch @@ -207,17 +219,17 @@ If not specified as a second field in a specifier, the executable path will be looked up in the corresponding property list file. .Ss Example ARCHPREFERENCE Values .Bl -tag -width " " -.It i386,x86_64,x86_64h +.It i386,x86_64,x86_64h,arm64,arm64e A specifier that matches any name. -.It foo:i386,x86_64,x86_64h +.It foo:i386,x86_64,x86_64h,arm64,arm64e A specifier that matches the program named .Nm foo (the full executable path is in the .Pa foo.plist file). -.It foo:/op/bin/boo:i386,x86_64,x86_64h +.It foo:/op/bin/boo:i386,x86_64,x86_64h,arm64,arm64e A specifier with all fields specified. -.It baz:i386;x86_64;x86_64h +.It baz:i386;x86_64;x86_64h,arm64,arm64e A specifier for .Nm baz and a second specifier that would match any other name. diff --git a/arch.tproj/arch.c b/arch.tproj/arch.c index 3a38c68..b522ce8 100644 --- a/arch.tproj/arch.c +++ b/arch.tproj/arch.c @@ -89,6 +89,9 @@ static const CPUTypes knownArchs[] = { {"x86_64h", CPU_TYPE_X86_64, CPU_SUBTYPE_X86_64_H}, {"arm", CPU_TYPE_ARM, CPU_SUBTYPE_ARM_ALL}, {"arm64", CPU_TYPE_ARM64, CPU_SUBTYPE_ARM64_ALL}, + /* rdar://65725144 ("arch -arm64" command should launch arm64e slice for 2-way fat x86_64+arm64e binaries) */ + /* This will modify the order if someone, for whatever reason, specifies -arch arm64 -arch x86_64 -arch arm64e */ + {"arm64", CPU_TYPE_ARM64, CPU_SUBTYPE_ARM64E}, {"arm64e", CPU_TYPE_ARM64, CPU_SUBTYPE_ARM64E}, {"arm64_32", CPU_TYPE_ARM64_32, CPU_SUBTYPE_ARM64_32_ALL}, }; @@ -296,14 +299,21 @@ static void addCPUbyname(CPU *cpu, const char *name) { int i; + size_t numKnownArchs = sizeof(knownArchs)/sizeof(knownArchs[0]); - for (i=0; i < sizeof(knownArchs)/sizeof(knownArchs[0]); i++) { + for (i=0; i < numKnownArchs; i++) { if (!isSupportedCPU(knownArchs[i].cpu)) continue; - if (0 == strcasecmp(name, knownArchs[i].arch)) { + int start = i; + /* rdar://65725144 ("arch -arm64" command should launch arm64e slice for 2-way fat x86_64+arm64e binaries) */ + /* Add subtypes that closely match the specified name */ + while ( i < numKnownArchs && + 0 == strcasecmp(name, knownArchs[i].arch) ) { addCPU(cpu, knownArchs[i].cpu, knownArchs[i].cpusubtype); - return; + i++; } + if (start != i) + return; } /* Didn't match a string in knownArchs */