Uh oh!
There was an error while loading. Please reload this page.
Make Linker.backend a classmethod - #1910
Conversation
This comment has been minimized.
This comment has been minimized.
dbe6176 to
215418aCompare
leofang
left a comment
There was a problem hiding this comment.
Thanks, Phillip! Implementation-wise LGTM. Left a few suggestions.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Allows querying the linking backend without constructing a Linker instance — useful for dispatching on input format (PTX vs. LTOIR) before linking. Updates existing call sites (Program init, test_linker) to use the new invocation form Linker.backend().
Covers classmethod invocation (Linker.backend() without an instance), memoisation flag handling, probe-on-first-use, and non-property attribute semantics.
Breaking change: Linker.backend is now a classmethod, so call sites must use parens: Linker.backend().
215418a to
12d291bCompare
leofang
left a comment
There was a problem hiding this comment.
Given that we just recently went to the opposite direction (converting some methods to properties, #1945 & #1986), it'd be better to have @mdboom or @Andy-Jost to chime in from the design consistency perspective. It might be possible that we need to re-evaluate if #714 is really necessary.
Uh oh!
There was an error while loading. Please reload this page.
leofang
commented
May 5, 2026
We discussed this PR in the team sync today, but I forgot the conclusion... Maybe Mike or Ralf remembers? 😅 |
Uh oh!
There was an error while loading. Please reload this page.
Merge upstream main into linker-backend-classmethod-714 and resolve three conflicts (_linker.pyx, _program.pyx, 1.0.0-notes.rst). Also rename Linker.backend to Linker.which_backend per review feedback from Ralf, and update the return type from str to CompilerBackendType to match main's enum convention.
leofang
commented
May 7, 2026
/ok to test 792d99f |
Uh oh!
There was an error while loading. Please reload this page.
|
Summary
Linker.backendfrom an instance property to a classmethod so callers can query the linking backend without constructing aLinker_decide_nvjitlink_or_driver()(existing memoised probe) and maps the return value to"nvJitLink"or"driver"_program.pyxand existing test assertion to use parensDevice()/cuInitrequired)0.8.0-notes.rstdocumenting the breaking changeBreaking change:
linker.backend(attribute access) now returns a bound method, not a string. All call sites must useLinker.backend(). Only 2 in-repo call sites affected; numba-cuda (the requester) will adoptLinker.backend()from day one.Test plan
test_linker_initpasses with updated paren callCloses#714
🤖 Generated with Claude Code