rust-lang / cc-rs

Rust library for build scripts to compile C/C++ code into a Rust library
https://docs.rs/cc
Apache License 2.0
1.79k stars 434 forks source link

Add visionOS support #1029

Closed madsmtm closed 4 months ago

madsmtm commented 4 months ago

I haven't added this to CI, as the Rust builds themselves are still somewhat broken until https://github.com/rust-lang/libc/pull/3568 lands.

CC @BlackHoleFox

QuentinPerez commented 4 months ago

We were definitely working on the same thing; I made almost the same changes. The only differences are the XROS_DEPLOYMENT_TARGET and this additional check on lines 2658 and 2674

                // there is no -m{}os-version-min for watchos, tvos, visionos
                if matches!(os, AppleOs::Ios | AppleOs::MacOs) {
                    cmd.args.push(
                        format!("-m{}os-version-min={}", sdk_details.sdk_prefix, min_version)
                            .into(),
                    );
                }
madsmtm commented 4 months ago

there is no -m{}os-version-min for watchos, tvos, visionos

There is, see Clang's docs for the availability attribute and Clang's docs for e.g. the -mtvos-version-min flag itself.

However, you right that it does not exist for visionOS, I've opened https://github.com/llvm/llvm-project/issues/88271 for that. This is somewhat problematic, as we need to tell Clang about the desired deployment target. Perhaps we can set XROS_DEPLOYMENT_TARGET? Or maybe -mtargetos=xros1.0?

madsmtm commented 4 months ago

Using just --target is recommended by Clang Driver developers, which we already do, so I think that is a non-issue.

Have opened https://github.com/rust-lang/cc-rs/issues/1030 to track removing the other flags from Apple targets.

NobodyXu commented 4 months ago

Thank you!