Bug 2336915 - llvm fails to build with Python 3.14: tools/opt-viewer/suppress.test: AttributeError: type object 'Passed' has no attribute 'demangler_lock'
Summary: llvm fails to build with Python 3.14: tools/opt-viewer/suppress.test: Attribu...
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: llvm
Version: rawhide
Hardware: Unspecified
OS: Unspecified
high
unspecified
Target Milestone: ---
Assignee: Tom Stellard
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PYTHON3.14
TreeView+ depends on / blocked
 
Reported: 2025-01-10 13:02 UTC by Karolina Surma
Modified: 2025-04-25 14:39 UTC (History)
16 users (show)

Fixed In Version: llvm-20.1.3-1.fc43
Clone Of:
Environment:
Last Closed: 2025-04-25 14:39:44 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github llvm llvm-project pull 131214 0 None open Avoid a race condition in opt-viewer/optrecord 2025-03-13 20:59:35 UTC
Red Hat Issue Tracker FC-1478 0 None None None 2025-02-13 03:02:28 UTC

Description Karolina Surma 2025-01-10 13:02:30 UTC
llvm fails to build with Python 3.14.0a3.

******************** TEST 'LLVM :: tools/opt-viewer/suppress.test' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
Reading YAML files...
Rendering index page...
Rendering HTML files...
	1 of 1
--
Command Output (stderr):
--
RUN: at line 1: /usr/bin/python3 /builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py -s /builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/test/tools/opt-viewer/Inputs/suppress -o /builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/redhat-linux-build/test/tools/opt-viewer/Output/suppress.test.tmp /builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/test/tools/opt-viewer/Inputs/suppress/s.opt.yaml --no-highlight --demangler=/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/redhat-linux-build/bin/llvm-cxxfilt
+ /usr/bin/python3 /builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py -s /builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/test/tools/opt-viewer/Inputs/suppress -o /builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/redhat-linux-build/test/tools/opt-viewer/Output/suppress.test.tmp /builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/test/tools/opt-viewer/Inputs/suppress/s.opt.yaml --no-highlight --demangler=/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/redhat-linux-build/bin/llvm-cxxfilt
/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py:138: SyntaxWarning: invalid escape sequence '\S'
  indent = re.sub("\S", " ", indent)
/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py:138: SyntaxWarning: invalid escape sequence '\S'
  indent = re.sub("\S", " ", indent)
/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py:138: SyntaxWarning: invalid escape sequence '\S'
  indent = re.sub("\S", " ", indent)
/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py:138: SyntaxWarning: invalid escape sequence '\S'
  indent = re.sub("\S", " ", indent)
/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py:138: SyntaxWarning: invalid escape sequence '\S'
  indent = re.sub("\S", " ", indent)
/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py:138: SyntaxWarning: invalid escape sequence '\S'
  indent = re.sub("\S", " ", indent)
/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py:138: SyntaxWarning: invalid escape sequence '\S'
  indent = re.sub("\S", " ", indent)
/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py:138: SyntaxWarning: invalid escape sequence '\S'
  indent = re.sub("\S", " ", indent)
/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py:138: SyntaxWarning: invalid escape sequence '\S'
  indent = re.sub("\S", " ", indent)
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/lib64/python3.14/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
                    ~~~~^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.14/multiprocessing/pool.py", line 48, in mapstar
    return list(map(*args))
  File "/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/optpmap.py", line 25, in _wrapped_func
    return func(argument, filter_)
  File "/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py", line 293, in _render_file
    SourceFileRenderer(source_dir, output_dir, filename, no_highlight).render(remarks)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
  File "/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py", line 216, in render
    self.render_source_lines(self.source_stream, line_remarks)
    ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py", line 123, in render_source_lines
    self.render_inline_remarks(remark, html_line)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py", line 126, in render_inline_remarks
    inlining_context = r.DemangledFunctionName
                       ^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/optrecord.py", line 153, in DemangledFunctionName
    return self.demangle(self.Function)
           ~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/optrecord.py", line 77, in demangle
    with cls.demangler_lock:
         ^^^^^^^^^^^^^^^^^^
AttributeError: type object 'Passed' has no attribute 'demangler_lock'. Did you mean: 'demangler_proc'?
"""

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py", line 471, in <module>
    main()
    ~~~~^^
  File "/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py", line 457, in main
    generate_report(
    ~~~~~~~~~~~~~~~^
        all_remarks,
        ^^^^^^^^^^^^
    ...<7 lines>...
        print_progress,
        ^^^^^^^^^^^^^^^
    )
    ^
  File "/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/opt-viewer.py", line 376, in generate_report
    optpmap.pmap(
    ~~~~~~~~~~~~^
        _render_file_bound, file_remarks.items(), num_jobs, should_print_progress
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/builddir/build/BUILD/llvm-19.1.6-build/llvm-project-19.1.6.src/llvm/tools/opt-viewer/optpmap.py", line 57, in pmap
    result = pool.map(_wrapped_func, func_and_args, *args, **kwargs)
  File "/usr/lib64/python3.14/multiprocessing/pool.py", line 367, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/lib64/python3.14/multiprocessing/pool.py", line 774, in get
    raise self._value
AttributeError: type object 'Passed' has no attribute 'demangler_lock'


https://docs.python.org/3.14/whatsnew/3.14.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.14/fedora-rawhide-x86_64/08492403-llvm/

For all our attempts to build llvm with Python 3.14, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14/package/llvm/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.14:
https://copr.fedorainfracloud.org/coprs/g/python/python3.14/

Let us know here if you have any questions.

Python 3.14 is planned to be included in Fedora 43.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.14.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Aoife Moloney 2025-02-26 13:22:13 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 42 development cycle.
Changing version to 42.

Comment 2 Miro Hrončok 2025-03-12 14:38:02 UTC
This blocks sympy, which blocks 38 other packages.

Comment 4 Miro Hrončok 2025-03-12 14:52:00 UTC
Naïvely, trying this:

--- a/llvm/tools/opt-viewer/optrecord.py
+++ b/llvm/tools/opt-viewer/optrecord.py
@@ -65,16 +65,23 @@ class Remark(yaml.YAMLObject):
     default_demangler = "c++filt -n"
     demangler_proc = None
 
+    @classmethod
+    def get_demangler_lock(cls):
+        try:
+            return cls.demangler_lock
+        except AttributeError:
+            cls.demangler_lock = Lock()
+            return cls.demangler_lock
+
     @classmethod
     def set_demangler(cls, demangler):
         cls.demangler_proc = subprocess.Popen(
             demangler.split(), stdin=subprocess.PIPE, stdout=subprocess.PIPE
         )
-        cls.demangler_lock = Lock()
 
     @classmethod
     def demangle(cls, name):
-        with cls.demangler_lock:
+        with cls.get_demangler_lock():
             cls.demangler_proc.stdin.write((name + "\n").encode("utf-8"))
             cls.demangler_proc.stdin.flush()
             return cls.demangler_proc.stdout.readline().rstrip().decode("utf-8")

Comment 5 Miro Hrončok 2025-03-13 20:59:35 UTC
https://github.com/llvm/llvm-project/pull/131214 fixes the race in our copr (and makes llvm build with Python 3.14).

Comment 6 Tulio Magno Quites Machado Filho 2025-04-25 14:39:44 UTC
This got fixed in LLVM 21 and got backported LLVM 20.1.3. See the results from: https://copr.fedorainfracloud.org/coprs/g/python/python3.14/build/8914108/

I'm closing this now.
Thanks!


Note You need to log in before you can comment on or make changes to this bug.