aboutsummaryrefslogtreecommitdiffstats
path: root/testing/ponyc/disable-avx512f-for-x86-only.patch
diff options
context:
space:
mode:
Diffstat (limited to 'testing/ponyc/disable-avx512f-for-x86-only.patch')
-rw-r--r--testing/ponyc/disable-avx512f-for-x86-only.patch122
1 files changed, 122 insertions, 0 deletions
diff --git a/testing/ponyc/disable-avx512f-for-x86-only.patch b/testing/ponyc/disable-avx512f-for-x86-only.patch
new file mode 100644
index 0000000000..e14ff87478
--- /dev/null
+++ b/testing/ponyc/disable-avx512f-for-x86-only.patch
@@ -0,0 +1,122 @@
+Patch-Source: https://github.com/ponylang/ponyc/pull/2665
+
+--- a/Makefile
++++ b/Makefile
+@@ -41,6 +41,7 @@
+ config ?= release
+ arch ?= native
+ tune ?= generic
++cpu ?= $(arch)
+ bits ?= $(shell getconf LONG_BIT)
+
+ ifndef verbose
+@@ -102,7 +103,7 @@
+ -DPONY_VERSION_STR=\"$(version_str)\" \
+ -D_FILE_OFFSET_BITS=64
+ ALL_CXXFLAGS = -std=gnu++11 -fno-rtti
+-LL_FLAGS = -mcpu=$(arch)
++LL_FLAGS = -mcpu=$(cpu)
+
+ # Determine pointer size in bits.
+ BITS := $(bits)
+--- a/src/libponyc/codegen/codegen.c
++++ b/src/libponyc/codegen/codegen.c
+@@ -976,48 +976,53 @@
+
+ bool codegen_pass_init(pass_opt_t* opt)
+ {
++ char *triple;
++
++ // Default triple, cpu and features.
++ if(opt->triple != NULL)
++ {
++ triple = LLVMCreateMessage(opt->triple);
++ } else {
++#ifdef PLATFORM_IS_MACOSX
++ // This is to prevent XCode 7+ from claiming OSX 14.5 is required.
++ triple = LLVMCreateMessage("x86_64-apple-macosx");
++#else
++ triple = LLVMGetDefaultTargetTriple();
++#endif
++ }
++
+ if(opt->features != NULL)
+ {
+ #if PONY_LLVM < 500
+- // Disable -avx512f on LLVM < 5.0.0 to avoid bug https://bugs.llvm.org/show_bug.cgi?id=30542
+- size_t temp_len = strlen(opt->features) + 9;
+- char* temp_str = (char*)ponyint_pool_alloc_size(temp_len);
+- snprintf(temp_str, temp_len, "%s,-avx512f", opt->features);
++ if(target_is_x86(triple))
++ {
++ // Disable -avx512f on LLVM < 5.0.0 to avoid bug https://bugs.llvm.org/show_bug.cgi?id=30542
++ size_t temp_len = strlen(opt->features) + 10;
++ char* temp_str = (char*)ponyint_pool_alloc_size(temp_len);
++ snprintf(temp_str, temp_len, "%s,-avx512f", opt->features);
+
+- opt->features = temp_str;
+-#endif
++ opt->features = LLVMCreateMessage(temp_str);
+
++ ponyint_pool_free_size(temp_len, temp_str);
++ } else {
++ opt->features = LLVMCreateMessage(opt->features);
++ }
++#else
+ opt->features = LLVMCreateMessage(opt->features);
+-
+-
+-#if PONY_LLVM < 500
+- // free memory for temp_str
+- ponyint_pool_free_size(temp_len, temp_str);
+ #endif
+ } else {
+ if((opt->cpu == NULL) && (opt->triple == NULL))
+ opt->features = LLVMGetHostCPUFeatures();
+ else
+ #if PONY_LLVM < 500
+- opt->features = LLVMCreateMessage("-avx512f");
++ opt->features = LLVMCreateMessage(target_is_x86(triple) ? "-avx512f" : "");
+ #else
+ opt->features = LLVMCreateMessage("");
+ #endif
+ }
+
+- // Default triple, cpu and features.
+- if(opt->triple != NULL)
+- {
+- opt->triple = LLVMCreateMessage(opt->triple);
+- } else {
+-#ifdef PLATFORM_IS_MACOSX
+- // This is to prevent XCode 7+ from claiming OSX 14.5 is required.
+- opt->triple = LLVMCreateMessage("x86_64-apple-macosx");
+-#else
+- opt->triple = LLVMGetDefaultTargetTriple();
+-#endif
+- }
+-
++ opt->triple = triple;
++
+ if(opt->cpu != NULL)
+ opt->cpu = LLVMCreateMessage(opt->cpu);
+ else
+--- a/src/libponyc/codegen/host.cc
++++ b/src/libponyc/codegen/host.cc
+@@ -46,7 +46,7 @@
+ for(auto it = features.begin(); it != features.end(); it++)
+ buf_size += (*it).getKey().str().length() + 2; // plus +/- char and ,/null
+
+-#if PONY_LLVM < 500
++#if PONY_LLVM < 500 and defined(PLATFORM_IS_X86)
+ // Add extra buffer space for llvm bug workaround
+ buf_size += 9;
+ #endif
+@@ -69,7 +69,7 @@
+ strcat(buf, ",");
+ }
+
+-#if PONY_LLVM < 500
++#if PONY_LLVM < 500 and defined(PLATFORM_IS_X86)
+ // Disable -avx512f on LLVM < 5.0.0 to avoid bug https://bugs.llvm.org/show_bug.cgi?id=30542
+ strcat(buf, ",-avx512f");
+ #endif