Experimental cygwin support in rustc

Co-authored-by: Ookiineko <chiisaineko@protonmail.com>
This commit is contained in:
王宇逸 2025-04-22 16:16:23 +08:00
parent d163a28381
commit 49553be307
5 changed files with 23 additions and 5 deletions

View file

@ -1388,7 +1388,7 @@ impl<'a> Builder<'a> {
// Windows doesn't need dylib path munging because the dlls for the
// compiler live next to the compiler and the system will find them
// automatically.
if cfg!(windows) {
if cfg!(any(windows, target_os = "cygwin")) {
return;
}

View file

@ -130,7 +130,7 @@ pub fn is_debug_info(name: &str) -> bool {
/// Returns the corresponding relative library directory that the compiler's
/// dylibs will be found in.
pub fn libdir(target: TargetSelection) -> &'static str {
if target.is_windows() { "bin" } else { "lib" }
if target.is_windows() || target.contains("cygwin") { "bin" } else { "lib" }
}
/// Adds a list of lookup paths to `cmd`'s dynamic library lookup path.

View file

@ -20,7 +20,7 @@ use std::str::FromStr;
/// Returns the environment variable which the dynamic library lookup path
/// resides in for this platform.
pub fn dylib_path_var() -> &'static str {
if cfg!(target_os = "windows") {
if cfg!(any(target_os = "windows", target_os = "cygwin")) {
"PATH"
} else if cfg!(target_vendor = "apple") {
"DYLD_LIBRARY_PATH"
@ -46,7 +46,7 @@ pub fn dylib_path() -> Vec<std::path::PathBuf> {
/// Given an executable called `name`, return the filename for the
/// executable for a particular target.
pub fn exe(name: &str, target: &str) -> String {
if target.contains("windows") {
if target.contains("windows") || target.contains("cygwin") {
format!("{name}.exe")
} else if target.contains("uefi") {
format!("{name}.efi")