Julia requires SSE2 on i386
authorSébastien Villemot <sebastien@debian.org>
Wed, 4 Nov 2020 07:56:54 +0000 (07:56 +0000)
committerNorbert Preining <norbert@preining.info>
Wed, 4 Nov 2020 07:56:54 +0000 (07:56 +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 3427fdfd352fc88f56423e66cd714a08d2ccaa1c..a097991c095ea4fed1b7261ccff4da00a537bda9 100644 (file)
@@ -21,6 +21,9 @@
 #endif
 
 #include <setjmp.h>
+#ifdef __i386__
+#include <cpuid.h>
+#endif
 #include <string>
 #include <sstream>
 #include <fstream>
@@ -7418,6 +7421,14 @@ extern "C" void jl_init_llvm(void)
 #ifdef USE_POLLY
     polly::initializePollyPasses(Registry);
 #endif
+#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
 
     // Parse command line flags after initialization
     const char *const argv_tailmerge[] = {"", "-enable-tail-merge=0"}; // NOO TOUCHIE; NO TOUCH! See #922