void-packages/srcpkgs/blender/patches/musl.patch

112 lines
3.8 KiB
Diff

From 8f2b2e92ffdec658d4eb999f41acf6c74a5b32ed Mon Sep 17 00:00:00 2001
From: Leon Marz <lmarz@cs.uni-frankfurt.de>
Date: Tue, 1 Sep 2020 09:09:50 +0200
Subject: [PATCH 1/2] musl fixes
[ Taken from https://git.alpinelinux.org/aports/plain/testing/blender/0001-musl-fixes.patch ]
Original Patch by Nathanael Copa
---
CMakeLists.txt | 13 +++++++++++++
intern/guardedalloc/intern/mallocn_intern.h | 2 +-
intern/libc_compat/libc_compat.c | 2 --
source/blender/blenlib/intern/system.c | 4 +++-
source/creator/creator_signals.c | 2 +-
5 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cee8675..111e6e3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -138,6 +138,19 @@ get_blender_version()
#-----------------------------------------------------------------------------
# Options
+# musl-libc related checks (missing execinfo.h and feenableexcept())
+include(CheckIncludeFiles)
+check_include_files(execinfo.h HAVE_EXECINFO_H)
+if(HAVE_EXECINFO_H)
+ add_definitions(-DHAVE_EXECINFO_H)
+endif()
+
+include(CheckLibraryExists)
+check_library_exists(m feenableexcept "fenv.h" HAVE_FEENABLEEXCEPT)
+if(HAVE_FEENABLEEXCEPT)
+ add_definitions(-DHAVE_FEENABLEEXCEPT)
+endif()
+
# Blender internal features
option(WITH_BLENDER "Build blender (disable to build only the blender player)" ON)
mark_as_advanced(WITH_BLENDER)
diff --git a/intern/guardedalloc/intern/mallocn_intern.h b/intern/guardedalloc/intern/mallocn_intern.h
index 8fc3e43..ee443c4 100644
--- a/intern/guardedalloc/intern/mallocn_intern.h
+++ b/intern/guardedalloc/intern/mallocn_intern.h
@@ -33,7 +33,7 @@
#undef HAVE_MALLOC_STATS
#define USE_MALLOC_USABLE_SIZE /* internal, when we have malloc_usable_size() */
-#if defined(__linux__) || (defined(__FreeBSD_kernel__) && !defined(__FreeBSD__)) || \
+#if defined(__linux__) && defined(HAVE_EXECINFO_H) || (defined(__FreeBSD_kernel__) && !defined(__FreeBSD__)) || \
defined(__GLIBC__)
# include <malloc.h>
# define HAVE_MALLOC_STATS
diff --git a/intern/libc_compat/libc_compat.c b/intern/libc_compat/libc_compat.c
index 78e387e..d21c281 100644
--- a/intern/libc_compat/libc_compat.c
+++ b/intern/libc_compat/libc_compat.c
@@ -25,7 +25,6 @@
# include <features.h>
# include <math.h>
-# if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 31)
double __exp_finite(double x);
double __exp2_finite(double x);
@@ -124,5 +123,4 @@ float __powf_finite(float x, float y)
return powf(x, y);
}
-# endif /* __GLIBC_PREREQ */
#endif /* __linux__ */
diff --git a/source/blender/blenlib/intern/system.c b/source/blender/blenlib/intern/system.c
index 20edbb9..6e856cd 100644
--- a/source/blender/blenlib/intern/system.c
+++ b/source/blender/blenlib/intern/system.c
@@ -35,7 +35,9 @@
# include "BLI_winstuff.h"
#else
+#if defined(HAVE_EXECINFO_H)
# include <execinfo.h>
+#endif
# include <unistd.h>
#endif
@@ -80,7 +82,7 @@ void BLI_system_backtrace(FILE *fp)
{
/* ------------- */
/* Linux / Apple */
-# if defined(__linux__) || defined(__APPLE__)
+# if defined(__linux__) && defined(HAVE_EXECINFO_H) || defined(__APPLE__)
# define SIZE 100
void *buffer[SIZE];
diff --git a/source/creator/creator_signals.c b/source/creator/creator_signals.c
index ad0b7b2..01d5e37 100644
--- a/source/creator/creator_signals.c
+++ b/source/creator/creator_signals.c
@@ -269,7 +269,7 @@ void main_signal_setup_fpe(void)
* set breakpoints on sig_handle_fpe */
signal(SIGFPE, sig_handle_fpe);
-# if defined(__linux__) && defined(__GNUC__)
+# if defined(__linux__) && defined(__GNUC__) && defined(HAVE_FEENABLEEXCEPT)
feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
# endif /* defined(__linux__) && defined(__GNUC__) */
# if defined(OSX_SSE_FPE)
--
2.28.0