From 3214aee2cad9a085030a9ec22707057a572ccd0724483eba2d25e5d02a7ccb09 Mon Sep 17 00:00:00 2001 From: Stefan Dirsch Date: Sat, 20 Jan 2024 13:49:19 +0000 Subject: [PATCH] - python36-buildfix.patch * src/freedreno/registers/gen_header.py: hopefully fixes aarch64 build - u_0001-intel-genxml-Drop-from-__future__-import-annotations.patch u_0002-intel-genxml-Add-a-untyped-OrderedDict-fallback-for-.patch python36-buildfix.patch * fixes build against python 3.6 OBS-URL: https://build.opensuse.org/package/show/X11:XOrg/Mesa?expand=0&rev=1252 --- Mesa.changes | 15 ++++ Mesa.spec | 7 ++ python36-buildfix.patch | 76 ++++++++++++++++++ ...p-from-__future__-import-annotations.patch | 54 +++++++++++++ ...-a-untyped-OrderedDict-fallback-for-.patch | 78 +++++++++++++++++++ 5 files changed, 230 insertions(+) create mode 100644 python36-buildfix.patch create mode 100644 u_0001-intel-genxml-Drop-from-__future__-import-annotations.patch create mode 100644 u_0002-intel-genxml-Add-a-untyped-OrderedDict-fallback-for-.patch diff --git a/Mesa.changes b/Mesa.changes index f14f0e0..f4784b8 100644 --- a/Mesa.changes +++ b/Mesa.changes @@ -1,3 +1,18 @@ +------------------------------------------------------------------- +Sat Jan 20 13:04:02 UTC 2024 - Stefan Dirsch + +- python36-buildfix.patch + * src/freedreno/registers/gen_header.py: hopefully fixes aarch64 + build + +------------------------------------------------------------------- +Sat Jan 20 11:22:42 UTC 2024 - Stefan Dirsch + +- u_0001-intel-genxml-Drop-from-__future__-import-annotations.patch + u_0002-intel-genxml-Add-a-untyped-OrderedDict-fallback-for-.patch + python36-buildfix.patch + * fixes build against python 3.6 + ------------------------------------------------------------------- Sat Jan 20 10:43:27 UTC 2024 - Stefan Dirsch diff --git a/Mesa.spec b/Mesa.spec index b4b4bbb..9c1eefb 100644 --- a/Mesa.spec +++ b/Mesa.spec @@ -138,6 +138,9 @@ Source4: manual-pages.tar.bz2 Source6: Mesa-rpmlintrc Source7: Mesa.keyring Patch2: n_add-Mesa-headers-again.patch +Patch11: u_0001-intel-genxml-Drop-from-__future__-import-annotations.patch +Patch12: u_0002-intel-genxml-Add-a-untyped-OrderedDict-fallback-for-.patch +Patch13: python36-buildfix.patch # never to be upstreamed Patch54: n_drirc-disable-rgb10-for-chromium-on-amd.patch Patch58: u_dep_xcb.patch @@ -751,6 +754,10 @@ programs against the XA state tracker. rm -rf docs/README.{VMS,WIN32,OS2} %patch -P 2 -p1 +# fixes build against python 3.6 +%patch -P 11 -p1 +%patch -P 12 -p1 +%patch -P 13 -p1 # no longer needed since gstreamer-plugins-vaapi 1.18.4 %if 0%{?suse_version} < 1550 %patch -P 54 -p1 diff --git a/python36-buildfix.patch b/python36-buildfix.patch new file mode 100644 index 0000000..f8592da --- /dev/null +++ b/python36-buildfix.patch @@ -0,0 +1,76 @@ +--- mesa-23.3.3/src/nouveau/nvidia-headers/class_parser.py.orig 2024-01-20 12:47:36.464476669 +0100 ++++ mesa-23.3.3/src/nouveau/nvidia-headers/class_parser.py 2024-01-20 13:04:30.212851443 +0100 +@@ -9,6 +9,16 @@ + + from mako.template import Template + ++def removeprefix(s, prefix): ++ if s.startswith(prefix): ++ return s[len(prefix):] ++ return s ++ ++def removesuffix(s, suffix): ++ if s.endswith(suffix): ++ return s[:-len(suffix)] ++ return s ++ + METHOD_ARRAY_SIZES = { + 'BIND_GROUP_CONSTANT_BUFFER' : 16, + 'CALL_MME_DATA' : 256, +@@ -273,7 +283,7 @@ + if ":" in list[2]: + state = 1 + elif teststr in list[1]: +- curmthd.field_defs[curfield][list[1].removeprefix(teststr)] = list[2] ++ curmthd.field_defs[curfield][removeprefix(list[1], teststr)] = list[2] + else: + state = 1 + +@@ -283,7 +293,7 @@ + if ("0x" in list[2]): + state = 1 + else: +- field = list[1].removeprefix(teststr) ++ field = removeprefix(list[1], teststr) + bitfield = list[2].split(":") + curmthd.field_name_start[field] = bitfield[1] + curmthd.field_name_end[field] = bitfield[0] +@@ -304,13 +314,13 @@ + is_array = 0 + if (':' in list[2]): + continue +- name = list[1].removeprefix(teststr) ++ name = removeprefix(list[1], teststr) + if name.endswith("(i)"): + is_array = 1 +- name = name.removesuffix("(i)") ++ name = removesuffix(name, "(i)") + if name.endswith("(j)"): + is_array = 1 +- name = name.removesuffix("(j)") ++ name = removesuffix(name, "(j)") + x = method() + x.name = name + x.addr = list[2] +@@ -336,8 +346,8 @@ + + clheader = os.path.basename(args.in_h) + nvcl = clheader +- nvcl = nvcl.removeprefix("cl") +- nvcl = nvcl.removesuffix(".h") ++ nvcl = removeprefix(nvcl, "cl") ++ nvcl = removesuffix(nvcl, ".h") + nvcl = nvcl.upper() + nvcl = "NV" + nvcl + +--- mesa-23.3.3/src/freedreno/registers/gen_header.py.orig 2024-01-20 14:01:30.261999839 +0100 ++++ mesa-23.3.3/src/freedreno/registers/gen_header.py 2024-01-20 14:01:57.678558692 +0100 +@@ -781,7 +781,7 @@ def main(): + parser.add_argument('--rnn', type=str, required=True) + parser.add_argument('--xml', type=str, required=True) + +- subparsers = parser.add_subparsers(required=True) ++ subparsers = parser.add_subparsers() + + parser_c_defines = subparsers.add_parser('c-defines') + parser_c_defines.set_defaults(func=dump_c_defines) diff --git a/u_0001-intel-genxml-Drop-from-__future__-import-annotations.patch b/u_0001-intel-genxml-Drop-from-__future__-import-annotations.patch new file mode 100644 index 0000000..14a8752 --- /dev/null +++ b/u_0001-intel-genxml-Drop-from-__future__-import-annotations.patch @@ -0,0 +1,54 @@ +From a14fa9920669c8d6d911e375376f2e45052a31d6 Mon Sep 17 00:00:00 2001 +From: Jordan Justen +Date: Sat, 20 Jan 2024 01:07:23 -0800 +Subject: [PATCH 1/2] intel/genxml: Drop "from __future__ import annotations" + +This is not supported in Python 3.6, and optional in 3.7+. + +Ref: f1eae2f8bbe ("python: drop python2 support") +Signed-off-by: Jordan Justen +--- + src/intel/genxml/gen_sort_tags.py | 1 - + src/intel/genxml/genxml_import.py | 1 - + src/intel/genxml/intel_genxml.py | 1 - + 3 files changed, 3 deletions(-) + +diff --git a/src/intel/genxml/gen_sort_tags.py b/src/intel/genxml/gen_sort_tags.py +index dcdba333fe6..44cd152cd11 100755 +--- a/src/intel/genxml/gen_sort_tags.py ++++ b/src/intel/genxml/gen_sort_tags.py +@@ -2,7 +2,6 @@ + # Copyright © 2019, 2022 Intel Corporation + # SPDX-License-Identifier: MIT + +-from __future__ import annotations + import argparse + import copy + import intel_genxml +diff --git a/src/intel/genxml/genxml_import.py b/src/intel/genxml/genxml_import.py +index 76a7c77eb4c..442b4726d08 100755 +--- a/src/intel/genxml/genxml_import.py ++++ b/src/intel/genxml/genxml_import.py +@@ -2,7 +2,6 @@ + # Copyright © 2019, 2022 Intel Corporation + # SPDX-License-Identifier: MIT + +-from __future__ import annotations + import argparse + import copy + import intel_genxml +diff --git a/src/intel/genxml/intel_genxml.py b/src/intel/genxml/intel_genxml.py +index 2b7b4d8391a..9388ebecfce 100755 +--- a/src/intel/genxml/intel_genxml.py ++++ b/src/intel/genxml/intel_genxml.py +@@ -2,7 +2,6 @@ + # Copyright © 2019, 2022 Intel Corporation + # SPDX-License-Identifier: MIT + +-from __future__ import annotations + from collections import OrderedDict + import copy + import io +-- +2.35.3 + diff --git a/u_0002-intel-genxml-Add-a-untyped-OrderedDict-fallback-for-.patch b/u_0002-intel-genxml-Add-a-untyped-OrderedDict-fallback-for-.patch new file mode 100644 index 0000000..a1fc972 --- /dev/null +++ b/u_0002-intel-genxml-Add-a-untyped-OrderedDict-fallback-for-.patch @@ -0,0 +1,78 @@ +From 89ede5b851a6a15f85e83278257ee4e3783f6bd2 Mon Sep 17 00:00:00 2001 +From: Jordan Justen +Date: Sat, 20 Jan 2024 01:00:56 -0800 +Subject: [PATCH 2/2] intel/genxml: Add a untyped OrderedDict fallback for + Python 3.6 + +typing.OrderedDict was introduced in Python 3.7.2. + +Python 3.6 and 3.7 have been deprecated and are no longer supported, +but this seems like an easy enough fallback to include for now. + +https://devguide.python.org/versions/ + +Signed-off-by: Jordan Justen +--- + src/intel/genxml/intel_genxml.py | 22 +++++++++++++++++----- + 1 file changed, 17 insertions(+), 5 deletions(-) + +diff --git a/src/intel/genxml/intel_genxml.py b/src/intel/genxml/intel_genxml.py +index 9388ebecfce..eefd7b44992 100755 +--- a/src/intel/genxml/intel_genxml.py ++++ b/src/intel/genxml/intel_genxml.py +@@ -45,10 +45,22 @@ BASE_TYPES = { + + FIXED_PATTERN = re.compile(r"(s|u)(\d+)\.(\d+)") + ++try: ++ # Python 3.7 and newer should be able to support strong typing for ++ # our OrderedDict usage. ++ def typed_ordered_dict(key_ty, val_ty): ++ return typing.OrderedDict[str, bool] ++ # This will raise an exception on Python 3.6 ++ typed_ordered_dict(int, int) ++except Exception: ++ # For Python 3.6 we return an untyped OrderedDict ++ def typed_ordered_dict(key_ty, val_ty): ++ return OrderedDict ++ + def is_base_type(name: str) -> bool: + return name in BASE_TYPES or FIXED_PATTERN.match(name) is not None + +-def add_struct_refs(items: typing.OrderedDict[str, bool], node: et.Element) -> None: ++def add_struct_refs(items: typed_ordered_dict(str, bool), node: et.Element) -> None: + if node.tag == 'field': + if 'type' in node.attrib and not is_base_type(node.attrib['type']): + t = node.attrib['type'] +@@ -64,16 +76,16 @@ class Struct(object): + def __init__(self, xml: et.Element): + self.xml = xml + self.name = xml.attrib['name'] +- self.deps: typing.OrderedDict[str, Struct] = OrderedDict() ++ self.deps: typed_ordered_dict(str, Struct) = OrderedDict() + + def find_deps(self, struct_dict, enum_dict) -> None: +- deps: typing.OrderedDict[str, bool] = OrderedDict() ++ deps: typed_ordered_dict(str, bool) = OrderedDict() + add_struct_refs(deps, self.xml) + for d in deps.keys(): + if d in struct_dict: + self.deps[d] = struct_dict[d] + +- def add_xml(self, items: typing.OrderedDict[str, et.Element]) -> None: ++ def add_xml(self, items: typed_ordered_dict(str, et.Element)) -> None: + for d in self.deps.values(): + d.add_xml(items) + items[self.name] = self.xml +@@ -151,7 +163,7 @@ def sort_xml(xml: et.ElementTree) -> None: + for ws in wrapped_struct_dict.values(): + ws.find_deps(wrapped_struct_dict, enum_dict) + +- sorted_structs: typing.OrderedDict[str, et.Element] = OrderedDict() ++ sorted_structs: typed_ordered_dict(str, et.Element) = OrderedDict() + for s in structs: + _s = wrapped_struct_dict[s.attrib['name']] + _s.add_xml(sorted_structs) +-- +2.35.3 +