[clang] Produce a diagnostic when using an unsupported deployment target on Apple
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
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?
Contributor guide
Research direction
Start by running the provided clang++ reproducer with -mmacos-version-min=10.9 and review how Clang handles Apple deployment targets. Clarify whether Clang or libc++ should define the supported minimum, then determine the expected diagnostic behavior and add coverage for that decision.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, macos
- Domain
- compilers, operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100