Skip to content

Fix exec platform auto-detection for cross-compilation#476

Open
lewissettercaci wants to merge 1 commit into
bazel-contrib:mainfrom
lewissettercaci:cross-compile-exec-platform
Open

Fix exec platform auto-detection for cross-compilation#476
lewissettercaci wants to merge 1 commit into
bazel-contrib:mainfrom
lewissettercaci:cross-compile-exec-platform

Conversation

@lewissettercaci

Copy link
Copy Markdown

When cross-compiling (e.g., building for linux-aarch64 from linux-x86_64), exec tools like cicc should run on the build host platform, not the target platform. The previous constraint-based auto-detection could incorrectly select the target platform's tools in some scenarios.

This fix adds explicit host platform detection at repository instantiation time, using the detected host platform as the default for exec components. This ensures that when building with --platforms=linux-aarch64 on an x86_64 host, the x86_64 CUDA tools are selected, not the ARM64 tools.

Priority order for exec platform selection:

  1. Explicit --@rules_cuda//cuda:exec_platform flag (user override)
  2. Detected host platform (works for local builds & cross-compilation)
  3. Constraint-based auto-detection (fallback for RBE scenarios)

When cross-compiling (e.g., building for linux-aarch64 from linux-x86_64),
exec tools like nvcc and cicc should run on the build host platform, not
the target platform. The previous constraint-based auto-detection could
incorrectly select the target platform's tools in some scenarios.

This fix adds explicit host platform detection at repository instantiation
time, using the detected host platform as the default for exec components.
This ensures that when building with --platforms=linux-aarch64 on an
x86_64 host, the x86_64 CUDA tools are selected, not the ARM64 tools.

Priority order for exec platform selection:
1. Explicit --@rules_cuda//cuda:exec_platform flag (user override)
2. Detected host platform (works for local builds & cross-compilation)
3. Constraint-based auto-detection (fallback for RBE scenarios)
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.

1 participant