File: 2001_fail_non-sse2-x86.patch

package info (click to toggle)
rust-wide 0.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 1,280 kB
  • sloc: makefile: 2; sh: 1
file content (29 lines) | stat: -rw-r--r-- 1,130 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Description: refuse to build optimized on non-sse2 x86
 Leads to unsound code due to a bug in LLVM.
Author: Jonas Smedegaard <dr@jones.dk>
Author: noisycoil@tutanota.com
Bug: https://github.com/Lokathor/wide/issues/174
Bug-Debian: https://bugs.debian.org/1078905
Bug-Rust: https://github.com/rust-lang/rust/issues/114479
Bug-LLVM: https://github.com/llvm/llvm-project/issues/44218
Last-Update: 2024-08-27
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- /dev/null
+++ b/build.rs
@@ -0,0 +1,15 @@
+use std::env::var;
+
+fn main() {
+    let target_arch = var("CARGO_CFG_TARGET_ARCH").unwrap();
+    let target_have_sse2 = var("CARGO_CFG_TARGET_FEATURE")
+        .map_or(false, |features| {
+            features.split(",").any(|feature| feature == "sse2")
+        });
+    let opt_level = var("OPT_LEVEL").unwrap_or_else(|_| "0".to_string());
+
+    if &target_arch == "x86" && !target_have_sse2 && opt_level != "0" {
+        println!("cargo:warning=Compiling optimized code on Debian non-SSE2 i686 architecture leads to unsound code. Build will be aborted.");
+        std::process::exit(1);
+    }
+}