Github messages for voidlinux
 help / color / mirror / Atom feed
From: sgn <sgn@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: [PR PATCH] blender: backport more Python's opcodes whitelist (better to update to 3.3, but this is not)
Date: Wed, 21 Sep 2022 19:00:53 +0200	[thread overview]
Message-ID: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-39402@inbox.vuxu.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1341 bytes --]

There is a new pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages blender-more-opcodes
https://github.com/void-linux/void-packages/pull/39402

blender: backport more Python's opcodes whitelist (better to update to 3.3, but this is not)
Also prepare for Python 3.11

<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: *\*NO**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/39402.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-blender-more-opcodes-39402.patch --]
[-- Type: text/x-diff, Size: 26689 bytes --]

From af4ebf419e3b07278429e2abd8bfe1a7e44ded86 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Wed, 21 Sep 2022 23:54:55 +0700
Subject: [PATCH] blender: backport more Python's opcodes whitelist

Also prepare for Python 3.11
---
 srcpkgs/blender/patches/0001-musl-fixes.patch |  47 ++--
 .../blender/patches/0001-python-3.11.patch    |  95 ++++++++
 .../patches/0002-fix-linking-issue.patch      |  13 +-
 .../blender/patches/0002-python-3.11.patch    |  66 ++++++
 .../blender/patches/0003-python-3.11.patch    | 203 ++++++++++++++++++
 .../blender/patches/0004-python-3.11.patch    |  58 +++++
 srcpkgs/blender/patches/altivec-all.patch     |   6 +-
 .../patches/no-Werror-double-promotion.patch  |   6 +-
 srcpkgs/blender/template                      |   4 +-
 9 files changed, 458 insertions(+), 40 deletions(-)
 create mode 100644 srcpkgs/blender/patches/0001-python-3.11.patch
 create mode 100644 srcpkgs/blender/patches/0002-python-3.11.patch
 create mode 100644 srcpkgs/blender/patches/0003-python-3.11.patch
 create mode 100644 srcpkgs/blender/patches/0004-python-3.11.patch

diff --git a/srcpkgs/blender/patches/0001-musl-fixes.patch b/srcpkgs/blender/patches/0001-musl-fixes.patch
index 0e64369b4379..0c5112eaae40 100644
--- a/srcpkgs/blender/patches/0001-musl-fixes.patch
+++ b/srcpkgs/blender/patches/0001-musl-fixes.patch
@@ -15,10 +15,10 @@ Original patch by Nathanael Copa
  source/creator/creator_signals.c            | 2 +-
  5 files changed, 5 insertions(+), 6 deletions(-)
 
-diff --git a/intern/guardedalloc/intern/mallocn_intern.h b/intern/guardedalloc/intern/mallocn_intern.h
-index aa95615..f7e347d 100644
---- a/intern/guardedalloc/intern/mallocn_intern.h
-+++ b/intern/guardedalloc/intern/mallocn_intern.h
+Index: blender-3.0.0/intern/guardedalloc/intern/mallocn_intern.h
+===================================================================
+--- blender-3.0.0.orig/intern/guardedalloc/intern/mallocn_intern.h
++++ blender-3.0.0/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() */
@@ -28,10 +28,10 @@ index aa95615..f7e347d 100644
      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
+Index: blender-3.0.0/intern/libc_compat/libc_compat.c
+===================================================================
+--- blender-3.0.0.orig/intern/libc_compat/libc_compat.c
++++ blender-3.0.0/intern/libc_compat/libc_compat.c
 @@ -25,7 +25,6 @@
  #  include <features.h>
  #  include <math.h>
@@ -46,10 +46,10 @@ index 78e387e..d21c281 100644
  
 -#  endif /* __GLIBC_PREREQ */
  #endif   /* __linux__ */
-diff --git a/source/blender/blenlib/intern/system.c b/source/blender/blenlib/intern/system.c
-index 8e3d489..4d0789b 100644
---- a/source/blender/blenlib/intern/system.c
-+++ b/source/blender/blenlib/intern/system.c
+Index: blender-3.0.0/source/blender/blenlib/intern/system.c
+===================================================================
+--- blender-3.0.0.orig/source/blender/blenlib/intern/system.c
++++ blender-3.0.0/source/blender/blenlib/intern/system.c
 @@ -35,7 +35,9 @@
  
  #  include "BLI_winstuff.h"
@@ -69,11 +69,11 @@ index 8e3d489..4d0789b 100644
  
  #    define SIZE 100
    void *buffer[SIZE];
-diff --git a/source/blender/gpu/GPU_vertex_buffer.h b/source/blender/gpu/GPU_vertex_buffer.h
-index eeaebd3..93a77a2 100644
---- a/source/blender/gpu/GPU_vertex_buffer.h
-+++ b/source/blender/gpu/GPU_vertex_buffer.h
-@@ -118,7 +118,6 @@ GPU_INLINE void *GPU_vertbuf_raw_step(GPUVertBufRaw *a)
+Index: blender-3.0.0/source/blender/gpu/GPU_vertex_buffer.h
+===================================================================
+--- blender-3.0.0.orig/source/blender/gpu/GPU_vertex_buffer.h
++++ blender-3.0.0/source/blender/gpu/GPU_vertex_buffer.h
+@@ -127,7 +127,6 @@ GPU_INLINE void *GPU_vertbuf_raw_step(GP
  {
    unsigned char *data = a->data;
    a->data += a->stride;
@@ -81,11 +81,11 @@ index eeaebd3..93a77a2 100644
    return (void *)data;
  }
  
-diff --git a/source/creator/creator_signals.c b/source/creator/creator_signals.c
-index 29e12a9..d90da8f 100644
---- a/source/creator/creator_signals.c
-+++ b/source/creator/creator_signals.c
-@@ -269,7 +269,7 @@ void main_signal_setup_fpe(void)
+Index: blender-3.0.0/source/creator/creator_signals.c
+===================================================================
+--- blender-3.0.0.orig/source/creator/creator_signals.c
++++ blender-3.0.0/source/creator/creator_signals.c
+@@ -271,7 +271,7 @@ void main_signal_setup_fpe(void)
     * set breakpoints on sig_handle_fpe */
    signal(SIGFPE, sig_handle_fpe);
  
@@ -94,6 +94,3 @@ index 29e12a9..d90da8f 100644
    feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
  #    endif /* defined(__linux__) && defined(__GNUC__) */
  #    if defined(OSX_SSE_FPE)
--- 
-2.30.1
-
diff --git a/srcpkgs/blender/patches/0001-python-3.11.patch b/srcpkgs/blender/patches/0001-python-3.11.patch
new file mode 100644
index 000000000000..4033c6617ba9
--- /dev/null
+++ b/srcpkgs/blender/patches/0001-python-3.11.patch
@@ -0,0 +1,95 @@
+From 7537369498bf61f872554b0ce2efc439008165a4 Mon Sep 17 00:00:00 2001
+From: Campbell Barton <campbell@blender.org>
+Date: Tue, 5 Jul 2022 13:41:49 +1000
+Subject: [PATCH] Python: remove invalid Py_TPFLAGS_HAVE_GC usage
+
+Blender wouldn't start with Python 3.11 because of an error in
+Py_TPFLAGS_HAVE_GC usage for `bpy.app.handlers.persistent`.
+Remove this flag as it's not necessary.
+
+Part of fix for T99277.
+---
+ .../blender/python/intern/bpy_app_handlers.c  | 70 +++++++++----------
+ 1 file changed, 35 insertions(+), 35 deletions(-)
+
+Index: blender-3.0.0/source/blender/python/intern/bpy_app_handlers.c
+===================================================================
+--- blender-3.0.0.orig/source/blender/python/intern/bpy_app_handlers.c
++++ blender-3.0.0/source/blender/python/intern/bpy_app_handlers.c
+@@ -151,41 +151,41 @@ static PyTypeObject BPyPersistent_Type =
+     0,                /* tp_basicsize */
+     0,                /* tp_itemsize */
+     /* methods */
+-    0,                                                             /* tp_dealloc */
+-    0,                                                             /* tp_print */
+-    0,                                                             /* tp_getattr */
+-    0,                                                             /* tp_setattr */
+-    0,                                                             /* tp_reserved */
+-    0,                                                             /* tp_repr */
+-    0,                                                             /* tp_as_number */
+-    0,                                                             /* tp_as_sequence */
+-    0,                                                             /* tp_as_mapping */
+-    0,                                                             /* tp_hash */
+-    0,                                                             /* tp_call */
+-    0,                                                             /* tp_str */
+-    0,                                                             /* tp_getattro */
+-    0,                                                             /* tp_setattro */
+-    0,                                                             /* tp_as_buffer */
+-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE, /* tp_flags */
+-    0,                                                             /* tp_doc */
+-    0,                                                             /* tp_traverse */
+-    0,                                                             /* tp_clear */
+-    0,                                                             /* tp_richcompare */
+-    0,                                                             /* tp_weaklistoffset */
+-    0,                                                             /* tp_iter */
+-    0,                                                             /* tp_iternext */
+-    0,                                                             /* tp_methods */
+-    0,                                                             /* tp_members */
+-    0,                                                             /* tp_getset */
+-    0,                                                             /* tp_base */
+-    0,                                                             /* tp_dict */
+-    0,                                                             /* tp_descr_get */
+-    0,                                                             /* tp_descr_set */
+-    0,                                                             /* tp_dictoffset */
+-    0,                                                             /* tp_init */
+-    0,                                                             /* tp_alloc */
+-    bpy_app_handlers_persistent_new,                               /* tp_new */
+-    0,                                                             /* tp_free */
++    0,                                        /* tp_dealloc */
++    0,                                        /* tp_print */
++    0,                                        /* tp_getattr */
++    0,                                        /* tp_setattr */
++    0,                                        /* tp_reserved */
++    0,                                        /* tp_repr */
++    0,                                        /* tp_as_number */
++    0,                                        /* tp_as_sequence */
++    0,                                        /* tp_as_mapping */
++    0,                                        /* tp_hash */
++    0,                                        /* tp_call */
++    0,                                        /* tp_str */
++    0,                                        /* tp_getattro */
++    0,                                        /* tp_setattro */
++    0,                                        /* tp_as_buffer */
++    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
++    0,                                        /* tp_doc */
++    0,                                        /* tp_traverse */
++    0,                                        /* tp_clear */
++    0,                                        /* tp_richcompare */
++    0,                                        /* tp_weaklistoffset */
++    0,                                        /* tp_iter */
++    0,                                        /* tp_iternext */
++    0,                                        /* tp_methods */
++    0,                                        /* tp_members */
++    0,                                        /* tp_getset */
++    0,                                        /* tp_base */
++    0,                                        /* tp_dict */
++    0,                                        /* tp_descr_get */
++    0,                                        /* tp_descr_set */
++    0,                                        /* tp_dictoffset */
++    0,                                        /* tp_init */
++    0,                                        /* tp_alloc */
++    bpy_app_handlers_persistent_new,          /* tp_new */
++    0,                                        /* tp_free */
+ };
+ 
+ static PyObject *py_cb_array[BKE_CB_EVT_TOT] = {NULL};
diff --git a/srcpkgs/blender/patches/0002-fix-linking-issue.patch b/srcpkgs/blender/patches/0002-fix-linking-issue.patch
index 28683714e126..ce6848b90080 100644
--- a/srcpkgs/blender/patches/0002-fix-linking-issue.patch
+++ b/srcpkgs/blender/patches/0002-fix-linking-issue.patch
@@ -9,17 +9,14 @@ Subject: [PATCH 2/3] fix linking issue
  intern/ghost/CMakeLists.txt | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
-diff --git a/intern/ghost/CMakeLists.txt b/intern/ghost/CMakeLists.txt
-index 1739659..d6b442b 100644
---- a/intern/ghost/CMakeLists.txt
-+++ b/intern/ghost/CMakeLists.txt
-@@ -484,5 +484,5 @@ if(WITH_XR_OPENXR)
+Index: blender-3.0.0/intern/ghost/CMakeLists.txt
+===================================================================
+--- blender-3.0.0.orig/intern/ghost/CMakeLists.txt
++++ blender-3.0.0/intern/ghost/CMakeLists.txt
+@@ -536,5 +536,5 @@ if(WITH_XR_OPENXR)
  endif()
  
  add_definitions(${GL_DEFINITIONS})
 -
 +list(APPEND LIB "-lX11" "-lXi" "-lXxf86vm" "-lXfixes" "-lXrender")
  blender_add_lib(bf_intern_ghost "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
--- 
-2.30.1
-
diff --git a/srcpkgs/blender/patches/0002-python-3.11.patch b/srcpkgs/blender/patches/0002-python-3.11.patch
new file mode 100644
index 000000000000..6ebd6d2dcaf3
--- /dev/null
+++ b/srcpkgs/blender/patches/0002-python-3.11.patch
@@ -0,0 +1,66 @@
+From dfa52017638abdf59791e5588c439d3a558a191d Mon Sep 17 00:00:00 2001
+From: Campbell Barton <campbell@blender.org>
+Date: Tue, 5 Jul 2022 13:41:53 +1000
+Subject: [PATCH] Python: add opcodes for safe py-drivers
+
+New opcodes added since 3.7 meant some actions such as `len()`
+were disabled in safe py-driver execution.
+
+The following opcodes have been added, see [0] for details:
+
+- ROT_FOUR: similar to existing ROT_* opcodes, added v3.8.
+
+- ROT_N: similar to existing ROT_* opcodes, added v3.10.
+
+- GET_LEN: Push len(TOS) onto the stack, added v3.10.
+
+- IS_OP: for ternary operator, added v3.9.
+
+- BUILD_SLICE: access `slice` built-in, doesn't expose new
+  functionality beyond existing `__getitem__` access.
+
+[0]: https://docs.python.org/3.10/library/dis.html
+---
+ source/blender/python/intern/bpy_driver.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+Index: blender-3.0.0/source/blender/python/intern/bpy_driver.c
+===================================================================
+--- blender-3.0.0.orig/source/blender/python/intern/bpy_driver.c
++++ blender-3.0.0/source/blender/python/intern/bpy_driver.c
+@@ -281,6 +281,7 @@ static const char secure_opcodes[255] =
+     OK_OP(ROT_THREE),
+     OK_OP(DUP_TOP),
+     OK_OP(DUP_TOP_TWO),
++    OK_OP(ROT_FOUR),
+     OK_OP(NOP),
+     OK_OP(UNARY_POSITIVE),
+     OK_OP(UNARY_NEGATIVE),
+@@ -298,6 +299,7 @@ static const char secure_opcodes[255] =
+     OK_OP(BINARY_TRUE_DIVIDE),
+     OK_OP(INPLACE_FLOOR_DIVIDE),
+     OK_OP(INPLACE_TRUE_DIVIDE),
++    OK_OP(GET_LEN),
+     OK_OP(INPLACE_ADD),
+     OK_OP(INPLACE_SUBTRACT),
+     OK_OP(INPLACE_MULTIPLY),
+@@ -314,6 +316,7 @@ static const char secure_opcodes[255] =
+     OK_OP(INPLACE_XOR),
+     OK_OP(INPLACE_OR),
+     OK_OP(RETURN_VALUE),
++    OK_OP(ROT_N),
+     OK_OP(BUILD_TUPLE),
+     OK_OP(BUILD_LIST),
+     OK_OP(BUILD_SET),
+@@ -326,9 +329,11 @@ static const char secure_opcodes[255] =
+     OK_OP(POP_JUMP_IF_FALSE),
+     OK_OP(POP_JUMP_IF_TRUE),
+     OK_OP(LOAD_GLOBAL),
++    OK_OP(IS_OP),
+     OK_OP(LOAD_FAST),
+     OK_OP(STORE_FAST),
+     OK_OP(DELETE_FAST),
++    OK_OP(BUILD_SLICE),
+     OK_OP(LOAD_DEREF),
+     OK_OP(STORE_DEREF),
+ 
diff --git a/srcpkgs/blender/patches/0003-python-3.11.patch b/srcpkgs/blender/patches/0003-python-3.11.patch
new file mode 100644
index 000000000000..b3b118972009
--- /dev/null
+++ b/srcpkgs/blender/patches/0003-python-3.11.patch
@@ -0,0 +1,203 @@
+From 780c0ea097444c3be60314dffd203c099720badb Mon Sep 17 00:00:00 2001
+From: Campbell Barton <campbell@blender.org>
+Date: Tue, 5 Jul 2022 13:41:55 +1000
+Subject: [PATCH] Python: support v3.11 (beta) with changes to PyFrameObject &
+ opcodes
+
+- Use API calls to access frame-data as PyFrameObject is now opaque.
+- Update opcodes allowed for safe driver evaluation.
+
+**Details**
+
+Some opcodes have been added for safe-driver evaluation.
+Python 3.11 removes many opcodes - the number of accepted opcodes in
+Blender's listing dropped from 65 to 43) however some new opcodes
+also needed to be added. As this relates to security details about newly
+added opcodes have been noted below (see [0] for full documentation).
+
+Newly added opcodes:
+
+- CACHE:
+  Used to control caching instructions.
+
+- RESUME:
+  A no-op. Performs internal checks.
+
+- BINARY_OP:
+  Implements the binary and in-place operators,
+  replacing specific binary operations.
+
+- CALL, PRECALL, KW_NAMES:
+  Used for calling functions, replacing some existing opcodes.
+
+- POP_JUMP_{FORWARD/BACKWARD}_IF_{TRUE/FALSE/NONE/NOT_NONE}.
+  Manipulate the byte-code counter.
+
+- SWAP, PUSH_NULL.
+  Stack manipulation.
+
+Resolves T99277.
+
+[0]: https://docs.python.org/3.11/library/dis.html
+---
+ source/blender/python/generic/py_capi_utils.c |  8 ++-
+ source/blender/python/intern/bpy_driver.c     | 62 ++++++++++++++++++-
+ source/blender/python/intern/bpy_interface.c  | 19 +++---
+ source/blender/python/intern/bpy_traceback.c  |  3 +-
+ 4 files changed, 79 insertions(+), 13 deletions(-)
+
+--- a/source/blender/python/generic/py_capi_utils.c
++++ b/source/blender/python/generic/py_capi_utils.c
+@@ -671,6 +671,7 @@ void PyC_StackSpit(void)
+ void PyC_FileAndNum(const char **r_filename, int *r_lineno)
+ {
+   PyFrameObject *frame;
++  PyCodeObject *code;
+ 
+   if (r_filename) {
+     *r_filename = NULL;
+@@ -679,13 +680,16 @@ void PyC_FileAndNum(const char **r_filen
+     *r_lineno = -1;
+   }
+ 
+-  if (!(frame = PyThreadState_GET()->frame)) {
++  if (!(frame = PyEval_GetFrame())) {
++    return;
++  }
++  if (!(code = PyFrame_GetCode(frame))) {
+     return;
+   }
+ 
+   /* when executing a script */
+   if (r_filename) {
+-    *r_filename = PyUnicode_AsUTF8(frame->f_code->co_filename);
++    *r_filename = PyUnicode_AsUTF8(code->co_filename);
+   }
+ 
+   /* when executing a module */
+--- a/source/blender/python/intern/bpy_driver.c
++++ b/source/blender/python/intern/bpy_driver.c
+@@ -276,6 +276,56 @@ static void pydriver_error(ChannelDriver
+ #  define OK_OP(op) [op] = 1
+ 
+ static const char secure_opcodes[255] = {
++#  if PY_VERSION_HEX >= 0x030b0000 /* Python 3.11 & newer. */
++
++    OK_OP(CACHE),
++    OK_OP(POP_TOP),
++    OK_OP(PUSH_NULL),
++    OK_OP(NOP),
++    OK_OP(UNARY_POSITIVE),
++    OK_OP(UNARY_NEGATIVE),
++    OK_OP(UNARY_NOT),
++    OK_OP(UNARY_INVERT),
++    OK_OP(BINARY_SUBSCR),
++    OK_OP(GET_LEN),
++    OK_OP(RETURN_VALUE),
++    OK_OP(SWAP),
++    OK_OP(BUILD_TUPLE),
++    OK_OP(BUILD_LIST),
++    OK_OP(BUILD_SET),
++    OK_OP(BUILD_MAP),
++    OK_OP(COMPARE_OP),
++    OK_OP(JUMP_FORWARD),
++    OK_OP(JUMP_IF_FALSE_OR_POP),
++    OK_OP(JUMP_IF_TRUE_OR_POP),
++    OK_OP(POP_JUMP_FORWARD_IF_FALSE),
++    OK_OP(POP_JUMP_FORWARD_IF_TRUE),
++    OK_OP(LOAD_GLOBAL),
++    OK_OP(IS_OP),
++    OK_OP(BINARY_OP),
++    OK_OP(LOAD_FAST),
++    OK_OP(STORE_FAST),
++    OK_OP(DELETE_FAST),
++    OK_OP(POP_JUMP_FORWARD_IF_NOT_NONE),
++    OK_OP(POP_JUMP_FORWARD_IF_NONE),
++    OK_OP(BUILD_SLICE),
++    OK_OP(LOAD_DEREF),
++    OK_OP(STORE_DEREF),
++    OK_OP(RESUME),
++    OK_OP(POP_JUMP_BACKWARD_IF_NOT_NONE),
++    OK_OP(POP_JUMP_BACKWARD_IF_NONE),
++    OK_OP(POP_JUMP_BACKWARD_IF_FALSE),
++    OK_OP(POP_JUMP_BACKWARD_IF_TRUE),
++
++    /* Special cases. */
++    OK_OP(LOAD_CONST), /* Ok because constants are accepted. */
++    OK_OP(LOAD_NAME),  /* Ok, because `PyCodeObject.names` is checked. */
++    OK_OP(CALL),       /* Ok, because we check its "name" before calling. */
++    OK_OP(KW_NAMES),   /* Ok, because it's used for calling functions with keyword arguments. */
++    OK_OP(PRECALL),    /* Ok, because it's used for calling. */
++
++#  else /* Python 3.10 and older. */
++
+     OK_OP(POP_TOP),
+     OK_OP(ROT_TWO),
+     OK_OP(ROT_THREE),
+@@ -343,6 +393,8 @@ static const char secure_opcodes[255] =
+     OK_OP(CALL_FUNCTION), /* ok, because we check its 'name' before calling */
+     OK_OP(CALL_FUNCTION_KW),
+     OK_OP(CALL_FUNCTION_EX),
++
++#  endif /* Python 3.10 and older. */
+ };
+ 
+ #  undef OK_OP
+@@ -379,7 +431,15 @@ static bool bpy_driver_secure_bytecode_v
+     const _Py_CODEUNIT *codestr;
+     Py_ssize_t code_len;
+ 
+-    PyBytes_AsStringAndSize(py_code->co_code, (char **)&codestr, &code_len);
++    PyObject *co_code;
++
++#  if PY_VERSION_HEX >= 0x030b0000 /* Python 3.11 & newer. */
++    co_code = py_code->_co_code;
++#  else
++    co_code = py_code->co_code;
++#  endif
++
++    PyBytes_AsStringAndSize(co_code, (char **)&codestr, &code_len);
+     code_len /= sizeof(*codestr);
+ 
+     for (Py_ssize_t i = 0; i < code_len; i++) {
+--- a/source/blender/python/intern/bpy_interface.c
++++ b/source/blender/python/intern/bpy_interface.c
+@@ -605,16 +605,17 @@ void BPY_python_use_system_env(void)
+ void BPY_python_backtrace(FILE *fp)
+ {
+   fputs("\n# Python backtrace\n", fp);
+-  PyThreadState *tstate = PyGILState_GetThisThreadState();
+-  if (tstate != NULL && tstate->frame != NULL) {
+-    PyFrameObject *frame = tstate->frame;
+-    do {
+-      const int line = PyCode_Addr2Line(frame->f_code, frame->f_lasti);
+-      const char *filename = PyUnicode_AsUTF8(frame->f_code->co_filename);
+-      const char *funcname = PyUnicode_AsUTF8(frame->f_code->co_name);
+-      fprintf(fp, "  File \"%s\", line %d in %s\n", filename, line, funcname);
+-    } while ((frame = frame->f_back));
++  PyFrameObject *frame;
++  if (!(frame = PyEval_GetFrame())) {
++    return;
+   }
++  do {
++    PyCodeObject *code = PyFrame_GetCode(frame);
++    const int line = PyFrame_GetLineNumber(frame);
++    const char *filepath = PyUnicode_AsUTF8(code->co_filename);
++    const char *funcname = PyUnicode_AsUTF8(code->co_name);
++    fprintf(fp, "  File \"%s\", line %d in %s\n", filepath, line, funcname);
++  } while ((frame = PyFrame_GetBack(frame)));
+ }
+ 
+ void BPY_DECREF(void *pyob_ptr)
+--- a/source/blender/python/intern/bpy_traceback.c
++++ b/source/blender/python/intern/bpy_traceback.c
+@@ -34,7 +34,8 @@
+ 
+ static const char *traceback_filepath(PyTracebackObject *tb, PyObject **coerce)
+ {
+-  *coerce = PyUnicode_EncodeFSDefault(tb->tb_frame->f_code->co_filename);
++  PyCodeObject *code = PyFrame_GetCode(tb->tb_frame);
++  *coerce = PyUnicode_EncodeFSDefault(code->co_filename);
+   return PyBytes_AS_STRING(*coerce);
+ }
+ 
diff --git a/srcpkgs/blender/patches/0004-python-3.11.patch b/srcpkgs/blender/patches/0004-python-3.11.patch
new file mode 100644
index 000000000000..2ff495371ceb
--- /dev/null
+++ b/srcpkgs/blender/patches/0004-python-3.11.patch
@@ -0,0 +1,58 @@
+From 378f65f7d9843ea789a66623019163f935af141e Mon Sep 17 00:00:00 2001
+From: Campbell Barton <campbell@blender.org>
+Date: Thu, 7 Jul 2022 12:30:40 +1000
+Subject: [PATCH] Fix Py-driver byte code access with Python 3.11
+
+Error in [0] which assumed the struct member was renamed however
+byte-code access from PyCodeObject now requires an API call.
+
+Thanks to @music for pointing this out.
+
+[0]: 780c0ea097444c3be60314dffd203c099720badb
+---
+ source/blender/python/intern/bpy_driver.c | 18 +++++++++++++++---
+ 1 file changed, 15 insertions(+), 3 deletions(-)
+
+--- a/source/blender/python/intern/bpy_driver.c
++++ b/source/blender/python/intern/bpy_driver.c
+@@ -434,13 +434,19 @@ static bool bpy_driver_secure_bytecode_v
+     PyObject *co_code;
+ 
+ #  if PY_VERSION_HEX >= 0x030b0000 /* Python 3.11 & newer. */
+-    co_code = py_code->_co_code;
++    co_code = PyCode_GetCode(py_code);
++    if (UNLIKELY(!co_code)) {
++      PyErr_Print();
++      PyErr_Clear();
++      return false;
++    }
+ #  else
+     co_code = py_code->co_code;
+ #  endif
+ 
+     PyBytes_AsStringAndSize(co_code, (char **)&codestr, &code_len);
+     code_len /= sizeof(*codestr);
++    bool ok = true;
+ 
+     for (Py_ssize_t i = 0; i < code_len; i++) {
+       const int opcode = _Py_OPCODE(codestr[i]);
+@@ -449,11 +455,17 @@ static bool bpy_driver_secure_bytecode_v
+                 "\tBPY_driver_eval() - restricted access disallows opcode '%d', "
+                 "enable auto-execution to support\n",
+                 opcode);
+-        return false;
++        ok = false;
++        break;
+       }
+     }
+ 
+-#  undef CODESIZE
++#  if PY_VERSION_HEX >= 0x030b0000 /* Python 3.11 & newer. */
++    Py_DECREF(co_code);
++#  endif
++    if (!ok) {
++      return false;
++    }
+   }
+ 
+   return true;
diff --git a/srcpkgs/blender/patches/altivec-all.patch b/srcpkgs/blender/patches/altivec-all.patch
index 115e1ea6fd03..bc6858b336d3 100644
--- a/srcpkgs/blender/patches/altivec-all.patch
+++ b/srcpkgs/blender/patches/altivec-all.patch
@@ -1,8 +1,10 @@
 This applies a better workaround for C++ type conflicts
 in AltiVec/C++, allowing it to build on BE ppc(64).
 
---- a/extern/clew/include/clew.h
-+++ b/extern/clew/include/clew.h
+Index: blender-3.0.0/extern/clew/include/clew.h
+===================================================================
+--- blender-3.0.0.orig/extern/clew/include/clew.h
++++ blender-3.0.0/extern/clew/include/clew.h
 @@ -370,15 +370,18 @@ typedef unsigned int cl_GLenum;
  
  /* Define basic vector types */
diff --git a/srcpkgs/blender/patches/no-Werror-double-promotion.patch b/srcpkgs/blender/patches/no-Werror-double-promotion.patch
index 2d17a6da1818..94533140866d 100644
--- a/srcpkgs/blender/patches/no-Werror-double-promotion.patch
+++ b/srcpkgs/blender/patches/no-Werror-double-promotion.patch
@@ -1,5 +1,7 @@
---- ./intern/cycles/CMakeLists.txt.orig	2021-04-16 20:47:50.466754473 +0200
-+++ ./intern/cycles/CMakeLists.txt	2021-04-16 20:48:06.199903232 +0200
+Index: blender-3.0.0/intern/cycles/CMakeLists.txt
+===================================================================
+--- blender-3.0.0.orig/intern/cycles/CMakeLists.txt
++++ blender-3.0.0/intern/cycles/CMakeLists.txt
 @@ -336,7 +336,7 @@ endif()
  # Warnings
  if(CMAKE_COMPILER_IS_GNUCXX)
diff --git a/srcpkgs/blender/template b/srcpkgs/blender/template
index 28befed1faf8..da38be21761a 100644
--- a/srcpkgs/blender/template
+++ b/srcpkgs/blender/template
@@ -1,7 +1,7 @@
 # Template file for 'blender'
 pkgname=blender
 version=3.0.0
-revision=5
+revision=6
 archs="x86_64* ppc64*"
 build_style="cmake"
 pycompile_dirs="/usr/share/blender/${version%.*}/scripts"
@@ -28,8 +28,6 @@ homepage="https://www.blender.org"
 distfiles="https://download.blender.org/source/blender-${version}.tar.xz"
 checksum=50f0f32bcdf8825a12ba5c8d853b6e6c6b2da65ef01e858ea5900a06cccbf1cb
 python_version=3
-CXXFLAGS="-DNDEBUG"
-CFLAGS="$CXXFLAGS"
 LDFLAGS="-Wl,-z,stack-size=2097152"
 # Blender tests are executed against a system installation of blender. This
 # is currently not supported by xbps-src.

             reply	other threads:[~2022-09-21 17:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-21 17:00 sgn [this message]
2022-09-24  7:00 ` [PR PATCH] [Updated] " sgn
2022-09-25  2:00 ` blender: blender: update to 3.3.0 oreo639
2022-09-25  2:00 ` oreo639
2022-09-25  2:00 ` oreo639
2022-09-25  2:02 ` oreo639
2022-09-25  2:02 ` oreo639
2022-09-25  9:58 ` [PR PATCH] [Updated] " sgn
2022-09-26 14:20 ` [PR PATCH] [Merged]: " sgn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-39402@inbox.vuxu.org \
    --to=sgn@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).