OSX27 SDK on macOS 26; TAPI file malformed/unknown architecture

Overnight I ran into a problem considering the C/C++ toolchain on macOS 26.6.2 and M1-series Mac which I'll be describing in this post.

I have the Command Line Tools installed (through xcode-select --install) and xcode-select -p shows /Library/Developer/CommandLineTools.

clang -v reports Apple clang version 21.0.0 (clang-2100.1.1.101). ld -v reports:

@(#)PROGRAM:ld PROJECT:ld-1267
BUILD 16:38:58 Jun  8 2026
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em armv8m.main armv8.1m.main
will use ld-classic for: armv6 armv7 armv7s i386 armv6m armv7k armv7m armv7em
LTO support using: LLVM version 21.0.0 (static support for 30, runtime is 30)
TAPI support using: Apple TAPI version 21.0.0 (tapi-2100.0.2.6)

By compiling and linking a basic C or C++ executable, there is an error reported by Clang / ld:

ld: tapi error: malformed file
 /Library/Developer/CommandLineTools/SDKs/MacOSX27.0.sdk/usr/lib/libSystem.B.tbd:4:20: error: unknown architecture

... arm64e.x1-macos ...
... rest omitted

Notice how SDKs/MacOSX27.0.sdk exists in the installation even though macOS 26 is the host system. I have attempted to remove /Library/Developer/CommandLineTools and performing xcode-select --install again, but the MACOSX27 SDK is still present.

The linker likely reports the error due to a mismatch between itself and the SDK/TAPI declaration, or the TAPI declaration and the host system. The Command Line Tools were not updated manually prior to receiving this error. It seems like an OTA update took place, as this problem happened overnight. If so, that does sound like an insecure design.

My quick fix was to remove the macOS 27 SDK from the system which allows Clang to find the macOS 26 SDK instead:

$ cd /Library/Developer/CommandLineTools/SDKs
$ ls MacOSX27*
MacOSX27.0.sdk MacOSX27.sdk
$ sudo rm -rf MacOSX27*

This is of course not a permanent solution before updating the host system to macOS 27, and therefore this post.

Tags: ld, xcode-select, tapi, malformed file, unknown architecture

The SDK is tied to the version of Xcode. It's not related to the host OS version except in terms of whether or not Xcode runs on that host OS version.

I assume the Command Line tools are similar, but that's a funky environment.

It would be better to post a reproducible example code that generates the error.

@Etresoft You asked for it.

$ sudo rm -rf /Library/Developer/CommandLineTools/
$ xcode-select --install
xcode-select: note: install requested for command line developer tools
$ xcode-select -p
/Library/Developer/CommandLineTools
Joeys-MacBook-Pro:~$ clang -v
Apple clang version 21.0.0 (clang-2100.1.1.101)
Target: arm64-apple-darwin25.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ ld -v
@(#)PROGRAM:ld PROJECT:ld-1267
BUILD 16:38:58 Jun  8 2026
configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em armv8m.main armv8.1m.main
will use ld-classic for: armv6 armv7 armv7s i386 armv6m armv7k armv7m armv7em
LTO support using: LLVM version 21.0.0 (static support for 30, runtime is 30)
TAPI support using: Apple TAPI version 21.0.0 (tapi-2100.0.2.6)
$ vim test.c
$ cat test.c 
#include <stdio.h>
int main(void) {
    printf("Hello world!\n");
    return 0;
}
$ clang test.c 
ld: tapi error: malformed file
/Library/Developer/CommandLineTools/SDKs/MacOSX27.0.sdk/usr/lib/libSystem.B.tbd:4:20: error: unknown architecture
                   arm64e.x1-macos, arm64e.x1-maccatalyst ]
                   ^~~~~~~~~~~~~~~
 in '/Library/Developer/CommandLineTools/SDKs/MacOSX27.0.sdk/usr/lib/libSystem.tbd'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I could reproduce this, but only by following your procedure exactly. I first had to install the command line tools. That worked fine and the build worked fine.

It was only after deleting the directory and then using xcode-select --install that it failed.

I don't have an answer for you. File a feedback report.

Personally, I avoid both the latest version and the previous version of Apple software whenever possible. My production machine is Sequoia and will remain so until Apple forces me to change.

OSX27 SDK on macOS 26; TAPI file malformed/unknown architecture
 
 
Q