clang: error: invalid version number in 'MACOSX_DEPLOYMENT_TARGET=11.3'

Ryan Schmidt ryandesign at
Sat May 1 16:43:38 UTC 2021

On May 1, 2021, at 06:33, Mojca Miklavec wrote:

> Hi,
> On Sat, 1 May 2021 at 12:22, Joshua Root wrote:
>> This usually indicates that your Command Line Tools are outdated. If
>> Software Update won't update them, you are affected by an Apple bug, and
>> will need to follow the instructions here:
>> <>
> I wasn't experiencing the exact same problem, but it might be related,
> and I'm confused.

I don't believe what you're experiencing is related to what Lars is seeing.

> Basically my problems started after I upgraded Big Sur and rebooted
> two days ago. I never installed Xcode, only the command-line tools.
> I had a repository that would be automatically built with CMake &
> Ninja (triggered via buildbot). The problem can be summarized as [1]:
> /Library/Developer/CommandLineTools/usr/bin/cc test.c -o test
> test.c:1:10: fatal error: 'stdio.h' file not found
> #include <stdio.h>
>         ^~~~~~~~~
> 1 error generated.
> (Note that just "clang test.c -o test" works just fine.)
> Curiously it helped when I made a clean checkout of the repository
> without doing anything else. Apparently CMake picked the compiler in a
> different way then(???), I have no clue [2].

Maybe CMake had previous configured itself to use the MacOSX11.1.sdk which you had with Xcode 12.4 and matching CLT. After upgrading to Xcode 12.5 and matching CLT, you have the MacOSX11.3.sdk, so anything CMake was looking for in the MacOSX11.1.sdk no longer exists. By cleaning and trying again, you've told CMake to find the SDK again.

I don't see any mention of SDKROOT environment variable or SDK paths in the steps of your build that were failing, so I'm not sure how that's happening.

> I initially planned to somewhat ignore the problem I had earlier, but
> then MacPorts started pointing me to the above link on the Trac about
> how to reinstall CLT. I followed the steps. It downloaded 1 GB of
> stuff, and (as expected) kept saying that I needed to update CLT for
> Xcode 12.4 and 12.5 even after the download was completed. I tried
> running it again, just in case, but I never actually saw anything
> being updated, I just saw the files being downloaded (it took too long
> to watch till the end) and when I came back to the computer,
> everything was as if nothing had happened, just prompting me to
> install the two updates again.
> I believe that MacPorts stopped complaining about broken CLT, but the
> above command that initially failed
>    /Library/Developer/CommandLineTools/usr/bin/cc test.c -o test
> still fails to work.

MacPorts base contains no code that complains about broken CLT.

The cltversion 1.0 portgroup, which some ports include, will emit this message if it cannot determine what version of the CLT you have, either because it is not installed or because you or more likely a macOS update removed its receipt:

cltversion: The Command Line Tools are installed, but MacPorts cannot determine the version.
cltversion: For a possible fix, please see:

If you see this, reinstall the CLT in order to reinstall its receipt.

Following these instructions tricks software update into thinking the CLT are always outdated, thus allowing it to reinstall them even when they're not really outdated. Yes, after reinstalling the CLT, software update will continue to present the CLT to you as an available update until you complete the final step shown in the problem hotlist entry.

Currently, software update is presenting both the Xcode 12.4 CLT and the Xcode 12.5 CLT. They're each just under 500MB, so if you downloaded both, that would be 1GB. There's no point to downloading both. Install just one, whichever one matches your Xcode version. If you installed both, one would overwrite the other, and I don't know which one, so you might want to repeat the CLT reinstallation and pick just the version you want.

MacPorts base does contain code that ensures you have an SDK that is suitable for your macOS version. In MacPorts 2.6.4, this message was overzealous on macOS 11, resulting in this message on macOS 11.2:

:warn:main The macOS 11.2 SDK does not appear to be installed. Ports may not build correctly.
:warn:main You can install it as part of the Xcode Command Line Tools package by running `xcode-select --install'.

even though you had the latest Xcode 12.4 installed which provided the newest SDK at the time, the 11.1 SDK. MacPorts 2.7.0 has fixed this SDK detection so that any macOS 11.x SDK is satisfactory for macOS 11.x.

More information about the macports-users mailing list