Skip to content

Deployment target improvements #68

Description

@drewcrawford

Issues like #64 are often motivated by some underlying issue with deployment targets (targets too old require backdeployment shims, and then the question arises how do we package the shims, it's a tough problem since cargo build doesn't build applications).

Less obviously the docs are wrong about how to set deployment targets which motivates a subset of those issues. Broadly the documentation covers

  • Package.swift which controls which platforms the package could be built for
  • SwiftLinker::new which controls which platforms the package is being built for

...but then we go on to link the package into a Rust program, which probably has a DT of macOS 11, see:

rustc --print=deployment-target
deployment_target=11.0

This mismatch will cause various compatibility shims to be expected to support macOS 11 and when they aren't in the right locations the program will crash at runtime.

I'm not entirely sure what to do about this, some options are:

  1. If SwiftLinker added println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET={version}"); that changes the Rust DT to the expected value and this works in simple cases. However I'm a bit skeptical of this solution, what if two libraries disagree about DT? The ultimate program can only be built for one.
  2. Instead of doing this for you, docs could tell you to do it in your own build.rs. While this makes it a little more visible, I'm still not certain there's a good way to handle conflicts between packages on this.
  3. Another idea is to have SwiftLinker use Rust's DT as probed at runtime (instead of trying to it as an argument to the constructor). Then everything will build with the same DT (probably macOS 11). That's not the most practical default but it is Rust's, and then affected users can use the build.rs workaround but ideally at the binary level rather than the library level.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions