Pass deployment target to cc linker with -m*-version-min= by madsmtm · Pull Request #136333 · rust-lang/rust (original) (raw)

Clang supports many ways of passing the deployment target, and prefers that you use the -target flag for doing so. This, however, works poorly work with Clang configuration files (at least before llvm/llvm-project#111387) and Zig CC.

To support GCC, we already passed the deployment target using the older, more widely supported -arch + -mmacosx-version-min= flag combination when compiling for macOS; let's do a similar thing for the other Apple targets too using -miphoneos-version-min=, -mtargetos= etc.

Note that when passing the target triple to the LLVM backend, we still have to merge the deployment target into that.

See also the similar fix in cc-rs where the problem is more prominent, exactly because we did not already do it for macOS.

@rustbot label O-apple
r? compiler
CC @thomcc @BlackHoleFox