Skip to content

Commit

Permalink
lang/rust: pull over fixes to rust 1.79 from pkgsrc-wip:
Browse files Browse the repository at this point in the history
1) Turn off the use ot thread local storage on NetBSD/aarch64,
   due to NetBSD PR#58154 and our desire to support systems
   built before the fix was applied.
2) Use the fixed 1.78.0 bootstrap for NetBSD/aarch64 (which
   is now built with the workaround from #1 applied).
3) Reinstate the patches to the openssl-sys and openssl-src
   vendor crates, and their checksum fixes, taken from pkgsrc-wip
   rust 1.78.0 and adapted.
4) Make the NetBSD/sparc64 target spec more similar to the other
   sparc64 targets.  Does not resolve the cross-build problem, sadly.
  • Loading branch information
he32 committed Jul 31, 2024
1 parent f77ffd3 commit c6fa78c
Show file tree
Hide file tree
Showing 11 changed files with 283 additions and 10 deletions.
19 changes: 16 additions & 3 deletions lang/rust/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.314 2024/07/30 18:06:32 tnn Exp $
# $NetBSD: Makefile,v 1.315 2024/07/31 08:05:50 he Exp $

DISTNAME= rustc-1.79.0-src
PKGNAME= ${DISTNAME:S/rustc/rust/:S/-src//}
Expand Down Expand Up @@ -319,10 +319,11 @@ SITES.${RUST_STD_STAGE0}= ${MASTER_SITE_LOCAL:=rust/}

.endif
.if ${MACHINE_PLATFORM:MNetBSD-*-aarch64} || make(distinfo) || make (makesum) || make(mdi)
NB= -nb1
RUST_STAGE0_VER= 1.78.0
RUST_ARCH= aarch64-unknown-netbsd
RUST_STAGE0:= rust-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.xz
RUST_STD_STAGE0:= rust-std-${RUST_STAGE0_VER}-${RUST_ARCH}.tar.xz
RUST_STAGE0:= rust-${RUST_STAGE0_VER}-${RUST_ARCH}${NB}.tar.xz
RUST_STD_STAGE0:= rust-std-${RUST_STAGE0_VER}-${RUST_ARCH}${NB}.tar.xz
DISTFILES:= ${DISTFILES} ${RUST_STAGE0} ${RUST_STD_STAGE0}
SITES.${RUST_STAGE0}= ${MASTER_SITE_LOCAL:=rust/}
SITES.${RUST_STD_STAGE0}= ${MASTER_SITE_LOCAL:=rust/}
Expand Down Expand Up @@ -426,6 +427,18 @@ CKSUM_CRATES+= vendor/crossbeam-utils-0.8.18
CKSUMS+= 31a8276afd38e39987a169eeb02e9bed32670de5ca36d7eb74aab7e506cf9dc4
CKSUMS+= ead4bda23c322bde8c01e48d4cd19b70e7b7e473a56466218d279f88463ab466

CKSUM_CRATES+= vendor/openssl-sys-0.9.92
CKSUMS+= 33f814dba4ac9942266157cbe3dc8eadf5e477090370a92c36c53f916fa45d48
CKSUMS+= f78ddd9b03c31a03350aa152d6f707c6cbb21b2ea0b493d05238aa473b80af09
CKSUMS+= b2cbaa5bfac5e7d5550aa0eb8e5c65a9f7e86a3692b759fb13330ef6e3b26b30
CKSUMS+= b303bf9ceae9fcffa4a0420ea858675d827fc2d75c358f8236e44274d58be1a0

CKSUM_CRATES+= vendor/openssl-src-111.28.1+1.1.1w
CKSUMS+= 090744f85cf99a9b8412c23fca1eabb61eb45d830f0f9f0e7309be2572c1e827
CKSUMS+= 4261f87c06e6505afd9f7bdafe5aebdd153a1c6f928203cec2dd125642d60fc1
CKSUMS+= c87f041ff9ada85cddcb2a787788e05b2ab5ffc0a85f502fe7e3f7cbda59d49c
CKSUMS+= 67b877964bc0e40c84669c423818a3cb39501eaedfc3f5caf9c33d4779c3d03f

SUBST_CLASSES+= cksum
SUBST_STAGE.cksum= pre-configure
.for crate in ${CKSUM_CRATES}
Expand Down
23 changes: 16 additions & 7 deletions lang/rust/distinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$NetBSD: distinfo,v 1.173 2024/07/27 02:35:24 tnn Exp $
$NetBSD: distinfo,v 1.174 2024/07/31 08:05:50 he Exp $

BLAKE2s (rust-1.77.1-aarch64_be-unknown-netbsd.tar.xz) = 5423dd837f47538992a67313a83983b583148f670f561da1d2a256fc98b5e24d
SHA512 (rust-1.77.1-aarch64_be-unknown-netbsd.tar.xz) = 449b8520f0904e15163e6a55bec5dcdb18c0e423b6dd2450f99dd061edcdbd33e9c4fe5dc874ab09b4efabd6199f9ad595f13ecd4d69d708c68f9fc54c1da6c4
Expand All @@ -9,9 +9,9 @@ Size (rust-1.78.0-aarch64-apple-darwin.tar.gz) = 330850938 bytes
BLAKE2s (rust-1.78.0-aarch64-unknown-linux-gnu.tar.gz) = 05f4fb750348075a70588284eafd410a3a9c71b8e44b5eddfee2dc104973f291
SHA512 (rust-1.78.0-aarch64-unknown-linux-gnu.tar.gz) = 91150da3a4412c447cbabe77d94585ef3b279a37fe208d4483d27c945abaef22686ae79e1ffad76dbaae2b3b95700dfa88c0e0657f1ebf154f520d3f3a9ab090
Size (rust-1.78.0-aarch64-unknown-linux-gnu.tar.gz) = 474875165 bytes
BLAKE2s (rust-1.78.0-aarch64-unknown-netbsd.tar.xz) = ae137e3b1af21db98d5437c5f18f7130d966ecf8f80cf5b050958e31eef64e90
SHA512 (rust-1.78.0-aarch64-unknown-netbsd.tar.xz) = 352f077b7b1d6b3fbe62349d0bde812b5e46ce112399d2e5205c1abfadb4f86d58fd3ade2adc90b4c07c2e4383906ac74f6564ca496b9e3db3f810c0422eb6e3
Size (rust-1.78.0-aarch64-unknown-netbsd.tar.xz) = 170785060 bytes
BLAKE2s (rust-1.78.0-aarch64-unknown-netbsd-nb1.tar.xz) = d690ca4901c0440956b573892165397814ad8fb0487b28df53d2fe7c59eb8265
SHA512 (rust-1.78.0-aarch64-unknown-netbsd-nb1.tar.xz) = 3d0c7713da80081d37285972600ce717f5fe078ba5dc4bfc7b7b943fedb89c8a5b87bb6bce08ab9fa8e5c63038a88862e77e211459201a59e729aa94b9a2e680
Size (rust-1.78.0-aarch64-unknown-netbsd-nb1.tar.xz) = 170867824 bytes
BLAKE2s (rust-1.78.0-arm-unknown-linux-gnueabihf.tar.gz) = 9bcf4bf8c7225b02fcb4b84eedbe8aec32511ed849c2e49105a8484a713fcc1b
SHA512 (rust-1.78.0-arm-unknown-linux-gnueabihf.tar.gz) = ddb9160f24edbaae174185ce2710d93831bc6253725bd7c1fae731cd9a8f3d6a115923ba050830ebe489eba9cee578b72f70f6aaa358a61deecfdaebcfe3b978
Size (rust-1.78.0-arm-unknown-linux-gnueabihf.tar.gz) = 362035971 bytes
Expand Down Expand Up @@ -63,9 +63,9 @@ Size (rust-std-1.78.0-aarch64-apple-darwin.tar.gz) = 39778441 bytes
BLAKE2s (rust-std-1.78.0-aarch64-unknown-linux-gnu.tar.gz) = 9abe969803d702b55507b70164c204a614682157b46070162a2b49950534c2da
SHA512 (rust-std-1.78.0-aarch64-unknown-linux-gnu.tar.gz) = 5c7c63981bb6ae55342619ba9f435039cddb02ac4108266b9a813addecbb56ee446a61f113ddfea211f21aea4b174b9c49c3f5805ba9280195cb4c115519787b
Size (rust-std-1.78.0-aarch64-unknown-linux-gnu.tar.gz) = 64560072 bytes
BLAKE2s (rust-std-1.78.0-aarch64-unknown-netbsd.tar.xz) = e3a3fd660f8ba6853b450e002ea6a8e1309c140b65cd2c4d4dc04c5df8044547
SHA512 (rust-std-1.78.0-aarch64-unknown-netbsd.tar.xz) = 10cc37959f7b25d608171cb4920745aecfa0358d6578d5be7539fc470419ffbfa9d076247d7ce18070364b2e2ce827169dbcd3c1641826bb16f39b5965d13831
Size (rust-std-1.78.0-aarch64-unknown-netbsd.tar.xz) = 22577220 bytes
BLAKE2s (rust-std-1.78.0-aarch64-unknown-netbsd-nb1.tar.xz) = d9bae6da7f52fe6df16e57d0cc65ce383da90a742ded555694c158a0c595a915
SHA512 (rust-std-1.78.0-aarch64-unknown-netbsd-nb1.tar.xz) = dfab5148028290538c0aee608828029c4c87823a29da8535b7ba0d9f975b094500e3258167697673354767ed735104ee1f22fd16b45a89c84dacf6c94d6c7f29
Size (rust-std-1.78.0-aarch64-unknown-netbsd-nb1.tar.xz) = 22585292 bytes
BLAKE2s (rust-std-1.78.0-arm-unknown-linux-gnueabihf.tar.gz) = f0c214c03267590cd861ec5b6b5ba765b8264f5bc2e1fcd682238c7a4eedb2a4
SHA512 (rust-std-1.78.0-arm-unknown-linux-gnueabihf.tar.gz) = abee9d658095e26ae22f0e5f47d1634f8572b355610e668b3cccb407977abc45ab65ab1cebf5f6525e4fdd893ca0d619e8c020c95bbfc9dc9e38883d929e1ada
Size (rust-std-1.78.0-arm-unknown-linux-gnueabihf.tar.gz) = 36357258 bytes
Expand Down Expand Up @@ -112,7 +112,10 @@ SHA1 (patch-compiler_rustc__codegen__ssa_src_back_linker.rs) = f5336828d70f9fc68
SHA1 (patch-compiler_rustc__llvm_build.rs) = a4a66d449fc9eb99d648d02a041778a68f4f7ce8
SHA1 (patch-compiler_rustc__target_src_spec_base_netbsd.rs) = 7d910631f49acf2c33fdd191fd3e0f261efae234
SHA1 (patch-compiler_rustc__target_src_spec_mod.rs) = a22b5d28997ed9a5565deec9c34322165d563d00
SHA1 (patch-compiler_rustc__target_src_spec_targets_aarch64__be__unknown__netbsd.rs) = 620eaf74c1dd030973af53dfe4f9aa998be5b123
SHA1 (patch-compiler_rustc__target_src_spec_targets_aarch64__unknown__netbsd.rs) = 1a02f2dd61a5f9cc4be1f66ac3404c961810c731
SHA1 (patch-compiler_rustc__target_src_spec_targets_mips64el__unknown__netbsd.rs) = e97b7978cc525db7eadf967d51f4818a3c145754
SHA1 (patch-compiler_rustc__target_src_spec_targets_sparc64__unknown__netbsd.rs) = 847022a9c02d277f39e2c842f23a9ed401bc5534
SHA1 (patch-library_backtrace_src_symbolize_gimli.rs) = 1ab343595e65ff6348f83cffc30e53d764485ff8
SHA1 (patch-library_backtrace_src_symbolize_gimli_elf.rs) = 3b84a462c6bc8245d579452e4c37e3ce13314952
SHA1 (patch-library_std_src_sys_pal_unix_mod.rs) = bfc59ae4568547e3ed71c8b31ba5b5b5363d5d40
Expand All @@ -135,4 +138,10 @@ SHA1 (patch-vendor_crossbeam-utils-0.8.18_no__atomic.rs) = d4d9288cb199af9bc7e32
SHA1 (patch-vendor_libc-0.2.148_src_unix_bsd_netbsdlike_netbsd_mips.rs) = 0895df54084281263b9dae67e57f68168fb66bd4
SHA1 (patch-vendor_libc-0.2.148_src_unix_bsd_netbsdlike_netbsd_riscv64.rs) = 8699853de4225d4e5953d6bf17b59bc463fa7b5d
SHA1 (patch-vendor_libc-0.2.151_src_unix_solarish_mod.rs) = 50a296ba939f8c12a445526b16f50e8111a762a7
SHA1 (patch-vendor_openssl-src-111.28.1+1.1.1w_openssl_Configurations_10-main.conf) = f14fa72626a831ca56a3b9d63d33f4ed72486e42
SHA1 (patch-vendor_openssl-src-111.28.1+1.1.1w_src_lib.rs) = ab83fe8e2e6a0ee4df75ba90388e10b815ef6ce9
SHA1 (patch-vendor_openssl-sys-0.9.102_build_find__normal.rs) = 2cf1432ed2be79677d41f267f9a08ff3082e9cbc
SHA1 (patch-vendor_openssl-sys-0.9.102_build_main.rs) = 8861b7d3acc1643f7fe6f494b18d452ac70cf810
SHA1 (patch-vendor_openssl-sys-0.9.92_build_find__normal.rs) = 91ad0d3e78055a5a205d55cd2c260cde70233bfe
SHA1 (patch-vendor_openssl-sys-0.9.92_build_main.rs) = a47c0b7144466592aca3b622cb77498d59c5dfc4
SHA1 (patch-vendor_rustc-ap-rustc__target_src_spec_aarch64__be__unknown__netbsd.rs) = 4e86aec4c89db9a331950a12f8ec7b8aaa50eed7
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$NetBSD: patch-compiler_rustc__target_src_spec_targets_aarch64__be__unknown__netbsd.rs,v 1.1 2024/07/31 08:05:50 he Exp $

NetBSD aarch64 has a bug in the thread-local storage implementation,
ref. PR#58154. Turn it off for now.
Ideally should check whether the version has the fix or not, but
e.g. __NetBSD_Version__ isn't easily available here that I know...

--- compiler/rustc_target/src/spec/targets/aarch64_be_unknown_netbsd.rs.orig 2024-07-23 19:21:34.344805113 +0000
+++ compiler/rustc_target/src/spec/targets/aarch64_be_unknown_netbsd.rs
@@ -18,6 +18,7 @@ pub fn target() -> Target {
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
endian: Endian::Big,
+ has_thread_local: false, // ref. NetBSD PR#58154
..base::netbsd::opts()
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$NetBSD: patch-compiler_rustc__target_src_spec_targets_aarch64__unknown__netbsd.rs,v 1.1 2024/07/31 08:05:50 he Exp $

NetBSD aarch64 has a bug in the thread-local storage implementation,
ref. PR#58154. Turn it off for now.
Ideally should check whether the version has the fix or not, but
e.g. __NetBSD_Version__ isn't easily available here that I know...

--- compiler/rustc_target/src/spec/targets/aarch64_unknown_netbsd.rs.orig 2024-07-23 19:18:44.116841966 +0000
+++ compiler/rustc_target/src/spec/targets/aarch64_unknown_netbsd.rs
@@ -17,6 +17,7 @@ pub fn target() -> Target {
mcount: "__mcount".into(),
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
+ has_thread_local: false, // ref. NetBSD PR#58154
..base::netbsd::opts()
},
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
$NetBSD: patch-compiler_rustc__target_src_spec_targets_sparc64__unknown__netbsd.rs,v 1.1 2024/07/31 08:05:50 he Exp $

Make more similar to other sparc64 target specs.

--- compiler/rustc_target/src/spec/targets/sparc64_unknown_netbsd.rs.orig 2006-07-24 01:21:28.000000000 +0000
+++ compiler/rustc_target/src/spec/targets/sparc64_unknown_netbsd.rs
@@ -1,11 +1,13 @@
use crate::abi::Endian;
-use crate::spec::{base, Cc, LinkerFlavor, Lld, Target, TargetOptions};
+use crate::spec::{base, Cc, LinkerFlavor, Lld, Target};

pub fn target() -> Target {
let mut base = base::netbsd::opts();
base.cpu = "v9".into();
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
base.max_atomic_width = Some(64);
+ base.endian = Endian::Big;
+ base.mcount = "__mcount".into();

Target {
llvm_target: "sparc64-unknown-netbsd".into(),
@@ -18,6 +20,6 @@ pub fn target() -> Target {
pointer_width: 64,
data_layout: "E-m:e-i64:64-n32:64-S128".into(),
arch: "sparc64".into(),
- options: TargetOptions { endian: Endian::Big, mcount: "__mcount".into(), ..base },
+ options: base,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
$NetBSD: patch-vendor_openssl-src-111.28.1+1.1.1w_openssl_Configurations_10-main.conf,v 1.1 2024/07/31 08:05:50 he Exp $

Replicate part of
https://github.com/openssl/openssl/pull/15086

--- vendor/openssl-src-111.28.1+1.1.1w/openssl/Configurations/10-main.conf.orig 2006-07-24 01:21:28.000000000 +0000
+++ vendor/openssl-src-111.28.1+1.1.1w/openssl/Configurations/10-main.conf
@@ -950,6 +950,10 @@ my %targets = (
shared_cflag => "-fPIC",
shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
},
+ "NetBSD-generic32" => {
+ inherit_from => [ "BSD-generic32" ],
+ ex_libs => add(threads("-latomic")),
+ },
"BSD-generic64" => {
inherit_from => [ "BSD-generic32" ],
bn_ops => "SIXTY_FOUR_BIT_LONG",
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
$NetBSD: patch-vendor_openssl-src-111.28.1+1.1.1w_src_lib.rs,v 1.1 2024/07/31 08:05:50 he Exp $

Provide defaults for the various NetBSD targets.

--- vendor/openssl-src-111.28.1+1.1.1w/src/lib.rs.orig 2006-07-24 01:21:28.000000000 +0000
+++ vendor/openssl-src-111.28.1+1.1.1w/src/lib.rs
@@ -239,6 +239,8 @@ impl Build {
"aarch64-unknown-freebsd" => "BSD-generic64",
"aarch64-unknown-linux-gnu" => "linux-aarch64",
"aarch64-unknown-linux-musl" => "linux-aarch64",
+ "aarch64-unknown-netbsd" => "BSD-generic64",
+ "aarch64_be-unknown-netbsd" => "BSD-generic64",
"aarch64-pc-windows-msvc" => "VC-WIN64-ARM",
"arm-linux-androideabi" => "linux-armv4",
"armv7-linux-androideabi" => "linux-armv4",
@@ -249,14 +251,17 @@ impl Build {
"armv5te-unknown-linux-gnueabi" => "linux-armv4",
"armv5te-unknown-linux-musleabi" => "linux-armv4",
"armv6-unknown-freebsd" => "BSD-generic32",
+ "armv6-unknown-netbsd-eabihf" => "BSD-generic32",
"armv7-unknown-freebsd" => "BSD-generic32",
"armv7-unknown-linux-gnueabi" => "linux-armv4",
"armv7-unknown-linux-musleabi" => "linux-armv4",
"armv7-unknown-linux-gnueabihf" => "linux-armv4",
"armv7-unknown-linux-musleabihf" => "linux-armv4",
+ "armv7-unknown-netbsd-eabihf" => "BSD-generic32",
"asmjs-unknown-emscripten" => "gcc",
"i586-unknown-linux-gnu" => "linux-elf",
"i586-unknown-linux-musl" => "linux-elf",
+ "i586-unknown-netbsd" => "BSD-x86-elf",
"i686-apple-darwin" => "darwin-i386-cc",
"i686-linux-android" => "linux-elf",
"i686-pc-windows-gnu" => "mingw",
@@ -264,6 +269,7 @@ impl Build {
"i686-unknown-freebsd" => "BSD-x86-elf",
"i686-unknown-linux-gnu" => "linux-elf",
"i686-unknown-linux-musl" => "linux-elf",
+ "i686-unknown-netbsd" => "BSD-x86-elf",
"loongarch64-unknown-linux-gnu" => "linux-generic64",
"mips-unknown-linux-gnu" => "linux-mips32",
"mips-unknown-linux-musl" => "linux-mips32",
@@ -273,9 +279,11 @@ impl Build {
"mips64el-unknown-linux-muslabi64" => "linux64-mips64",
"mipsel-unknown-linux-gnu" => "linux-mips32",
"mipsel-unknown-linux-musl" => "linux-mips32",
+ "mipsel-unknown-netbsd" => "NetBSD-generic32",
"powerpc-unknown-freebsd" => "BSD-generic32",
"powerpc-unknown-linux-gnu" => "linux-ppc",
"powerpc-unknown-linux-gnuspe" => "linux-ppc",
+ "powerpc-unknown-netbsd" => "BSD-generic32",
"powerpc64-unknown-freebsd" => "BSD-generic64",
"powerpc64-unknown-linux-gnu" => "linux-ppc64",
"powerpc64-unknown-linux-musl" => "linux-ppc64",
@@ -283,8 +291,10 @@ impl Build {
"powerpc64le-unknown-linux-gnu" => "linux-ppc64le",
"powerpc64le-unknown-linux-musl" => "linux-ppc64le",
"riscv64gc-unknown-linux-gnu" => "linux-generic64",
+ "riscv64gc-unknown-netbsd" => "BSD-generic64",
"s390x-unknown-linux-gnu" => "linux64-s390x",
"s390x-unknown-linux-musl" => "linux64-s390x",
+ "sparc64-unknown-netbsd" => "BSD-generic64",
"x86_64-apple-darwin" => "darwin64-x86_64-cc",
"x86_64-linux-android" => "linux-x86_64",
"x86_64-pc-windows-gnu" => "mingw64",
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
$NetBSD: patch-vendor_openssl-sys-0.9.102_build_find__normal.rs,v 1.1 2024/07/31 08:05:51 he Exp $

Add hack for Darwin when homebrew is installed.

--- vendor/openssl-sys-0.9.102/build/find_normal.rs.orig 2006-07-24 01:21:28.000000000 +0000
+++ vendor/openssl-sys-0.9.102/build/find_normal.rs
@@ -72,23 +72,6 @@ fn resolve_with_wellknown_location(dir:
fn find_openssl_dir(target: &str) -> OsString {
let host = env::var("HOST").unwrap();

- if host == target && target.ends_with("-apple-darwin") {
- let homebrew_dir = match target {
- "aarch64-apple-darwin" => "/opt/homebrew",
- _ => "/usr/local",
- };
-
- if let Some(dir) = resolve_with_wellknown_homebrew_location(homebrew_dir) {
- return dir.into();
- } else if let Some(dir) = resolve_with_wellknown_location("/opt/pkg") {
- // pkgsrc
- return dir.into();
- } else if let Some(dir) = resolve_with_wellknown_location("/opt/local") {
- // MacPorts
- return dir.into();
- }
- }
-
try_pkg_config();
try_vcpkg();

23 changes: 23 additions & 0 deletions lang/rust/patches/patch-vendor_openssl-sys-0.9.102_build_main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
$NetBSD: patch-vendor_openssl-sys-0.9.102_build_main.rs,v 1.1 2024/07/31 08:05:51 he Exp $

Patterned after Linux and Android, on 32-bit NetBSD ports
include -latomic. Parts of this inspired by
https://github.com/sfackler/rust-openssl/commit/a0a1d1d29263abb7c47fc2e58cef8dab13762a45

--- vendor/openssl-sys-0.9.102/build/main.rs.orig 2006-07-24 01:21:28.000000000 +0000
+++ vendor/openssl-sys-0.9.102/build/main.rs
@@ -142,6 +142,14 @@ fn main() {
println!("cargo:rustc-link-lib=atomic");
}

+ // Patterned of the above, make sure we include -latomic
+ // on ilp32 ports (yes, this only tests the "p32" part).
+ if env::var("CARGO_CFG_TARGET_OS").unwrap() == "netbsd"
+ && env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "32"
+ {
+ println!("cargo:rustc-link-lib=atomic");
+ }
+
if kind == "static" && target.contains("windows") {
println!("cargo:rustc-link-lib=dylib=gdi32");
println!("cargo:rustc-link-lib=dylib=user32");
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
$NetBSD: patch-vendor_openssl-sys-0.9.92_build_find__normal.rs,v 1.1 2024/07/31 08:05:51 he Exp $

Add hack for Darwin when homebrew is installed.

--- vendor/openssl-sys-0.9.92/build/find_normal.rs.orig 2006-07-24 01:21:28.000000000 +0000
+++ vendor/openssl-sys-0.9.92/build/find_normal.rs
@@ -72,23 +72,6 @@ fn resolve_with_wellknown_location(dir:
fn find_openssl_dir(target: &str) -> OsString {
let host = env::var("HOST").unwrap();

- if host == target && target.ends_with("-apple-darwin") {
- let homebrew_dir = match target {
- "aarch64-apple-darwin" => "/opt/homebrew",
- _ => "/usr/local",
- };
-
- if let Some(dir) = resolve_with_wellknown_homebrew_location(homebrew_dir) {
- return dir.into();
- } else if let Some(dir) = resolve_with_wellknown_location("/opt/pkg") {
- // pkgsrc
- return dir.into();
- } else if let Some(dir) = resolve_with_wellknown_location("/opt/local") {
- // MacPorts
- return dir.into();
- }
- }
-
try_pkg_config();
try_vcpkg();

23 changes: 23 additions & 0 deletions lang/rust/patches/patch-vendor_openssl-sys-0.9.92_build_main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
$NetBSD: patch-vendor_openssl-sys-0.9.92_build_main.rs,v 1.1 2024/07/31 08:05:51 he Exp $

Patterned after Linux and Android, on 32-bit NetBSD ports
include -latomic. Parts of this inspired by
https://github.com/sfackler/rust-openssl/commit/a0a1d1d29263abb7c47fc2e58cef8dab13762a45

--- vendor/openssl-sys-0.9.92/build/main.rs.orig 2006-07-24 01:21:28.000000000 +0000
+++ vendor/openssl-sys-0.9.92/build/main.rs
@@ -115,6 +115,14 @@ fn main() {
println!("cargo:rustc-link-lib={}={}", kind, lib);
}

+ // Patterned of the above, make sure we include -latomic
+ // on ilp32 ports (yes, this only tests the "p32" part).
+ if env::var("CARGO_CFG_TARGET_OS").unwrap() == "netbsd"
+ && env::var("CARGO_CFG_TARGET_POINTER_WIDTH").unwrap() == "32"
+ {
+ println!("cargo:rustc-link-lib=atomic");
+ }
+
if kind == "static" && target.contains("windows") {
println!("cargo:rustc-link-lib=dylib=gdi32");
println!("cargo:rustc-link-lib=dylib=user32");

0 comments on commit c6fa78c

Please sign in to comment.