Skip to content

internal/dxcore: Fix build on 32-bit targets - #2058

Open
rautyrauty wants to merge 1 commit into
NVIDIA:mainfrom
rautyrauty:fix-dxcore-32bit-build
Open

internal/dxcore: Fix build on 32-bit targets#2058
rautyrauty wants to merge 1 commit into
NVIDIA:mainfrom
rautyrauty:fix-dxcore-32bit-build

Conversation

@rautyrauty

Copy link
Copy Markdown

Description

dxcore.getAdapter() reinterprets the C adapter list through a
(*[1 << 30]C.struct_dxcore_adapter) array pointer. On ILP32 targets the
struct 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/nvcdi on GOARCH=386 or
GOARCH=arm. We hit it packaging LXD 6.9, which vendors
nvidia-container-toolkit v1.19.1, for the i586 architecture of ALT Linux.

The fix indexes the C array through unsafe.Slice() bounded by
adapterCount, which is the modern replacement for the huge-array idiom
and works on every pointer size. No behaviour change on 64-bit targets.

Checklist

  • No secrets, sensitive information, or unrelated changes
  • Unit tests passing (make test)
  • Lint checks passing (make lint)
  • Test cases are added for new code paths — no new code path; this is a
    compile-time fix with no runtime behaviour change
  • Commits are signed-off and cryptographically signed

Testing

  • GOARCH=386 CGO_ENABLED=1 go build ./internal/dxcore/ fails on main
    with the diagnostic above and passes with this change.
  • go build ./internal/dxcore/ ./pkg/nvcdi/ and make test pass on amd64.
  • LXD 6.9 with this change applied to its vendored copy builds and passes
    its packaging checks in a clean i586 chroot on ALT Linux Sisyphus.

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
@copy-pr-bot

copy-pr-bot Bot commented Sep 9, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@henry118 henry118 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rautyrauty thanks for the patch. LGTM.

Can you please sign your commit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants