aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Kubaj <pkubaj@FreeBSD.org>2022-11-24 18:02:15 +0000
committerPiotr Kubaj <pkubaj@FreeBSD.org>2022-11-24 18:17:45 +0000
commitf0ee4a8524218edb81fe0be3fce56b7f15b2dae1 (patch)
treef01a21243d5fc8bd725043428c606ae437727e20
parent9fd803845f22794afaf041daef820f9535907223 (diff)
downloadports-f0ee4a8524218edb81fe0be3fce56b7f15b2dae1.tar.gz
ports-f0ee4a8524218edb81fe0be3fce56b7f15b2dae1.zip
lang/rust: fix build on armv7 the same way as for powerpc
-rw-r--r--lang/rust/Makefile7
-rw-r--r--lang/rust/files/patch-compiler_rustc__llvm_build.rs42
-rw-r--r--lang/rust/files/powerpc/patch-compiler_rustc__llvm_build.rs29
3 files changed, 47 insertions, 31 deletions
diff --git a/lang/rust/Makefile b/lang/rust/Makefile
index 19b7cc66e748..48abb4cb624f 100644
--- a/lang/rust/Makefile
+++ b/lang/rust/Makefile
@@ -111,12 +111,15 @@ IGNORE= is only for FreeBSD
.if ${ARCH} == powerpc
# bfd to link rustc_driver; lld currently can't
BUILD_DEPENDS+= ld.bfd:devel/binutils
-LIB_DEPENDS+= libatomic.so:lang/gcc${GCC_DEFAULT}
-MAKE_ENV+= RUSTFLAGS="-L/usr/local/lib/gcc${GCC_DEFAULT}"
.else
MAKE_ENV+= RUST_BACKTRACE=1
.endif
+.if ${ARCH} == armv7 || ${ARCH} == powerpc
+LIB_DEPENDS+= libatomic.so:lang/gcc${GCC_DEFAULT}
+MAKE_ENV+= RUSTFLAGS="-L/usr/local/lib/gcc${GCC_DEFAULT}"
+.endif
+
# rls doesn't build on rust nightly
# rls needs 64-bit atomics: it doesn't build on powerpc
.if !defined(NIGHTLY_DATE) && ${ARCH} != powerpc
diff --git a/lang/rust/files/patch-compiler_rustc__llvm_build.rs b/lang/rust/files/patch-compiler_rustc__llvm_build.rs
new file mode 100644
index 000000000000..4509c7b9d54c
--- /dev/null
+++ b/lang/rust/files/patch-compiler_rustc__llvm_build.rs
@@ -0,0 +1,42 @@
+From cbeec86a5594ef6ca36d0ea24b4cb7e3dbaded87 Mon Sep 17 00:00:00 2001
+From: pkubaj <pkubaj@FreeBSD.org>
+Date: Fri, 18 Nov 2022 12:36:49 +0000
+Subject: [PATCH] Fix build on powerpc-unknown-freebsd
+
+Probably also fixes build on arm and mips*. Related to https://github.com/rust-lang/rust/issues/104220
+---
+ compiler/rustc_llvm/build.rs | 15 +++++++++------
+ 1 file changed, 9 insertions(+), 6 deletions(-)
+
+diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs
+index d35e4191cc0b1..afdf9ac8883e9 100644
+--- compiler/rustc_llvm/build.rs
++++ compiler/rustc_llvm/build.rs
+@@ -237,18 +237,21 @@ fn main() {
+
+ if !is_crossed {
+ cmd.arg("--system-libs");
+- } else if target.contains("windows-gnu") {
+- println!("cargo:rustc-link-lib=shell32");
+- println!("cargo:rustc-link-lib=uuid");
+- } else if target.contains("netbsd") || target.contains("haiku") || target.contains("darwin") {
+- println!("cargo:rustc-link-lib=z");
+- } else if target.starts_with("arm")
++ }
++
++ if target.starts_with("arm")
+ || target.starts_with("mips-")
+ || target.starts_with("mipsel-")
+ || target.starts_with("powerpc-")
+ {
+ // 32-bit targets need to link libatomic.
+ println!("cargo:rustc-link-lib=atomic");
++ println!("cargo:rustc-link-lib=z");
++ } else if target.contains("windows-gnu") {
++ println!("cargo:rustc-link-lib=shell32");
++ println!("cargo:rustc-link-lib=uuid");
++ } else if target.contains("netbsd") || target.contains("haiku") || target.contains("darwin") {
++ println!("cargo:rustc-link-lib=z");
+ }
+ cmd.args(&components);
+
diff --git a/lang/rust/files/powerpc/patch-compiler_rustc__llvm_build.rs b/lang/rust/files/powerpc/patch-compiler_rustc__llvm_build.rs
deleted file mode 100644
index efe5542e0e1b..000000000000
--- a/lang/rust/files/powerpc/patch-compiler_rustc__llvm_build.rs
+++ /dev/null
@@ -1,29 +0,0 @@
---- compiler/rustc_llvm/build.rs.orig 2022-11-15 08:26:08.366900000 +0100
-+++ compiler/rustc_llvm/build.rs 2022-11-15 08:29:07.101616000 +0100
-@@ -235,20 +235,18 @@ fn main() {
- let mut cmd = Command::new(&llvm_config);
- cmd.arg(llvm_link_arg).arg("--libs");
-
-- if !is_crossed {
-+ if target.starts_with("arm")
-+ || target.starts_with("powerpc-")
-+ {
-+ println!("cargo:rustc-link-lib=atomic");
-+ println!("cargo:rustc-link-lib=z");
-+ } else if !is_crossed {
- cmd.arg("--system-libs");
- } else if target.contains("windows-gnu") {
- println!("cargo:rustc-link-lib=shell32");
- println!("cargo:rustc-link-lib=uuid");
- } else if target.contains("netbsd") || target.contains("haiku") || target.contains("darwin") {
- println!("cargo:rustc-link-lib=z");
-- } else if target.starts_with("arm")
-- || target.starts_with("mips-")
-- || target.starts_with("mipsel-")
-- || target.starts_with("powerpc-")
-- {
-- // 32-bit targets need to link libatomic.
-- println!("cargo:rustc-link-lib=atomic");
- }
- cmd.args(&components);
-