pkgsrc-Users archive

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

Re: rust: use system libunwind



Hi,

The attached patch should hopefully fix the issues with external
libunwind on Linux. Please try it and if it packages also try to build
some packages like devel/cargo-c to check for regressions.
If pkgsrc zlib still fails to link it may need a similar fix.
If so adjust the lib == "unwind" condition to match also "z".

Kind regards,
-Tobias
? rust-fix-linux-build.patch.txt
Index: distinfo
===================================================================
RCS file: /cvsroot/pkgsrc/lang/rust/distinfo,v
retrieving revision 1.167
diff -p -u -r1.167 distinfo
--- distinfo	3 Mar 2024 14:57:30 -0000	1.167
+++ distinfo	11 Apr 2024 11:23:42 -0000
@@ -114,7 +114,7 @@ Size (rust-std-1.74.1-x86_64-unknown-net
 BLAKE2s (rustc-1.75.0-src.tar.gz) = ce73634181497293f543514b5e22b059b9f7b4d102766db8beaa76fd9baf7db4
 SHA512 (rustc-1.75.0-src.tar.gz) = c0fbc7349082bdda5693664f86e2814e3a15272dd1b5028859e9d0d864b4375fae94b7039e14567d25bc9c3c4d8187734a163a2522b75cb1f267f7b9e57c3385
 Size (rustc-1.75.0-src.tar.gz) = 285857065 bytes
-SHA1 (patch-compiler_rustc__codegen__ssa_src_back_linker.rs) = 62819cf6db7d2e3e77d433fe883046c28fc20d91
+SHA1 (patch-compiler_rustc__codegen__ssa_src_back_linker.rs) = a401c9860c7d4e0f76e1e0616de50a9044382136
 SHA1 (patch-compiler_rustc__llvm_build.rs) = a4a66d449fc9eb99d648d02a041778a68f4f7ce8
 SHA1 (patch-compiler_rustc__target_src_spec_base_netbsd.rs) = 7fb6ec6d45a9bf4525c675390117e9e61b8023cd
 SHA1 (patch-compiler_rustc__target_src_spec_mod.rs) = a22b5d28997ed9a5565deec9c34322165d563d00
@@ -127,7 +127,7 @@ SHA1 (patch-library_std_src_sys_unix_thr
 SHA1 (patch-src_bootstrap_bootstrap.py) = 5cd73003292c935ce0e405edd132180233a04857
 SHA1 (patch-src_bootstrap_src_core_build__steps_compile.rs) = 4696304623232acd419ad15597f539a10a014271
 SHA1 (patch-src_bootstrap_src_core_build__steps_llvm.rs) = aba4c50ffd0a037096ea34a5e9660f8b435d997f
-SHA1 (patch-src_bootstrap_src_core_builder.rs) = 557721367140fe1078ce9948296f1a747fab56f0
+SHA1 (patch-src_bootstrap_src_core_builder.rs) = ec809ca54600aaa805cf8431cbb4a865693e6102
 SHA1 (patch-src_bootstrap_src_lib.rs) = d29bc3c0b335d5e788eecbb02fc08966beef0fb1
 SHA1 (patch-src_llvm-project_llvm_CMakeLists.txt) = 7abfabb6ec70df229a69355f8c76825610165c37
 SHA1 (patch-src_llvm-project_llvm_cmake_modules_AddLLVM.cmake) = e1b2eb2f0b3cf1cf87b443656ae306b3242f6b12
Index: patches/patch-compiler_rustc__codegen__ssa_src_back_linker.rs
===================================================================
RCS file: /cvsroot/pkgsrc/lang/rust/patches/patch-compiler_rustc__codegen__ssa_src_back_linker.rs,v
retrieving revision 1.12
diff -p -u -r1.12 patch-compiler_rustc__codegen__ssa_src_back_linker.rs
--- patches/patch-compiler_rustc__codegen__ssa_src_back_linker.rs	25 Oct 2023 05:50:43 -0000	1.12
+++ patches/patch-compiler_rustc__codegen__ssa_src_back_linker.rs	11 Apr 2024 11:23:42 -0000
@@ -1,10 +1,11 @@
-$NetBSD: patch-compiler_rustc__codegen__ssa_src_back_linker.rs,v 1.12 2023/10/25 05:50:43 pin Exp $
+$NetBSD$
 
 Do not use @rpath on Darwin.
+Find external linunwind on Linux.
 
---- compiler/rustc_codegen_ssa/src/back/linker.rs.orig	2022-12-12 16:02:12.000000000 +0000
+--- compiler/rustc_codegen_ssa/src/back/linker.rs.orig	2023-12-21 16:55:28.000000000 +0000
 +++ compiler/rustc_codegen_ssa/src/back/linker.rs
-@@ -325,7 +325,7 @@ impl<'a> GccLinker<'a> {
+@@ -329,7 +329,7 @@ impl<'a> GccLinker<'a> {
              // principled solution at some point to force the compiler to pass
              // the right `-Wl,-install_name` with an `@rpath` in it.
              if self.sess.opts.cg.rpath || self.sess.opts.unstable_opts.osx_rpath_install_name {
@@ -13,3 +14,14 @@ Do not use @rpath on Darwin.
                  rpath.push(out_filename.file_name().unwrap());
                  self.linker_args(&[OsString::from("-install_name"), rpath]);
              }
+@@ -455,6 +455,10 @@ impl<'a> Linker for GccLinker<'a> {
+                 self.linker_arg("--as-needed");
+             }
+         }
++        if self.sess.target.os.contains("linux") && lib == "unwind" {
++            self.linker_arg("-rpath,@PREFIX@/lib");
++            self.linker_arg("-L@PREFIX@/lib");
++        }
+     }
+     fn link_staticlib(&mut self, lib: &str, verbatim: bool) {
+         self.hint_static();
Index: patches/patch-src_bootstrap_src_core_builder.rs
===================================================================
RCS file: /cvsroot/pkgsrc/lang/rust/patches/patch-src_bootstrap_src_core_builder.rs,v
retrieving revision 1.1
diff -p -u -r1.1 patch-src_bootstrap_src_core_builder.rs
--- patches/patch-src_bootstrap_src_core_builder.rs	3 Mar 2024 14:53:32 -0000	1.1
+++ patches/patch-src_bootstrap_src_core_builder.rs	11 Apr 2024 11:23:42 -0000
@@ -1,8 +1,9 @@
-$NetBSD: patch-src_bootstrap_src_core_builder.rs,v 1.1 2024/03/03 14:53:32 he Exp $
+$NetBSD$
 
 Use @PREFIX@, not $ORIGIN in rpath.
+Find external libunwind on Linux.
 
---- src/bootstrap/src/core/builder.rs.orig	2024-01-13 20:06:50.748741545 +0000
+--- src/bootstrap/src/core/builder.rs.orig	2023-12-21 16:55:28.000000000 +0000
 +++ src/bootstrap/src/core/builder.rs
 @@ -1678,7 +1678,7 @@ impl<'a> Builder<'a> {
                  && !target.contains("xous")
@@ -13,3 +14,15 @@ Use @PREFIX@, not $ORIGIN in rpath.
              } else {
                  None
              };
+@@ -2095,6 +2095,11 @@ impl<'a> Builder<'a> {
+             rustflags.arg("-Zinline-mir");
+         }
+ 
++        // added for pkgsrc libunwind
++        if target.contains("linux") {
++            rustflags.arg("-Clink-args=-Wl,-rpath,@PREFIX@/lib,-L@PREFIX@/lib");
++        }
++
+         // set rustc args passed from command line
+         let rustc_args =
+             self.config.cmd.rustc_args().iter().map(|s| s.to_string()).collect::<Vec<_>>();


Home | Main Index | Thread Index | Old Index