internal/dxcore: Fix build on 32-bit targets - #2058
Open
rautyrauty wants to merge 1 commit into
Open
Conversation
The (*[1 << 30]C.struct_dxcore_adapter) cast declares an array type that exceeds a 32-bit address space, so the package fails to compile with GOARCH=386 or GOARCH=arm: dxcore.go:55:2: type [1073741824]_Ctype_struct_dxcore_adapter larger than address space
rautyrauty
requested review from
cdesiniotis,
henry118 and
tariq1890
as code owners
September 9, 2026 06:00
henry118
reviewed
Sep 9, 2026
henry118
left a comment
Member
There was a problem hiding this comment.
@rautyrauty thanks for the patch. LGTM.
Can you please sign your commit?
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.
Description
dxcore.getAdapter()reinterprets the C adapter list through a(*[1 << 30]C.struct_dxcore_adapter)array pointer. On ILP32 targets thestruct is 76 bytes, so that array type is larger than the whole address
space and the compiler rejects the type itself:
internal/dxcore/dxcore.go:55:2: type [1073741824]_Ctype_struct_dxcore_adapter larger than address space
internal/dxcore/dxcore.go:55:2: type [1073741824]_Ctype_struct_dxcore_adapter too large
This breaks every consumer that imports
pkg/nvcdionGOARCH=386orGOARCH=arm. We hit it packaging LXD 6.9, which vendorsnvidia-container-toolkit v1.19.1, for the i586 architecture of ALT Linux.
The fix indexes the C array through
unsafe.Slice()bounded byadapterCount, which is the modern replacement for the huge-array idiomand works on every pointer size. No behaviour change on 64-bit targets.
Checklist
make test)make lint)compile-time fix with no runtime behaviour change
Testing
GOARCH=386 CGO_ENABLED=1 go build ./internal/dxcore/fails onmainwith the diagnostic above and passes with this change.
go build ./internal/dxcore/ ./pkg/nvcdi/andmake testpass on amd64.its packaging checks in a clean i586 chroot on ALT Linux Sisyphus.