From 635dd86cac3aa437d6194124485b1efacaed2adf Mon Sep 17 00:00:00 2001
From: Tim Biermann <tbier@posteo.de>
Date: Fri, 22 Sep 2023 19:23:20 +0200
Subject: [PATCH] rust: rebuilt for llvm 17

---
 rust/.footprint                 | 62 ---------------------------------
 rust/.signature                 |  6 ++--
 rust/Pkgfile                    | 13 +++++--
 rust/maintainer_clean_footprint | 11 ++++++
 4 files changed, 24 insertions(+), 68 deletions(-)
 create mode 100755 rust/maintainer_clean_footprint

diff --git a/rust/.footprint b/rust/.footprint
index c070e5d74..341610bbd 100644
--- a/rust/.footprint
+++ b/rust/.footprint
@@ -17,9 +17,6 @@ drwxr-xr-x	root/root	usr/bin/
 -rwxr-xr-x	root/root	usr/bin/rustfmt
 drwxr-xr-x	root/root	usr/lib/
 -rwxr-xr-x	root/root	usr/lib/cargo-credential-1password
--rw-r--r--	root/root	usr/lib/librustc_driver-f7e5d33dbd75fe5d.so
--rw-r--r--	root/root	usr/lib/libstd-50c1d16d6f6157a1.so
--rw-r--r--	root/root	usr/lib/libtest-8821a20103e22414.so
 -rwxr-xr-x	root/root	usr/lib/rust-analyzer-proc-macro-srv
 drwxr-xr-x	root/root	usr/lib/rustlib/
 drwxr-xr-x	root/root	usr/lib/rustlib/etc/
@@ -32,35 +29,6 @@ drwxr-xr-x	root/root	usr/lib/rustlib/etc/
 -rw-r--r--	root/root	usr/lib/rustlib/etc/rust_types.py
 drwxr-xr-x	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/
 drwxr-xr-x	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libaddr2line-9c8751a65fdb4587.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libadler-9385269e1191e0d7.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/liballoc-9b238e6d55539011.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libcfg_if-94b231bc57d45044.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libcompiler_builtins-20e2186333919fe6.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libcore-7c983eb2a381bf73.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libgetopts-d934f6c22975aa50.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libgimli-4010d9e5c51bba03.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libhashbrown-ede5eb3f3c4ff06b.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/liblibc-704a8258d126c33d.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libmemchr-3e929970524b1bed.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libminiz_oxide-17a69d0fac8d46b1.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libobject-0fffb56a36d7cd50.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libpanic_abort-c9b30049a77f02dc.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libpanic_unwind-83114828d9f6063a.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libproc_macro-790bf2ea3edcdb80.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libprofiler_builtins-9e3f55a894a32473.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/librustc_demangle-df3a1e023d434f11.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/librustc_std_workspace_alloc-da665452ad72ca72.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/librustc_std_workspace_core-6a70df351097ce63.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/librustc_std_workspace_std-ee806b97b0614ee0.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libstd-d1f45c19a421f635.rlib
--rwxr-xr-x	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libstd-d1f45c19a421f635.so
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libstd_detect-1448003347d72f1a.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libsysroot-f05d51cae539455d.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libtest-a8c897997d1e3b77.rlib
--rwxr-xr-x	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libtest-a8c897997d1e3b77.so
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libunicode_width-26a093e2185baae8.rlib
--rw-r--r--	root/root	usr/lib/rustlib/i686-unknown-linux-gnu/lib/libunwind-5ef6a0a6e01304a1.rlib
 drwxr-xr-x	root/root	usr/lib/rustlib/src/
 drwxr-xr-x	root/root	usr/lib/rustlib/src/rust/
 -rw-r--r--	root/root	usr/lib/rustlib/src/rust/Cargo.lock
@@ -1978,7 +1946,6 @@ drwxr-xr-x	root/root	usr/lib/rustlib/src/rust/src/llvm-project/libunwind/test/co
 -rw-r--r--	root/root	usr/lib/rustlib/src/rust/src/llvm-project/libunwind/test/configs/llvm-libunwind-static.cfg.in
 -rw-r--r--	root/root	usr/lib/rustlib/src/rust/src/llvm-project/libunwind/test/floatregister.pass.cpp
 -rw-r--r--	root/root	usr/lib/rustlib/src/rust/src/llvm-project/libunwind/test/forceunwind.pass.cpp
--rw-r--r--	root/root	usr/lib/rustlib/src/rust/src/llvm-project/libunwind/test/frameheadercache_test.pass.cpp
 -rw-r--r--	root/root	usr/lib/rustlib/src/rust/src/llvm-project/libunwind/test/libunwind_01.pass.cpp
 -rw-r--r--	root/root	usr/lib/rustlib/src/rust/src/llvm-project/libunwind/test/libunwind_02.pass.cpp
 -rw-r--r--	root/root	usr/lib/rustlib/src/rust/src/llvm-project/libunwind/test/lit.cfg.py
@@ -1991,40 +1958,11 @@ drwxr-xr-x	root/root	usr/lib/rustlib/src/rust/src/llvm-project/libunwind/test/co
 -rw-r--r--	root/root	usr/lib/rustlib/src/rust/src/llvm-project/libunwind/test/unwind_scalable_vectors.pass.cpp
 drwxr-xr-x	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/
 drwxr-xr-x	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-18b62ea0da20918f.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-e02da72b52c78f34.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-f77ce964b897b9f9.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-032e476c53d465fe.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-54f76a39355e7e15.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-529e1e00c5ca76c8.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgetopts-8f5b82f7461bec57.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-0f6882f15355c60f.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-0fc86a1c5888a88d.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-a54574efc80b5ea8.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-51dc6398bebc292a.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-375ebcb5fd4d4d6b.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-1b642689cd4b18fc.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_abort-c8b3346b1ec21423.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-87788777e17bfeba.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libproc_macro-944114b6f889eb55.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libprofiler_builtins-505e283f8aa36187.rlib
 -rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc-stable_rt.asan.a
 -rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc-stable_rt.lsan.a
 -rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc-stable_rt.msan.a
 -rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc-stable_rt.safestack.a
 -rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc-stable_rt.tsan.a
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-3e43dfcd60bbbbc7.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-2e742c79f9d36314.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-c49747b6cb7bb060.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_std-0b3506bd91252e46.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-50c1d16d6f6157a1.rlib
--rwxr-xr-x	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-50c1d16d6f6157a1.so
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-48e4b721171f064f.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libsysroot-1aca37b52832c0de.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libtest-8821a20103e22414.rlib
--rwxr-xr-x	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libtest-8821a20103e22414.so
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunicode_width-29955766608ab07c.rlib
--rw-r--r--	root/root	usr/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-7986088c9bc15673.rlib
 drwxr-xr-x	root/root	usr/share/
 drwxr-xr-x	root/root	usr/share/man/
 drwxr-xr-x	root/root	usr/share/man/man1/
diff --git a/rust/.signature b/rust/.signature
index cfced0939..f44d9b12d 100644
--- a/rust/.signature
+++ b/rust/.signature
@@ -1,7 +1,7 @@
 untrusted comment: verify with /etc/ports/opt.pub
-RWSE3ohX2g5d/Xr2XNDRUONxGMAciXmLR63LlGQEWAc6xVSK6xw4LF45v9gnp8h/ugj+lJvQ5LyM6qqi1mKX7qN+vH/Z5R+sNgE=
-SHA256 (Pkgfile) = db6d123e64c06ede8ec030c1e49459252a2dca3a6dc82256adb51e39e55c3ea2
-SHA256 (.footprint) = 781d4aaa21c47df93ac2d6aabc52268a35713caa811457092750324f47614b0a
+RWSE3ohX2g5d/aywLQLj6u/ctcuapztvFrQot7LCIfvqMzZGsjK/iYR/uaZOI4KkO8uP2MisqovBySj2LnDtqtZOiNaWzBLFhQA=
+SHA256 (Pkgfile) = 3fe7ab4ba1c04dbe1000c18c76d1156e89c76bf0337d2e38c7e9b41be4fc73d4
+SHA256 (.footprint) = 5bef79ca1ee1814a1c4c746003cbbf376a751e611b438f9bddd090f0e080e3ad
 SHA256 (rustc-1.72.1-src.tar.xz) = aea58d962ff1c19521b9f587aad88285f0fd35b6b6738b031a7a15bb1b70a7c3
 SHA256 (rust-std-1.71.0-x86_64-unknown-linux-gnu.tar.xz) = 98ae6530c3a41167e9d93d11ea078be98a02f6d809a06d0d51af3ce0f73150d7
 SHA256 (rustc-1.71.0-x86_64-unknown-linux-gnu.tar.xz) = c293d906769671d1cd18e945671bbd14e0b8a41df5075c47f33e6086fc8a1558
diff --git a/rust/Pkgfile b/rust/Pkgfile
index e2ff6dee9..e70d26c85 100644
--- a/rust/Pkgfile
+++ b/rust/Pkgfile
@@ -9,7 +9,7 @@ version=1.72.1
 _date=2023-07-13
 _rustc=1.71.0
 _cargo=$_rustc
-release=1
+release=2
 
 source=(https://static.rust-lang.org/dist/${name}c-$version-src.tar.xz
 	https://static.rust-lang.org/dist/$_date/rust-std-$_rustc-x86_64-unknown-linux-gnu.tar.xz
@@ -69,6 +69,12 @@ build() {
 	# Use our *-pc-linux-gnu targets, making LTO with clang simpler
 	patch -p1 -i $SRC/0002-compiler-Change-LLVM-targets.patch
 
+	# temp fixes for LLVM 17
+	# https://www.linuxfromscratch.org/blfs/view/svn/general/rust.html
+	sed 's/FS,/"", &/' -i ./compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
+	sed '/LLVMContext.h/i#include "llvm/ADT/SmallString.h"' \
+		-i compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp
+
 cat <<- EOF > $SRC/config.toml
 	changelog-seen = 2
 
@@ -180,7 +186,8 @@ EOF
 	#   = note: `-D dead-code` implied by `-D warnings`
 	export RUSTFLAGS+=' -A dead_code'
 
-	export LIBGIT2_NO_PKG_CONFIG=1
+	{ [ ! -e /usr/include/libssh2.h ] ||
+		export LIBSSH2_SYS_USE_PKG_CONFIG=1; }
 	export RUST_BACKTRACE=full
 	/usr/bin/python3 ./x.py build --config="${SRC}"/config.toml -j ${JOBS-1}
 	DESTDIR=$PKG /usr/bin/python3 ./x.py --config="${SRC}"/config.toml install
@@ -206,6 +213,6 @@ EOF
 		fi
 	done < <(find "$PKG/usr/lib/rustlib"  -path '*/analysis/*.json' -print0)
 
-	rm $PKG/usr/bin/*.old
+	find $PKG/usr -name "*.old" -delete
 	rm $PKG/usr/lib/rustlib/{install.log,manifest-*}
 }
diff --git a/rust/maintainer_clean_footprint b/rust/maintainer_clean_footprint
new file mode 100755
index 000000000..7a42cc619
--- /dev/null
+++ b/rust/maintainer_clean_footprint
@@ -0,0 +1,11 @@
+#!/bin/sh
+# rust started doing these weird random hash files again.. so here we
+# go cleaning them out of the footprint again..
+
+rm -f footprint.in
+mv .footprint footprint.in
+
+hash_pattern="[0-9a-z]\{16\}"
+sed "/$hash_pattern/d" footprint.in > .footprint
+
+rm -f footprint.in