Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use platform_binary #139

Closed
onelxj opened this issue Dec 19, 2023 · 1 comment
Closed

Can't use platform_binary #139

onelxj opened this issue Dec 19, 2023 · 1 comment

Comments

@onelxj
Copy link

onelxj commented Dec 19, 2023

I'm using bazel version 5.4.1 (the same error I saw on bazel 7.0.0)
Running on macOS Ventura 13.4.1, M2 arm64 chip

WORKSPACE

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
HERMETIC_CC_TOOLCHAIN_VERSION = "v2.1.3"

http_archive(
    name = "hermetic_cc_toolchain",
    sha256 = "a5caccbf6d86d4f60afd45b541a05ca4cc3f5f523aec7d3f7711e584600fb075",
    urls = [
        "https://mirror.bazel.build/github.com/uber/hermetic_cc_toolchain/releases/download/{0}/hermetic_cc_toolchain-{0}.tar.gz".format(HERMETIC_CC_TOOLCHAIN_VERSION),
        "https://github.com/uber/hermetic_cc_toolchain/releases/download/{0}/hermetic_cc_toolchain-{0}.tar.gz".format(HERMETIC_CC_TOOLCHAIN_VERSION),
    ],
)

BUILD

load("@hermetic_cc_toolchain//rules:platform.bzl", "platform_binary")

cc_binary(
    name = "hello_world",
    srcs = ["hello_world.cc"],
    visibility = ["//visibility:public"],
)

platform_binary(
    name = "linux",
    src = "hello_world",
    platform = "@hermetic_cc_toolchain//platform:linux_arm64",
)

Trying to run bazel build :linux

ERROR: error loading package '': Every .bzl file must have a corresponding package, but '@hermetic_cc_toolchain//rules:platform.bzl' does not have one. Please create a BUILD file in the same or any parent directory. Note that this BUILD file does not need to do anything except exist.

UPD 1:
I wasn't able to run the original examples as well:
cd examples/rules_cc && bazel build //...

ERROR: Analysis of target '//:hello_world' failed; build aborted:
Compilation of zig-wrapper.zig failed:
command=ZIG_LOCAL_CACHE_DIR=/tmp/zig-cache ZIG_GLOBAL_CACHE_DIR=/tmp/zig-cache ../zig build-exe -target aarch64-macos-none -mcpu=apple_a14 -fstrip -OReleaseSafe zig-wrapper.zig
return_code=1
stderr=error: FileNotFound

stdout=

You stumbled into a problem with Zig SDK that bazel-zig-cc was not able to fix.
Please file a new issue to github.com/uber/hermetic_cc_toolchain with:

  • Full output of this Bazel run, including the Bazel command.
  • Version of the Zig SDK if you have a non-default.
  • Version of hermetic_cc_toolchain

Note: this may have been ziglang/zig#14978, for
which hermetic_cc_toolchain has a workaround and you may have been "struck by
lightning" three times in a row.

UPD 2:
The same error I get now if I try to build tests, seems it can't find the downloaded zig binary.

@motiejus
Copy link
Collaborator

I am not sure rules are meant to be public. Probably not. Thoughts @linzhp ? There is nothing zig-specific in there, and, if we want to expose a zig toolchain, it should be a proper toolchain, but not this.

Note: this may have been ziglang/zig#14978, for
which hermetic_cc_toolchain has a workaround and you may have been "struck by
lightning" three times in a row.

Can you file this separately? On my end, changing the wording for this is overdue.

@motiejus motiejus reopened this Jan 30, 2024
@motiejus motiejus closed this as not planned Won't fix, can't repro, duplicate, stale Jan 30, 2024
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

No branches or pull requests

2 participants