How to set *_DEPLOYMENT_TARGET when building Rust compiler for Apple platforms?

I'm building the aarch64-apple-tvos-sim via x.py. It works overall, however I'm looking for the following customizations:

  1. Custom TVOS_DEPLOYMENT_TARGET or -mtvos-simulator-version-min
  2. Build the static libraries only

For [1] I tried setting the CFLAGS_aarch64-apple-tvos-sim=-mtvos-simulator-version-min=17.0 but I'm not sure it had any effect as produced rlib and dylib libraries do not have LC_VERSION set as per otool -l. Cannot figure out how to achieve [2].

I think I was able to force Rust's bootstrap to produce binaries with desired *_DEPLOYMENT_TARGET:

  1. Set the CFLAGS_<triple> and CXXFLAGS_<triple> environment variables to -m<platform>-version-min=<version>
  2. Set the RUSTC_WRAPPER environment variable to custom shell script:
    #!/bin/zsh
    
    target_option_idx=${@[(Ie)--target]}
    
    if [[ ${target_option_idx} -ne 0 ]]; then
        target_value_idx=$((target_option_idx + 1))
        target_value=$@[target_value_idx]
    
        if [[ "${target_value}" = "<triple>" ]]; then
            exec /usr/bin/env <platform>_DEPLOYMENT_TARGET=<version> "$@"
        fi
    fi
    
    exec /usr/bin/env "$@"
    

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.