pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

rust: fix our "mipsel" target so that it can work.



Module Name:	pkgsrc-wip
Committed By:	Havard Eidnes <he%NetBSD.org@localhost>
Pushed By:	he
Date:		Thu Dec 29 14:25:11 2022 +0000
Changeset:	165260204b4613c8537b95045a60ce5071bfc6a8

Modified Files:
	rust/Makefile
	rust/distinfo
	rust/patches/patch-compiler_rustc__target_src_spec_mipsel__unknown__netbsd.rs
	rust/patches/patch-vendor_libc_src_unix_bsd_netbsdlike_netbsd_mod.rs
Added Files:
	rust/patches/patch-vendor_libc-0.2.126_src_unix_bsd_netbsdlike_netbsd_mips.rs
	rust/patches/patch-vendor_libc-0.2.126_src_unix_bsd_netbsdlike_netbsd_mod.rs

Log Message:
rust: fix our "mipsel" target so that it can work.

Earlier failed attempts:
 * cpu = "mips1", would have been more "portable" to older CPUs,
   but llvm failed to generate code for this cpu in at least one
   instance.  The "mips1" target in llvm is marked "highly experimental",
   so this is perhaps not surprising.
 * cpu = "mips3", an earlier mistake.  Produces "of course" 64-bit
   instructions, so gives "illegal instruction" on e.g. cobalt and
   32-bit-only CPUs.  Despite this also being marked "highly experimental"
   in llvm, this build completed.

So ... we give up some portability to the older CPUs, and generate
code for cpu = "mips32" with soft-float, and this produces a working
rustc / cargo combination, at least to the point that devel/cbindgen
can be built using a MIPSSIM kernel on qemu.

A native build of rust has yet to be attempted, it will be difficult
with the 508MB max memory limit for the 32-bit mips port, so the
next best is to try in a o32 chroot on a mips64 kernel which can
now get more memory.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=165260204b4613c8537b95045a60ce5071bfc6a8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 rust/Makefile                                      |  6 ++++-
 rust/distinfo                                      |  6 +++--
 ...stc__target_src_spec_mipsel__unknown__netbsd.rs |  7 ++++--
 ...-0.2.126_src_unix_bsd_netbsdlike_netbsd_mips.rs | 29 ++++++++++++++++++++++
 ...c-0.2.126_src_unix_bsd_netbsdlike_netbsd_mod.rs | 20 +++++++++++++++
 ...ndor_libc_src_unix_bsd_netbsdlike_netbsd_mod.rs |  7 ++----
 6 files changed, 65 insertions(+), 10 deletions(-)

diffs:
diff --git a/rust/Makefile b/rust/Makefile
index c8b126acf7..73695fe427 100644
--- a/rust/Makefile
+++ b/rust/Makefile
@@ -419,10 +419,14 @@ CKSUMS+=	36261a678137edb49eab7c4d51052e4a9c78312a248dd25c4b67a44180cfbbd6
 CKSUMS+=	8f9613e50c2771b33d7cf817a735d536b389ec57f861b9486d870373c768276e
 CKSUMS+=	86a2db06339eb850f9d28d524a94a9db5aa4f4d2c3fd080fb90c8c101ef53bed
 CKSUMS+=	fa260decf53280d4fdf714af60f42d4774f8d6f2da71b0a55a6c2a85e422eb57
-CKSUMS+=	624b6c3cc11d3785b6a3eacf1dbae820192e12c7c7da7de0abde94eb86fbf27e
+CKSUMS+=	d35c4f5c2ad764235adc8b315a3b8d69c3f322feeda0738f56a1a25b49a9649d
 CKSUMS+=	52a31038984e68582347f4b28fd64c01e6308ff4293628818bb279605e7b28c6
 CKSUMS+=	d7c68074765debe9f6d21797be22b34f7699535e2b9f15b131db18a8ba2bc751
 
+CKSUM_CRATES+=	vendor/libc-0.2.126
+CKSUMS+=	cb1560bf8ffcc7b2726a27b433efac90e726292960626f3064bd2c6b7f861a55
+CKSUMS+=	e449f032ed443158128ef105521fbe67aaef8f01beb83581357e774fab67d0ea
+
 CKSUM_CRATES+=	vendor/lzma-sys
 CKSUMS+=	6fd5e9245db34c6f557b8bfcaf03db82fc88c3b06dbfbb5f03b2bcd138983ef9
 CKSUMS+=	5e252578b5d266f6a4c8dc9f71ca7a91536ccb8c5c7d7753b82f12ec886459ef
diff --git a/rust/distinfo b/rust/distinfo
index 8f69abe9e7..f6f0a97fe7 100644
--- a/rust/distinfo
+++ b/rust/distinfo
@@ -112,7 +112,7 @@ SHA1 (patch-compiler_rustc__codegen__ssa_src_back_linker.rs) = 62819cf6db7d2e3e7
 SHA1 (patch-compiler_rustc__llvm_build.rs) = e99c9eb2fd1731c0e6f5d38ff74bf28bf0be87d0
 SHA1 (patch-compiler_rustc__target_src_spec_aarch64__be__unknown__netbsd.rs) = c81d0d288699056ae45569f8d0a1c9bb08153ec4
 SHA1 (patch-compiler_rustc__target_src_spec_i586__unknown__netbsd.rs) = 866d01e7c1f3d8dd7d26f2fdc4360df273ed401f
-SHA1 (patch-compiler_rustc__target_src_spec_mipsel__unknown__netbsd.rs) = 2c5d6088a7df293b6c4ffea54c8751d2f5722495
+SHA1 (patch-compiler_rustc__target_src_spec_mipsel__unknown__netbsd.rs) = fc78fc681f170be9e3b6e3c823a6bd62da742cbd
 SHA1 (patch-compiler_rustc__target_src_spec_mod.rs) = 5042a89fe5da4219b54082c104a1b44ba7cc395e
 SHA1 (patch-compiler_rustc__target_src_spec_netbsd__base.rs) = bc73a140d7b1d3ced12ad2564be4edce5b9579f0
 SHA1 (patch-library_backtrace_src_symbolize_gimli.rs) = 32ab8ea3809cd4f6fee9fc0df5db47d76ccbd9d2
@@ -146,8 +146,10 @@ SHA1 (patch-vendor_crossbeam-utils-0.8.8_no__atomic.rs) = 7f31d6c45ef843eb2595df
 SHA1 (patch-vendor_crossbeam-utils_no__atomic.rs) = 4ada02a26490ca6fcd87af999bbb8cef48078060
 SHA1 (patch-vendor_crossbeam_no__atomic.rs) = 6054fa9cb00b9cc7d9125354702945ac22ad6aeb
 SHA1 (patch-vendor_kqueue_src_time.rs) = 21950e7d79fb88257bdb11b988f2a3ae0084ba3d
+SHA1 (patch-vendor_libc-0.2.126_src_unix_bsd_netbsdlike_netbsd_mips.rs) = 4d3bcccb5aa57260d93baaee1beb4d3e3d6f3aa4
+SHA1 (patch-vendor_libc-0.2.126_src_unix_bsd_netbsdlike_netbsd_mod.rs) = 3f498a38aaecf15386160218a013394f17b10e21
 SHA1 (patch-vendor_libc_src_unix_bsd_netbsdlike_netbsd_mips.rs) = 09326b70d7821b1742285c464c70b347400191d7
-SHA1 (patch-vendor_libc_src_unix_bsd_netbsdlike_netbsd_mod.rs) = 94608147cae5fd7a6ae2aed14ca8da4b1c92db1e
+SHA1 (patch-vendor_libc_src_unix_bsd_netbsdlike_netbsd_mod.rs) = 5b74832fac31de5064eee07e240be4acdbb8606c
 SHA1 (patch-vendor_libc_src_unix_solarish_mod.rs) = 8364e19ea09203d32494c37ff3db19fe3d6b9d8a
 SHA1 (patch-vendor_lzma-sys_config.h) = b654c7e129fa02697734bc87173f89b3056a5437
 SHA1 (patch-vendor_openssl-src_openssl_Configurations_10-main.conf) = 1c4e1d5520776e70d588f3da0fd54b6f956835b5
diff --git a/rust/patches/patch-compiler_rustc__target_src_spec_mipsel__unknown__netbsd.rs b/rust/patches/patch-compiler_rustc__target_src_spec_mipsel__unknown__netbsd.rs
index 3d6cd07fd4..cdee1caa6f 100644
--- a/rust/patches/patch-compiler_rustc__target_src_spec_mipsel__unknown__netbsd.rs
+++ b/rust/patches/patch-compiler_rustc__target_src_spec_mipsel__unknown__netbsd.rs
@@ -1,17 +1,19 @@
 $NetBSD$
 
 Add target spec for NetBSD/mipsel.
+This one uses mips32 (mips1 llvm fails), so this one is not universally
+usable on NetBSD's supported 32-bit MIPS processors.
 
 --- compiler/rustc_target/src/spec/mipsel_unknown_netbsd.rs.orig	2022-11-06 18:16:59.750850353 +0000
 +++ compiler/rustc_target/src/spec/mipsel_unknown_netbsd.rs	2022-11-06 18:14:10.846209169 +0000
-@@ -0,0 +1,20 @@
+@@ -0,0 +1,21 @@
 +use crate::abi::Endian;
 +use crate::spec::{Target, TargetOptions};
 +
 +pub fn target() -> Target {
 +    let mut base = super::netbsd_base::opts();
 +    base.max_atomic_width = Some(32);
-+    base.cpu = "mips3".into();
++    base.cpu = "mips32".into();
 +
 +    Target {
 +	llvm_target: "mipsel-unknown-netbsd".into(),
@@ -19,6 +21,7 @@ Add target spec for NetBSD/mipsel.
 +	data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(),
 +	arch: "mips".into(),
 +	options: TargetOptions {
++	    features: "+soft-float".into(),
 +	    mcount: "__mcount".into(),
 +	    endian: Endian::Little,
 +	    ..base
diff --git a/rust/patches/patch-vendor_libc-0.2.126_src_unix_bsd_netbsdlike_netbsd_mips.rs b/rust/patches/patch-vendor_libc-0.2.126_src_unix_bsd_netbsdlike_netbsd_mips.rs
new file mode 100644
index 0000000000..b547540086
--- /dev/null
+++ b/rust/patches/patch-vendor_libc-0.2.126_src_unix_bsd_netbsdlike_netbsd_mips.rs
@@ -0,0 +1,29 @@
+$NetBSD$
+
+Replicate patch from unversioned libc.
+
+--- vendor/libc-0.2.126/src/unix/bsd/netbsdlike/netbsd/mips.rs.orig	2022-12-28 21:30:25.222843485 +0000
++++ vendor/libc-0.2.126/src/unix/bsd/netbsdlike/netbsd/mips.rs
+@@ -0,0 +1,22 @@
++use PT_FIRSTMACH;
++
++pub type c_long = i32;
++pub type c_ulong = u32;
++pub type c_char = i8;
++pub type __cpu_simple_lock_nv_t = ::c_int;
++
++// should be pub(crate), but that requires Rust 1.18.0
++cfg_if! {
++    if #[cfg(libc_const_size_of)] {
++        #[doc(hidden)]
++        pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1;
++    } else {
++        #[doc(hidden)]
++        pub const _ALIGNBYTES: usize = 8 - 1;
++    }
++}
++
++pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1;
++pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2;
++pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 3;
++pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 4;
diff --git a/rust/patches/patch-vendor_libc-0.2.126_src_unix_bsd_netbsdlike_netbsd_mod.rs b/rust/patches/patch-vendor_libc-0.2.126_src_unix_bsd_netbsdlike_netbsd_mod.rs
new file mode 100644
index 0000000000..32c1c0918e
--- /dev/null
+++ b/rust/patches/patch-vendor_libc-0.2.126_src_unix_bsd_netbsdlike_netbsd_mod.rs
@@ -0,0 +1,20 @@
+$NetBSD$
+
+Replicate patch from un-versioned libc.
+
+--- vendor/libc-0.2.126/src/unix/bsd/netbsdlike/netbsd/mod.rs.orig	2022-12-12 18:23:58.000000000 +0000
++++ vendor/libc-0.2.126/src/unix/bsd/netbsdlike/netbsd/mod.rs
+@@ -2840,7 +2840,12 @@ cfg_if! {
+     } else if #[cfg(target_arch = "x86")] {
+         mod x86;
+         pub use self::x86::*;
++    } else if #[cfg(target_arch = "mips")] {
++	mod mips;
++	pub use self::mips::*;
+     } else {
+-        // Unknown target_arch
++        // Unknown target_arch, this should error out
++	mod unknown;
++	pub use self::unknown::*;
+     }
+ }
diff --git a/rust/patches/patch-vendor_libc_src_unix_bsd_netbsdlike_netbsd_mod.rs b/rust/patches/patch-vendor_libc_src_unix_bsd_netbsdlike_netbsd_mod.rs
index f323097969..a8eae5a15a 100644
--- a/rust/patches/patch-vendor_libc_src_unix_bsd_netbsdlike_netbsd_mod.rs
+++ b/rust/patches/patch-vendor_libc_src_unix_bsd_netbsdlike_netbsd_mod.rs
@@ -4,7 +4,7 @@ Copy execinfo function definitions from openbsd's mod.rs.
 
 --- vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs.orig	2022-05-10 20:59:35.217463943 +0000
 +++ vendor/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs
-@@ -2971,6 +2971,22 @@ extern "C" {
+@@ -3008,6 +3008,22 @@ extern "C" {
      pub fn kinfo_getvmmap(pid: ::pid_t, cntp: *mut ::size_t) -> *mut kinfo_vmentry;
  }
  
@@ -27,15 +27,12 @@ Copy execinfo function definitions from openbsd's mod.rs.
  cfg_if! {
      if #[cfg(target_arch = "aarch64")] {
          mod aarch64;
-@@ -2990,7 +3006,15 @@ cfg_if! {
+@@ -3027,7 +3043,12 @@ cfg_if! {
      } else if #[cfg(target_arch = "x86")] {
          mod x86;
          pub use self::x86::*;
 +    } else if #[cfg(target_arch = "mips")] {
 +        mod mips;
-+        pub use self::mips::*;
-+    } else if #[cfg(target_arch = "mipsel")] {
-+        mod mips;
 +        pub use self::mips::*;
      } else {
 -        // Unknown target_arch


Home | Main Index | Thread Index | Old Index