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