aboutsummaryrefslogtreecommitdiffstats
path: root/testing/blender/musl-fixes.patch
blob: 89ecee708755a59a984ecfe2657d6c1b2248a0ad (plain)
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0c2e4f8..5b7b747 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -185,6 +185,18 @@ if(UNIX AND NOT APPLE)
   set(_init_OPENSUBDIV                     OFF)
   set(_init_OPENVDB                        OFF)
   set(_init_OPENIMAGEDENOISE               OFF)
+  # 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()
 elseif(WIN32)
   set(_init_JACK                           OFF)
 elseif(APPLE)
diff --git a/intern/guardedalloc/intern/mallocn_intern.h b/intern/guardedalloc/intern/mallocn_intern.h
index e6e0907..6868a88 100644
--- a/intern/guardedalloc/intern/mallocn_intern.h
+++ b/intern/guardedalloc/intern/mallocn_intern.h
@@ -40,7 +40,8 @@
 #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/source/blender/blenlib/intern/system.c b/source/blender/blenlib/intern/system.c
index 941c2b6..2b710a4 100644
--- a/source/blender/blenlib/intern/system.c
+++ b/source/blender/blenlib/intern/system.c
@@ -38,7 +38,9 @@
 #  include <dbghelp.h>
 #  pragma warning(pop)
 #else
-#  include <execinfo.h>
+#  if defined(HAVE_EXECINFO_H)
+#    include <execinfo.h>
+#  endif
 #  include <unistd.h>
 #endif
 
diff --git a/source/creator/creator_signals.c b/source/creator/creator_signals.c
index e8c6e92..5b54ea9 100644
--- a/source/creator/creator_signals.c
+++ b/source/creator/creator_signals.c
@@ -329,7 +329,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)
diff --git a/source/blender/blenlib/intern/system.c b/source/blender/blenlib/intern/system.c
index 2b710a4..0e2948c 100644
--- a/source/blender/blenlib/intern/system.c
+++ b/source/blender/blenlib/intern/system.c
@@ -83,7 +83,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];