Julia requires SSE2 on i386
authorSébastien Villemot <sebastien@debian.org>
Tue, 31 Dec 2019 08:30:40 +0000 (08:30 +0000)
committerMo Zhou <lumin@debian.org>
Tue, 31 Dec 2019 08:30:40 +0000 (08:30 +0000)
Bug: https://github.com/JuliaLang/julia/issues/7185
Forwarded: no
Last-Update: 2015-11-01

This patch adds an explicit error message if the CPU does not support SSE2.
The CPU features are queried using the x86 CPUID opcode. The wrapper function
__get_cpuid() is provided by GCC and Clang. See <cpuid.h> for the list of
supported CPU extension flags.
Last-Update: 2015-11-01
Gbp-Pq: Name require-sse2-on-i386.patch

src/codegen.cpp

index 1d6e98dc8c94c65d0d7debf9926549279a2397f3..0c2989b710e5c6004fcb48ecfa3b8f06df3390f0 100644 (file)
@@ -18,6 +18,9 @@
 #endif
 
 #include <setjmp.h>
+#ifdef __i386__
+#include <cpuid.h>
+#endif
 #include <string>
 #include <sstream>
 #include <fstream>
@@ -7631,6 +7634,15 @@ static void init_julia_llvm_env(Module *m)
 
 extern "C" void *jl_init_llvm(void)
 {
+#ifdef __i386__
+    unsigned int eax = 0, ebx = 0, ecx = 0, edx = 0;
+    __get_cpuid(1, &eax, &ebx, &ecx, &edx);
+    if (!(edx & bit_SSE2)) {
+        fprintf(stderr, "Your processor does not have SSE2 extension, which is required by Julia. Exiting.\n");
+        exit(EXIT_FAILURE);
+    }
+#endif
+
     const char *const argv_tailmerge[] = {"", "-enable-tail-merge=0"}; // NOO TOUCHIE; NO TOUCH! See #922
     cl::ParseCommandLineOptions(sizeof(argv_tailmerge)/sizeof(argv_tailmerge[0]), argv_tailmerge, "disable-tail-merge\n");
 #if defined(_OS_WINDOWS_) && defined(_CPU_X86_64_)