Skip to content

[clang] Produce a diagnostic when using an unsupported deployment target on Apple #167988

@ldionne

Description

@ldionne

Xcode documents a list of supported deployment targets: https://developer.apple.com/support/xcode/

For example, Xcode 26 supports macOS 11 as the oldest deployment target. Presumably, Clang could produce a diagnostic when selecting a deployment target that is unsupported on Apple platforms. Indeed, failure to do so might allow programmers to provide a deployment target that is too old and not supported by the SDK they are using, which can lead to silent issues.

An example of this is that up to now, libc++ has not been enforcing the oldest deployment target it supports (which matches roughly the Xcode deployment target). This means that anyone building for e.g. macOS 10.9 silently gets a binary that doesn't work on macOS 10.9 (due to libc++ using APIs that didn't exist back then) but without any complain from the compiler. That seems broken.

Another take on this would be that Clang's support is actually decoupled from Xcode's support and Clang actually intends to support platforms older than whatever Xcode supports. I don't know whether that's the case. If that's the case, though, this issue could be closed as moot and instead we should pursue a hard error in the libc++ headers when the programmer tries to use an unsupported deployment target.

Reproducer:

echo "int main() {}" | clang++ -xc++ - -mmacos-version-min=10.9 -o a.out

Should probably issue a diagnostic (depending on the outcome of the above).

CC @ahatanak WDYT?

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:driver'clang' and 'clang++' user-facing binaries. Not 'clang-cl'platform:macos

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions