bazelbuild / bazel-toolchains

Repository that hosts Bazel toolchain configs for remote execution and related support tools.
Apache License 2.0
186 stars 96 forks source link

Running `rbe_configs_gen` on macOS for Apple Silicon to generate configs for x86 Linux doesn't work #993

Closed shs96c closed 1 year ago

shs96c commented 1 year ago

On an Apple Silicon Mac run:

./rbe_configs_gen --toolchain_container=gcr.io/engflow-public/bazel/ubuntu2004-bazel-java11@sha256:c7b874d00b5a5c0cdc9e2d24eea11f3ca689723a42d6c6d088e9e659d389a0f1 --exec_os=linux --target_os=linux --generate_java_configs=false --output_config_path engflow_config --output_src_root .

This fails, with an error log:

2023/01/17 10:33:54 rbe_configs_gen.go \
2023/01/17 10:33:54 --toolchain_container="gcr.io/engflow-public/bazel/ubuntu2004-bazel-java11@sha256:c7b874d00b5a5c0cdc9e2d24eea11f3ca689723a42d6c6d088e9e659d389a0f1" \
2023/01/17 10:33:54 --exec_os="linux" \
2023/01/17 10:33:54 --target_os="linux" \
2023/01/17 10:33:54 --bazel_version="" \
2023/01/17 10:33:54 --output_src_root="." \
2023/01/17 10:33:54 --output_config_path="engflow_config" \
2023/01/17 10:33:54 --generate_java_configs=false \
2023/01/17 10:33:54 rbeconfigsgen.Options:
2023/01/17 10:33:54 BazelVersion="6.0.0"
2023/01/17 10:33:54 ToolchainContainer="gcr.io/engflow-public/bazel/ubuntu2004-bazel-java11@sha256:c7b874d00b5a5c0cdc9e2d24eea11f3ca689723a42d6c6d088e9e659d389a0f1"
2023/01/17 10:33:54 ExecOS="linux"
2023/01/17 10:33:54 TargetOS="linux"
2023/01/17 10:33:54 OutputTarball=""
2023/01/17 10:33:54 OutputSourceRoot="."
2023/01/17 10:33:54 OutputConfigPath="engflow_config"
2023/01/17 10:33:54 OutputManifest=""
2023/01/17 10:33:54 PlatformParams={ExecConstraints: [@platforms//os:linux @platforms//cpu:x86_64 @bazel_tools//tools/cpp:clang], TargetConstraints: [@platforms//os:linux @platforms//cpu:x86_64], CppToolchainTarget: "", ToolchainContainer: "", OSFamily: "Linux"}
2023/01/17 10:33:54 GenCPPConfigs=true
2023/01/17 10:33:54 CPPConfigTargets=[@local_config_cc//...]
2023/01/17 10:33:54 CPPConfigRepo="local_config_cc"
2023/01/17 10:33:54 CppBazelCmd="build"
2023/01/17 10:33:54 CppGenEnv=map[ABI_LIBC_VERSION:glibc_2.19 ABI_VERSION:clang BAZEL_COMPILER:clang BAZEL_HOST_SYSTEM:i686-unknown-linux-gnu BAZEL_TARGET_CPU:k8 BAZEL_TARGET_LIBC:glibc_2.19 BAZEL_TARGET_SYSTEM:x86_64-unknown-linux-gnu CC:clang CC_TOOLCHAIN_NAME:linux_gnu_x86]
2023/01/17 10:33:54 CppGenEnvJSON=""
2023/01/17 10:33:54 GenJavaConfigs=false
2023/01/17 10:33:54 JavaUseLocalRuntime=false
2023/01/17 10:33:54 TempWorkDir=""
2023/01/17 10:33:54 Cleanup=true
2023/01/17 10:33:54 Running: 'docker pull gcr.io/engflow-public/bazel/ubuntu2004-bazel-java11@sha256:c7b874d00b5a5c0cdc9e2d24eea11f3ca689723a42d6c6d088e9e659d389a0f1'
2023/01/17 10:33:55 Running: 'docker inspect --format={{index .RepoDigests 0}} gcr.io/engflow-public/bazel/ubuntu2004-bazel-java11@sha256:c7b874d00b5a5c0cdc9e2d24eea11f3ca689723a42d6c6d088e9e659d389a0f1'
2023/01/17 10:33:55 Resolved toolchain image "gcr.io/engflow-public/bazel/ubuntu2004-bazel-java11@sha256:c7b874d00b5a5c0cdc9e2d24eea11f3ca689723a42d6c6d088e9e659d389a0f1" to fully qualified reference "gcr.io/engflow-public/bazel/ubuntu2004-bazel-java11@sha256:c7b874d00b5a5c0cdc9e2d24eea11f3ca689723a42d6c6d088e9e659d389a0f1".
2023/01/17 10:33:55 Running: 'docker create --rm gcr.io/engflow-public/bazel/ubuntu2004-bazel-java11@sha256:c7b874d00b5a5c0cdc9e2d24eea11f3ca689723a42d6c6d088e9e659d389a0f1 sleep infinity'
2023/01/17 10:33:55 Config generation failed: Config generation failed: failed to initialize a docker container: container ID "WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested\nff56913949408cfbad8d5b6d29888a741c2e1f2f3767695c78e75886619725ca" extracted from the stdout of the container create command had unexpected length, got 216, want 64

Normally, it's possible to pass a --platform flag to the docker command line tool to force it to use a particular platform. One way to fix this problem is to allow parameters to be passed to the docker execution.

An alternative solution would be to drop WARNING lines from the output in rbeconfigsgen.go (around line 280 or so, where the output is checked)