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

Answered by DTS Engineer in 907935022

I was able to reproduce this from a clean macOS 26.6 VM:

% sw_vers
ProductName:		macOS
ProductVersion:		26.6
BuildVersion:		25G72
% xcode-select --install    
…
% cat hello.c 
#include <stdio.h>

int main(int argc, char ** argv) {
    printf("Hello Cruel World!\n");
    return 0;
}
% clang hello.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 ]
                   ^~~~~~~~~~~~~~~
…

The thing to note here is that tapi is coming from the command-line tools package:

% xcrun -f tapi                                           
/Library/Developer/CommandLineTools/usr/bin/tapi

so it should be able to handle the .tbd file within the macOS 27 SDK. I’ll come back to that point below.

Note If you’re not familiar with .tbd files, I have a quick intro in An Apple Library Primer.

I encourage you to file a bug about this. And please post your bug number, just for the record.


The easiest way around this is to install Xcode 27.0 and select its command-line tools:

% sudo xcode-select -s /Volumes/Xcode_27/Xcode.app 
% clang hello.c                                   
% ./a.out
Hello Cruel World!

Failing that, you can probably get around this by installing the command-line tools aligned with Xcode 26.


The above raises the questions as to why the tapi in Xcode works. And my best guess on that front is that it’s a newer version:

% sudo xcode-select -s /Library/Developer/CommandLineTools
% xcrun tapi --version                                    
Apple TAPI version 21.0.0 (tapi-2100.0.2.6)
% sudo xcode-select -s /Volumes/Xcode_27/Xcode.app
% xcrun tapi --version
Apple TAPI version 21.0.0 (tapi-2100.3.8.1)

So I think the root cause of this bug is that the command-line tools package for Xcode 27 didn’t pick up the new tapi tool.

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

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.

I was able to reproduce this from a clean macOS 26.6 VM:

% sw_vers
ProductName:		macOS
ProductVersion:		26.6
BuildVersion:		25G72
% xcode-select --install    
…
% cat hello.c 
#include <stdio.h>

int main(int argc, char ** argv) {
    printf("Hello Cruel World!\n");
    return 0;
}
% clang hello.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 ]
                   ^~~~~~~~~~~~~~~
…

The thing to note here is that tapi is coming from the command-line tools package:

% xcrun -f tapi                                           
/Library/Developer/CommandLineTools/usr/bin/tapi

so it should be able to handle the .tbd file within the macOS 27 SDK. I’ll come back to that point below.

Note If you’re not familiar with .tbd files, I have a quick intro in An Apple Library Primer.

I encourage you to file a bug about this. And please post your bug number, just for the record.


The easiest way around this is to install Xcode 27.0 and select its command-line tools:

% sudo xcode-select -s /Volumes/Xcode_27/Xcode.app 
% clang hello.c                                   
% ./a.out
Hello Cruel World!

Failing that, you can probably get around this by installing the command-line tools aligned with Xcode 26.


The above raises the questions as to why the tapi in Xcode works. And my best guess on that front is that it’s a newer version:

% sudo xcode-select -s /Library/Developer/CommandLineTools
% xcrun tapi --version                                    
Apple TAPI version 21.0.0 (tapi-2100.0.2.6)
% sudo xcode-select -s /Volumes/Xcode_27/Xcode.app
% xcrun tapi --version
Apple TAPI version 21.0.0 (tapi-2100.3.8.1)

So I think the root cause of this bug is that the command-line tools package for Xcode 27 didn’t pick up the new tapi tool.

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I'm familiar. Thanks. Bug report filed. FB25065811