I've been working on a slow project migration to bazel involving cross-compiling shenanigan. As far as I could tell, all of the Bazel toolchain stuff was working and was committed into source control.
A few months later I have time to pick the project up again. Unfortunately, things aren't working. My cc_toolchains still seem to be working and are being resolved. Yet the underlying binary which is being executed appears to be the standard host /usr/bin/gcc
even though the --toolchain_resolution_debug info shows the correct toolchain being selected. This obviously fails when you are trying to build for one architecture with a compiler which is targeting another. (On the off-chance bazel was being clever, I md5summed the in-sandbox /usr/bin/gcc binary and the host system gcc version and they were the same).
/var/tmp/gk/repo_bazel$ bazel --output_base=/var/tmp/gk/bazel_cache build --experimental_platforms_api //usfp-firewall/usfp/mflow/usfp_hash:usfp_hash --verbose_failures --sandbox_debug --toolchain_resolution_debug --platforms=//usfp-firewall:armada
INFO: ToolchainResolution: Type @bazel_tools//tools/cpp:toolchain_type: target platform //usfp-firewall:armada: execution @local_config_platform//:host: Selected toolchain //tools/build/nfp-firewall-build:marvell_armada_toolchain
INFO: ToolchainResolution: Type @bazel_tools//tools/cpp:toolchain_type: target platform //usfp-firewall:armada: Rejected toolchain //tools/build/nfp-firewall-build:marvell_octeontx_toolchain; mismatching values: NPU_octeontx
INFO: ToolchainResolution: Type @bazel_tools//tools/cpp:toolchain_type: target platform //usfp-firewall:armada: Rejected toolchain //tools/build/nfp-firewall-build:marvell_octeontx2_toolchain; mismatching values: NPU_octeontx2
INFO: ToolchainResolution: Type @bazel_tools//tools/cpp:toolchain_type: target platform //usfp-firewall:armada: Rejected toolchain @local_config_cc//:cc-compiler-armeabi-v7a; mismatching values: arm, android
INFO: ToolchainResolution: Type @bazel_tools//tools/cpp:toolchain_type: target platform //usfp-firewall:armada: Rejected toolchain @local_config_cc//:cc-compiler-k8; mismatching values: x86_64
INFO: ToolchainResolution: Target platform //usfp-firewall:armada: Selected execution platform @local_config_platform//:host, type @bazel_tools//tools/cpp:toolchain_type -> toolchain //tools/build/nfp-firewall-build:marvell_armada_toolchain
INFO: ToolchainResolution: Target platform @local_config_platform//:host: Selected execution platform @local_config_platform//:host,
INFO: ToolchainResolution: Target platform //usfp-firewall:armada: Selected execution platform @local_config_platform//:host,
INFO: ToolchainResolution: Target platform @local_config_platform//:host: Selected execution platform @local_config_platform//:host,
INFO: Analyzed target //usfp-firewall/usfp/mflow/usfp_hash:usfp_hash (28 packages loaded, 802 targets configured).
INFO: Found 1 target...
ERROR: /var/tmp/gk/repo_bazel/usfp-firewall/usfp/mflow/usfp_hash/BUILD:24:11: Compiling usfp-firewall/usfp/mflow/usfp_hash/usfp_hash_cuckoo.c failed: (Exit 1): linux-sandbox failed: error executing command
(cd /var/tmp/gk/bazel_cache/sandbox/linux-sandbox/1336/execroot/__main__ && \
exec env - \
PATH=/home/garrettkajmowicz/bin:/opt/sophos/bin:/opt/marvell/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/storage/build_tools:/storage/pit-dev-lab \
PWD=/proc/self/cwd \
TMPDIR=/tmp \
/home/garrettkajmowicz/.cache/bazel/_bazel_garrettkajmowicz/install/f95ca91ebc34d56aa0f8ad499de91220/linux-sandbox -t 15 -w /var/tmp/gk/bazel_cache/sandbox/linux-sandbox/1336/execroot/__main__ -w /tmp -w /dev/shm -D -- /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -MD -MF bazel-out/k8-fastbuild/bin/usfp-firewall/usfp/mflow/usfp_hash/_objs/usfp_hash/usfp_hash_cuckoo.pic.d '-frandom-seed=bazel-out/k8-fastbuild/bin/usfp-firewall/usfp/mflow/usfp_hash/_objs/usfp_hash/usfp_hash_cuckoo.pic.o' -fPIC