-
Notifications
You must be signed in to change notification settings - Fork 323
Description
Description
When building an Android Kotlin app using system_demo_toolchains(), the build fails because the cpython_archive target's sha256 attribute uses a select() without a default value, and the Android build configuration (cfg:no-san) sets CPU to x86_32 which doesn't match any of the available options.
Environment
- Buck2 version: 2026-01-14-27ba7841b62d77ea13dbee5f69fa5999cfe18a90
- OS: macOS (Darwin 25.1.0, Apple Silicon arm64)
- Java: OpenJDK 17 via Homebrew
Steps to Reproduce
- Create a new Buck2 project with
buck2 init - Add an
android_binarytarget with Kotlin source files usingandroid_librarywithlanguage = "KOTLIN" - Run
buck2 build //path/to:android_target
Error Message
BUILD FAILED
Error running analysis for `root//app:app_debug (prelude//platforms:default#...)`
Caused by:
0: Error in configured node dependency, dependency chain follows:
root//app:app_debug
-> root//app:core (cfg:no-san#...)
-> toolchains//:kotlin_for_android
-> prelude//toolchains/android/.../kotlincd_tool
-> toolchains//:java_bootstrap
-> prelude//java/tools:fat_jar
-> toolchains//:python_bootstrap
-> toolchains//:cpython
-> toolchains//:cpython_archive
1: configuring attr `sha256`
2: None of 2 conditions matched configuration `cfg:no-san#...` and no default was set:
prelude//cpu:arm64
prelude//cpu:x86_64
Analysis
The cpython_archive target in system_demo_toolchains() uses a nested select based on OS and CPU:
sha256 = select({
"prelude//os:macos": select({
"prelude//cpu:arm64": "...",
"prelude//cpu:x86_64": "...",
}),
...
})When building for Android, the configuration cfg:no-san is created with:
prelude//cpu/constraints:x86_32(Android target architecture)prelude//os/constraints:macos(host OS)
The select for CPU only has arm64 and x86_64 options, so x86_32 doesn't match, causing the failure.
Expected Behavior
The cpython_archive should use the host execution platform's CPU (arm64 on Apple Silicon) rather than the target platform's CPU (x86_32 for Android), since Python is needed for build tooling, not for running on the Android device.
Suggested Fix
Either:
- Add a default value to the
sha256select that falls back to the host platform - Use
exec_compatible_withor execution platform constraints to ensure cpython_archive resolves based on the execution platform, not the target platform - Document that
system_demo_toolchains()doesn't support Android Kotlin builds
Workaround
Currently, building Java-only Android resources works:
buck2 build //app:res # Works
buck2 build //app:app_debug # Fails (Kotlin)