Take the address of a dllimport slot at run time - #1421
Merged
Conversation
'NB_SLOT_ALIAS' initialized a 'constexpr' pointer with the address of a CPython function. Windows declares such a function with '__declspec(dllimport)', so its address is the content of an import slot and not a constant expression. Clang rejects the initializer in every Windows target, which stops the build of any extension with clang-cl. MSVC accepts it as an extension, so the existing Windows job of the CI never saw the error. The pointer is now 'const' instead of 'constexpr'. It is only ever called, so no other place needs a constant expression. A clang-cl job covers the target.
Owner
|
Thank you. I will trim back some of the comments of these changes, I think they are overkill. The commit history and PR description is enough to look into the detailed rationale. |
This was referenced Aug 23, 2026
KKyang
added a commit
to ROCm/rocm-libraries
that referenced
this pull request
Aug 24, 2026
Fixes #11170 ## Problem nanobind **3.0.0** (released 2026-08-22) does not build with clang on Windows. `NB_SLOT_ALIAS` constexpr-initialises a function pointer to the `dllimport`'d `PyObject_Vectorcall`, and the address of a dllimport symbol is not a constant expression there: ``` nanobind/nb_backend_slots.h:581:27: error: constexpr variable 'vectorcall' must be initialized by a constant expression nanobind/nb_backend.h:616:28: note: expanded from macro 'NB_SLOT_ALIAS' 616 | inline constexpr ret (*name) args = ⌖ ``` Every nanobind TU fails, so `pip install projects/hipblaslt/tensilelite/rocisa` dies during build isolation and takes the **rocISA / Windows** job with it. It started the same day 3.0.0 landed on PyPI, because every nanobind requirement in these trees was unbounded — `nanobind>=2.0`, or in two places just `nanobind`. Underlying compiler behaviour: [llvm/llvm-project#125952](llvm/llvm-project#125952). Same code is fine on Linux/macOS. ## Fix Upstream fixed it in [wjakob/nanobind#1421](wjakob/nanobind#1421) (merged 2026-08-23) by dropping the `constexpr`. So exclude the single bad release with `!=3.0.0` rather than capping the 3.x line — 3.0.1 gets picked up automatically with no follow-up change: | version | | |---|---| | 2.15.0 | allowed | | **3.0.0** | **excluded** | | 3.0.1 | allowed | | 3.1.0 | allowed | Applied to all five pip-resolved requirements: - `projects/hipblaslt/tensilelite/pyproject.toml` - `projects/hipblaslt/tensilelite/requirements.txt` - `projects/hipblaslt/tensilelite/rocisa/pyproject.toml` - `shared/stinkytofu/pyproject.toml` - `shared/stinkytofu/requirements.txt` The CMake `FetchContent` fallbacks are already pinned (rocisa v2.6.1, hipdnn v2.12.0, origami v2.0.0) and are unaffected. ## Test plan - [x] Specifier verified: `>=2.0,!=3.0.0` admits 2.15.0 / 3.0.1 / 3.1.0, rejects 3.0.0 and 1.9.0 - [x] Grep confirms no unbounded nanobind requirement remains in either tree - [ ] rocISA / Windows green in CI (the real check)
Jinp800125
pushed a commit
to Jinp800125/rocm-libraries
that referenced
this pull request
Aug 27, 2026
Fixes ROCm#11170 ## Problem nanobind **3.0.0** (released 2026-08-22) does not build with clang on Windows. `NB_SLOT_ALIAS` constexpr-initialises a function pointer to the `dllimport`'d `PyObject_Vectorcall`, and the address of a dllimport symbol is not a constant expression there: ``` nanobind/nb_backend_slots.h:581:27: error: constexpr variable 'vectorcall' must be initialized by a constant expression nanobind/nb_backend.h:616:28: note: expanded from macro 'NB_SLOT_ALIAS' 616 | inline constexpr ret (*name) args = ⌖ ``` Every nanobind TU fails, so `pip install projects/hipblaslt/tensilelite/rocisa` dies during build isolation and takes the **rocISA / Windows** job with it. It started the same day 3.0.0 landed on PyPI, because every nanobind requirement in these trees was unbounded — `nanobind>=2.0`, or in two places just `nanobind`. Underlying compiler behaviour: [llvm/llvm-project#125952](llvm/llvm-project#125952). Same code is fine on Linux/macOS. ## Fix Upstream fixed it in [wjakob/nanobind#1421](wjakob/nanobind#1421) (merged 2026-08-23) by dropping the `constexpr`. So exclude the single bad release with `!=3.0.0` rather than capping the 3.x line — 3.0.1 gets picked up automatically with no follow-up change: | version | | |---|---| | 2.15.0 | allowed | | **3.0.0** | **excluded** | | 3.0.1 | allowed | | 3.1.0 | allowed | Applied to all five pip-resolved requirements: - `projects/hipblaslt/tensilelite/pyproject.toml` - `projects/hipblaslt/tensilelite/requirements.txt` - `projects/hipblaslt/tensilelite/rocisa/pyproject.toml` - `shared/stinkytofu/pyproject.toml` - `shared/stinkytofu/requirements.txt` The CMake `FetchContent` fallbacks are already pinned (rocisa v2.6.1, hipdnn v2.12.0, origami v2.0.0) and are unaffected. ## Test plan - [x] Specifier verified: `>=2.0,!=3.0.0` admits 2.15.0 / 3.0.1 / 3.1.0, rejects 3.0.0 and 1.9.0 - [x] Grep confirms no unbounded nanobind requirement remains in either tree - [ ] rocISA / Windows green in CI (the real check)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Take the address of a dllimport slot at run time
NB_SLOT_ALIASinitializes aconstexprpointer with the address of a CPython function (nb_backend.h:615):Windows declares a CPython function with
__declspec(dllimport), so its address is the content of an import slot that the loader fills, and not a constant expression. Clang rejects the initializer:Every Windows target of Clang fails, both
--target=x86_64-pc-windows-msvcand--target=x86_64-w64-windows-gnu, so no extension builds with clang-cl. MSVC accepts the initializer as an extension, which is why thewindows-2022job of the CI stays green.The macro arrived with the vector call slots in 9219167 and reached its first release in 3.0.0.
Fix
Make the pointer
constinstead ofconstexpr:Tests
The error appears at compile time on one platform, so the test is a CI job.
.github/workflows/ci.ymlgains aclang-cljob.