git: b039f2e46b15 - main - lang/rust: enable SSE2 by default on i386

From: Alan Somers <asomers_at_FreeBSD.org>
Date: Sat, 09 Nov 2024 22:47:09 UTC
The branch main has been updated by asomers:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b039f2e46b15c1ff5cbaf41e642993d982294da3

commit b039f2e46b15c1ff5cbaf41e642993d982294da3
Author:     Alan Somers <asomers@FreeBSD.org>
AuthorDate: 2024-10-21 19:25:23 +0000
Commit:     Alan Somers <asomers@FreeBSD.org>
CommitDate: 2024-11-09 22:45:49 +0000

    lang/rust: enable SSE2 by default on i386
    
    Upstream Rust always requires SSE2 for x86.  But back in 2017[^1][^2] we
    patched lang/rust to disable SSE2 for i386.  At the time, it was
    reported that some people were still using non-SSE2 capable hardware.
    More recently, LLVM bugs have been discovered[^3][^4] that can result in
    rounding bugs and reduced accuracy when using f64 on non-SSE hardware.
    In weird cases, they can even cause wilder unpredictable behavior, like
    segfaults.
    
    Revert our change for the sake of Pentium 4 (and later) users.  But add
    an SSE2 option.  Disabling it will allow the port to be used on Pentium
    3 and older CPUs.
    
    [^1]: https://github.com/freebsd/freebsd-ports/commit/d65b2886b1b3b2135f0b8982de4d9754517acf61
    [^2]: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=223415
    [^3]: https://github.com/rust-lang/rust/issues/114479
    [^4]: https://github.com/llvm/llvm-project/issues/44218
    
    Reviewed by: emaste
    Differential Revision: https://reviews.freebsd.org/D47227
---
 UPDATING                                                     | 12 ++++++++++++
 lang/rust/Makefile                                           |  7 ++++++-
 ...rustc__target_src_spec_targets_i686__unknown__freebsd.rs} |  0
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/UPDATING b/UPDATING
index 1a674317b048..5a5daad9ddeb 100644
--- a/UPDATING
+++ b/UPDATING
@@ -5,6 +5,18 @@ they are unavoidable.
 You should get into the habit of checking this file for changes each time
 you update your ports collection, before attempting any port upgrades.
 
+20241109:
+  AFFECTS: all users of i386
+  AUTHOR: asomers@FreeBSD.org
+
+  On i386 the lang/rust port has been updated to require SSE2 by default.  Not
+  only does the compiler itself require SSE2, but it unconditionally generates
+  code that requires it, too.  Over 500 ports include Rust code (www/firefox,
+  security/py-cryptography, etc).  Official binary packages of all of those
+  ports will no longer work on Pentium III and older hardware.  PIII users must
+  now build their own lang/rust packages, clearing the SSE2 option, and rebuild
+  any dependent ports.
+
 20241104:
   AFFECTS: users of mail/fetchmail
   AUTHOR: chalpin@cs.wisc.edu
diff --git a/lang/rust/Makefile b/lang/rust/Makefile
index 8c2b971e132a..9406b62a91ad 100644
--- a/lang/rust/Makefile
+++ b/lang/rust/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	rust
 PORTVERSION?=	1.82.0
-PORTREVISION?=	0
+PORTREVISION?=	1
 CATEGORIES=	lang
 MASTER_SITES=	https://static.rust-lang.org/dist/:src \
 		https://dev-static.rust-lang.org/dist/:src \
@@ -48,12 +48,17 @@ TMPDIR?=	${WRKDIR}
 
 OPTIONS_DEFINE=		DOCS GDB LTO PORT_LLVM SOURCES WASM
 OPTIONS_DEFAULT=	SOURCES WASM
+OPTIONS_DEFINE_i386=	SSE2
+OPTIONS_DEFAULT_i386=	SSE2
 
 GDB_DESC=	Install ports gdb (necessary for debugging rust programs)
 PORT_LLVM_DESC=	Build against devel/llvm instead of bundled copy (experimental)
+SSE2_DESC=	Enable SSE2 instructions
 SOURCES_DESC=	Install source files
 WASM_DESC=	Build the WebAssembly target (wasm32-unknown-unknown)
 
+SSE2_EXTRA_PATCHES_OFF+=	${FILESDIR}/extra-patch-compiler_rustc__target_src_spec_targets_i686__unknown__freebsd.rs
+
 DOCS_VARS=		_RUST_BUILD_DOCS=true \
 			_COMPONENTS+="rust-docs-${_PACKAGE_VERS}-${_RUST_TARGET} rust-docs-json-${_PACKAGE_VERS}-${_RUST_TARGET}" \
 			_RUST_TOOLS+=rustdoc
diff --git a/lang/rust/files/patch-compiler_rustc__target_src_spec_targets_i686__unknown__freebsd.rs b/lang/rust/files/extra-patch-compiler_rustc__target_src_spec_targets_i686__unknown__freebsd.rs
similarity index 100%
rename from lang/rust/files/patch-compiler_rustc__target_src_spec_targets_i686__unknown__freebsd.rs
rename to lang/rust/files/extra-patch-compiler_rustc__target_src_spec_targets_i686__unknown__freebsd.rs