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

Fixed errors with non-absolute labels #1185

Closed
wants to merge 2 commits into from

Conversation

UebelAndre
Copy link
Collaborator

This fixes the following errors when building post #1159

Repository rule http_archive defined at:
  /private/var/tmp/_bazel_user/c4900dc498759a5aae30fdfe5c69c114/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in <toplevel>
ERROR: Analysis of target '//docs:cargo_bazel_rustdoc' failed; build aborted: no such package 'rust/settings': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
 - /Users/user/Code/cargo-bazel/rust/settings

@UebelAndre UebelAndre requested a review from hlopko March 11, 2022 19:01
@UebelAndre
Copy link
Collaborator Author

UebelAndre commented Mar 11, 2022

#1159 (comment)

Bisected to this commit, when trying to upgrade rules_rust. This triggered the following error for me:

    //proto/protobuf:protobuf_prost_generated (782077f4a782b271e6081e5d253d233307fbb065ebd24cbeda52275882be7e2c)
    //tools/prostgen:prostgen (ad7becf1f627c98f4c44ac49f5991ab41aa98662628ab4c26b029d7fb1035392)
.-> @rules_rust//util/process_wrapper:process_wrapper (ad7becf1f627c98f4c44ac49f5991ab41aa98662628ab4c26b029d7fb1035392)
|   @rules_rust//util/process_wrapper:process_wrapper_impl (ad7becf1f627c98f4c44ac49f5991ab41aa98662628ab4c26b029d7fb1035392)
|   @rules_rust//util/process_wrapper:process_wrapper_bin (ad7becf1f627c98f4c44ac49f5991ab41aa98662628ab4c26b029d7fb1035392)
`-- @rules_rust//util/process_wrapper:process_wrapper (ad7becf1f627c98f4c44ac49f5991ab41aa98662628ab4c26b029d7fb1035392)

Where the protobuf:protobuf_prost_generated target depends on the prostgen tool. This was in the host configuration. If I switched that to the exec configuration, the error went away, but it does seem like there's potentially a problem for rules that expected to be run on host.

This is also impacting this PR: https://buildkite.com/bazel/rules-rust-rustlang/builds/5643#51bcff38-d1a6-48ce-bad2-7b660b8b63a5

(19:03:32) ERROR: /workdir/util/process_wrapper/BUILD.bazel:37:12: in rust_binary rule //util/process_wrapper:process_wrapper_bin: cycle in dependency graph:
    //cargo/cargo_build_script_runner:bin_test
    //cargo/cargo_build_script_runner:cargo_build_script_runner
    //cargo/cargo_build_script_runner:cargo_build_script_output_parser
    //util/process_wrapper:process_wrapper
    //util/process_wrapper:process_wrapper_impl
.-> //util/process_wrapper:process_wrapper_bin
|   //util/process_wrapper:process_wrapper
|   //util/process_wrapper:process_wrapper_impl
`-- //util/process_wrapper:process_wrapper_bin

@UebelAndre
Copy link
Collaborator Author

@dfreese do you have a solution to the error in #1185 (comment) ?

@dfreese
Copy link
Collaborator

dfreese commented Mar 11, 2022

@dfreese do you have a solution to the error in #1185 (comment) ?

nothing concrete beyond what I mentioned in that initial comment, which I don't think directly translates. I'm trying to work on a minimally reproducible test case, but was running into the issue this PR addresses.

@dfreese
Copy link
Collaborator

dfreese commented Mar 11, 2022

@UebelAndre this is the smallest test case I could get that demonstrates the failure.

BUILD:

load("@rules_cc//cc:defs.bzl", "cc_test")
load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")

package(default_visibility = ["//visibility:private"])

# Passes
# cc_binary(
#     name = "code_generation",
#     srcs = ["code_generation.cc"],
# )
# Fails
rust_binary(
    name = "code_generation",
    srcs = ["code_generation.rs"],
)

genrule(
    name = "generated",
    srcs = [],
    outs = ["generated.h"],
    cmd = "$(location :code_generation) > $@",
    # Irrelevant to the failure, but checked both with and without.
    stamp = True,
    tools = [":code_generation"],
)

cc_test(
    name = "test_value",
    srcs = [
        "generated.h",
        "test_value.cc",
    ],
    visibility = ["//visibility:public"],
)

code_generation.rs:

fn main() {
    println!("constexpr int kTestValue = 42;");
}

code_generation.cc:

#include <iostream>

int main() {
  std::cout << "constexpr int kTestValue = 42;" << std::endl;
  return 0;
}

test_value.cc:

#include "generated.h"
int main() { return kTestValue == 42 ? 0 : 1; }
# load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# Updated 2022-03-11.  Main last updated 2022-03-11.
# http_archive(
#     name = "rules_rust",
#     sha256 = "ba638848794ff0698425e23f3cdc7c1c3cd3c1911fda720c80accbef4f0a48b6",
#     strip_prefix = "rules_rust-5e6ad9f638b5334a70ee914b63f080140020b3c4",
#     urls = [
#         "https://github.com/bazelbuild/rules_rust/archive/5e6ad9f638b5334a70ee914b63f080140020b3c4.tar.gz",
#     ],
# )

# Local repository applying PR #1185 
local_repository(
    name = "rules_rust",
    path = "../rules_rust",
)

load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")

rules_rust_dependencies()

rust_register_toolchains()

With that I see the following error. It looks the same on version 4.0.0 and 4.2.1.

someone@somewhere:~/cycle_example$ bazel-5.0.0 test //...
ERROR: /home/viz/.cache/bazel/_bazel_viz/1e97f2cc96b4e28933552bb1116a0892/external/rules_rust/util/process_wrapper/BUILD.bazel:7:6: in alias rule @rules_rust//util/process_wrapper:process_wrapper: cycle in dependency graph:
    //:generated (28ff57593ba01d914893f9cd455c859110ce813ccf3771961541220915f453dc)
    //:code_generation (ad7becf1f627c98f4c44ac49f5991ab41aa98662628ab4c26b029d7fb1035392)
.-> @rules_rust//util/process_wrapper:process_wrapper (ad7becf1f627c98f4c44ac49f5991ab41aa98662628ab4c26b029d7fb1035392)
|   @rules_rust//util/process_wrapper:process_wrapper_impl (ad7becf1f627c98f4c44ac49f5991ab41aa98662628ab4c26b029d7fb1035392)
|   @rules_rust//util/process_wrapper:process_wrapper_bin (ad7becf1f627c98f4c44ac49f5991ab41aa98662628ab4c26b029d7fb1035392)
`-- @rules_rust//util/process_wrapper:process_wrapper (ad7becf1f627c98f4c44ac49f5991ab41aa98662628ab4c26b029d7fb1035392)
ERROR: Analysis of target '//:generated' failed; build aborted
INFO: Elapsed time: 0.258s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded, 3 targets configured)
FAILED: Build did NOT complete successfully (1 packages loaded, 3 targets configured)

@dfreese
Copy link
Collaborator

dfreese commented Mar 12, 2022

I put together this #1187, which fixes both problems, I think.

@UebelAndre
Copy link
Collaborator Author

This change was addressed by #1187

@UebelAndre UebelAndre closed this Mar 12, 2022
@UebelAndre UebelAndre deleted the label branch March 12, 2022 22:24
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.

2 participants