impl TargetInfo<'_> { /// The LLVM/Clang target triple. /// /// See <https://clang.llvm.org/docs/CrossCompilation.html#target-triple>. /// /// Rust and Clang don't really agree on target naming, so we first try to /// find the matching trible based on `rustc`'s output, but if no such /// triple exists, we attempt to construct the triple from scratch. /// /// NOTE: You should never need to match on this explicitly, use the /// fields on [`TargetInfo`] instead. pub(crate) fn llvm_target(
&self,
rustc_target: &str,
version: Option<&str>,
) -> Cow<'static, str> { if rustc_target == "armv7-apple-ios" { // FIXME(madsmtm): Unnecessary once we bump MSRV to Rust 1.74 return Cow::Borrowed("armv7-apple-ios");
} elseifself.os == "uefi" { // Override the UEFI LLVM targets. // // The rustc mappings (as of 1.82) for the UEFI targets are: // * i686-unknown-uefi -> i686-unknown-windows-gnu // * x86_64-unknown-uefi -> x86_64-unknown-windows // * aarch64-unknown-uefi -> aarch64-unknown-windows // // However, in cc-rs all the UEFI targets use // -windows-gnu. This has been the case since 2021 [1]. // * i686-unknown-uefi -> i686-unknown-windows-gnu // * x86_64-unknown-uefi -> x86_64-unknown-windows-gnu // * aarch64-unknown-uefi -> aarch64-unknown-windows-gnu // // For now, override the UEFI mapping to keep the behavior // of cc-rs unchanged. // // TODO: as discussed in [2], it may be possible to switch // to new UEFI targets added to clang, and regardless it // would be good to have consistency between rustc and // cc-rs. // // [1]: https://github.com/rust-lang/cc-rs/pull/623 // [2]: https://github.com/rust-lang/cc-rs/pull/1264 return Cow::Owned(format!("{}-unknown-windows-gnu", self.full_arch));
}
// If no version is requested, let's take the triple directly from // `rustc` (the logic below is not yet good enough for most targets). // // FIXME(madsmtm): This should ideally be removed. if version.is_none() { iflet Ok(index) = generated::LLVM_TARGETS
.binary_search_by_key(&rustc_target, |(rustc_target, _)| rustc_target)
{ let (_, llvm_target) = &generated::LLVM_TARGETS[index]; return Cow::Borrowed(llvm_target);
}
}
// Otherwise, attempt to construct the triple from the target info.
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.