From 14dd4e97a80c55a9140017ab13d0d8000977b274 Mon Sep 17 00:00:00 2001 From: Alex Zepeda Date: Tue, 1 Aug 2023 15:54:30 -0700 Subject: [PATCH 1/2] rustc_llvm: Link to `zlib` on dragonfly --- compiler/rustc_llvm/build.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index aa1121d6bb3f6..c3ab4312c029a 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -251,7 +251,8 @@ fn main() { } else if target.contains("windows-gnu") { println!("cargo:rustc-link-lib=shell32"); println!("cargo:rustc-link-lib=uuid"); - } else if target.contains("haiku") || target.contains("darwin") { + } else if target.contains("haiku") || target.contains("darwin") || target.contains("dragonfly") + { println!("cargo:rustc-link-lib=z"); } else if target.contains("netbsd") { println!("cargo:rustc-link-lib=z"); From 6ef7813cf0a7f591ec6709e06a4ce1c1ebc8f223 Mon Sep 17 00:00:00 2001 From: Alex Zepeda Date: Mon, 7 Aug 2023 17:11:01 -0700 Subject: [PATCH 2/2] rustc_llvm: Link `zlib` on cross Solaris builds On native builds `llvm-config` picks up `zlib` and this gets pased into the rust build tools, but on cross builds `llvm-config` is explicitly ignored as it contains information for the host system and cannot be trusted to be accurate for the target system. Both DragonFly and Solaris contain `zlib` in the base system, so this is both a safe assumption and required for a successful cross build unless `zlib` support is disabled in LLVM. This is more or less in the same vein as #75713 and #75655. --- compiler/rustc_llvm/build.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index c3ab4312c029a..a4986b94ea226 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -251,7 +251,9 @@ fn main() { } else if target.contains("windows-gnu") { println!("cargo:rustc-link-lib=shell32"); println!("cargo:rustc-link-lib=uuid"); - } else if target.contains("haiku") || target.contains("darwin") || target.contains("dragonfly") + } else if target.contains("haiku") + || target.contains("darwin") + || (is_crossed && (target.contains("dragonfly") || target.contains("solaris"))) { println!("cargo:rustc-link-lib=z"); } else if target.contains("netbsd") {