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

invalid registered toolchain '@rules_foreign_cc//toolchains:preinstalled_nmake_toolchain': No repository visible as '@rules_foreign_cc' from main repository #1239

Closed
dmitry-j-mikhin opened this issue Jul 30, 2024 · 9 comments · Fixed by #1264 · May be fixed by #1241

Comments

@dmitry-j-mikhin
Copy link
Contributor

I have simple Bazel module
MODULE.bazel:

module(
    name = "libxml2",
    version = "2.13.3",
    compatibility_level = 1,
)
bazel_dep(name = "rules_foreign_cc", version = "0.11.1")

BUILD.bazel:

""" Builds libxml2.
"""

load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")

filegroup(
    name = "srcs",
    srcs = glob(["**"]),
)

cache_entries = {
    "CMAKE_POSITION_INDEPENDENT_CODE": "ON",
    "BUILD_SHARED_LIBS": "OFF",
    #libxml2 specific options.
    "LIBXML2_WITH_PYTHON": "OFF",
    "LIBXML2_WITH_LZMA": "OFF",
    "LIBXML2_WITH_TESTS": "OFF",
    "LIBXML2_WITH_PROGRAMS": "OFF",
}

cmake(
    name = "libxml2",
    env = {"CMAKE_BUILD_TYPE": "Release"},
    lib_source = ":srcs",
    cache_entries = cache_entries,
    out_include_dir = "include/libxml2",
    visibility = ["//visibility:public"],
)

This module compiles successfully on Linux and macOS. But on Windows the following error occurs:

bazel --output_user_root=C:/b build --show_progress_rate_limit=5 --curses=yes --color=yes --terminal_columns=143 --show_timestamps --verbose_failures --jobs=30 --announce_rc --experimental_repository_cache_hardlinks --disk_cache= --remote_cache=remotebuildexecution.googleapis.com --remote_instance_name=projects/bazel-untrusted/instances/default_instance --google_default_credentials --bes_backend=buildeventservice.googleapis.com --bes_timeout=360s --project_id=bazel-untrusted --remote_timeout=60 --remote_max_connections=200 --remote_default_platform_properties=properties:{name:"cache-silo-key" value:"1d5ec805093884c76b310cf26aeb82ee568b9359f72bef33e0bc82eff4360c80"} --remote_download_toplevel --test_env=LocalAppData --test_env=BAZELISK_USER_AGENT --test_env=USE_BAZEL_VERSION -- @libxml2//:libxml2
(16:48:01) WARNING: Option 'project_id' is deprecated: Use --bes_instance_name instead
(16:48:01) WARNING: Option 'remote_default_platform_properties' is deprecated: --remote_default_platform_properties has been deprecated in favor of --remote_default_exec_properties.
(16:48:01) INFO: Invocation ID: 0f7cc2aa-16f9-4098-a3fb-4d089a40eca6
(16:48:01) INFO: Options provided by the client:
  Inherited 'common' options: --isatty=0 --terminal_columns=80
(16:48:01) INFO: Options provided by the client:
  'build' options: --python_path=C:/python3/python.exe
(16:48:01) INFO: Reading rc options for 'build' from c:\b\bk-windows-326v\bazel-org-repo-root\.bazelrc:
  'build' options: --experimental_enable_bzlmod --registry=file:///c:/b/bk-windows-326v/bazel/bcr-presubmit
(16:48:01) INFO: Current date is 2024-07-30
(16:48:01) WARNING: Option 'project_id' is deprecated: Use --bes_instance_name instead
(16:48:01) WARNING: Option 'remote_default_platform_properties' is deprecated: --remote_default_platform_properties has been deprecated in favor of --remote_default_exec_properties.
(16:48:12) ERROR: C:/b/wd2wermq/external/rules_foreign_cc~/toolchains/private/BUILD.bazel:158:15: While resolving toolchains for target @@rules_foreign_cc~//toolchains/private:pkgconfig_tool_msvc_build_ (538d53d): invalid registered toolchain '@rules_foreign_cc//toolchains:preinstalled_nmake_toolchain': No repository visible as '@rules_foreign_cc' from main repository
(16:48:12) ERROR: Analysis of target '@@libxml2~//:libxml2' failed; build aborted: Analysis failed
(16:48:12) INFO: Elapsed time: 11.979s, Critical Path: 0.05s
(16:48:12) INFO: 1 process: 1 internal.
(16:48:12) ERROR: Build did NOT complete successfully
(16:48:12) FAILED:
    Fetching repository @@rules_foreign_cc~~tools~cmake-3.23.2-windows-x86_64; starting 5s
    Fetching C:/b/wd2wermq/external/rules_foreign_cc~~tools~cmake-3.23.2-windows-x86_64; Extracting cmake-3.23.2-windows-x86_64.zip 4s
bazel build failed with exit code 1
🚨 Error: The command exited with status 1
user command error: exit status 1

Full logs are available here - https://buildkite.com/bazel/bcr-presubmit/builds/6949#0191048a-50a6-4826-8e5c-68d888cca6f1
Related discussion in BCR - bazelbuild/bazel-central-registry#2512

@meteorcloudy
Copy link
Contributor

/cc @jsharpe

@dmitry-j-mikhin
Copy link
Contributor Author

I will also try to debug this issue deeper. But I need time to prepare the Windows development environment first.

@meteorcloudy
Copy link
Contributor

@dmitry-j-mikhin Can you try to verify if #1241 fix the issue?

@meteorcloudy
Copy link
Contributor

OK, looks like we need to fix the type of https://github.com/bazelbuild/rules_foreign_cc/blob/fb209674f326b7020f64d5d022cbe7fa16f3209c/foreign_cc/private/transitions.bzl#L28, make it accept label_list instead of string_list. @dmitry-j-mikhin Do you mind digging into it? It's a bit more involved than I thought.

@dmitry-j-mikhin
Copy link
Contributor Author

Yep, I'm digging)

@dmitry-j-mikhin
Copy link
Contributor Author

Can you try to verify if #1241 fix the issue?

+ bazel build -c dbg //:hello_world_bin
ERROR: C:/msys64/home/mikhin/_bazel_mikhin/e6sjlh7b/external/rules_foreign_cc~/toolchains/private/BUILD.bazel:158:15: @@rules_foreign_cc~//
toolchains/private:pkgconfig_tool_msvc_build: expected value of type 'string' for element 0 of attribute 'extra_toolchains' in 'extra_toolc
hains_transitioned_foreign_cc_target' rule, but got Label("@@rules_foreign_cc~//toolchains:preinstalled_nmake_toolchain") (Label)
ERROR: C:/msys64/home/mikhin/_bazel_mikhin/e6sjlh7b/external/rules_foreign_cc~/toolchains/private/BUILD.bazel:158:15: @@rules_foreign_cc~//
toolchains/private:pkgconfig_tool_msvc_build: missing value for mandatory attribute 'extra_toolchains' in 'extra_toolchains_transitioned_fo
reign_cc_target' rule
ERROR: C:/msys64/home/mikhin/_bazel_mikhin/e6sjlh7b/external/rules_foreign_cc~/toolchains/private/BUILD.bazel:164:22: Cannot compute config
 conditions
ERROR: C:/msys64/home/mikhin/_bazel_mikhin/e6sjlh7b/external/libxml2~/BUILD.bazel:21:6: Target '@@libxml2~//:libxml2' depends on toolchain
'@@rules_foreign_cc~//toolchains/private:built_pkgconfig', which cannot be found: Target '@@rules_foreign_cc~//toolchains/private:built_pkg
config' contains an error and its package is in error'
ERROR: Analysis of target '//:hello_world_bin' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.449s, Critical Path: 0.02s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
FAILED:
    Fetching repository @@rules_perl~~perl_repositories~perl_windows_x86_64; Downloading perl
    Fetching repository @@rules_python~~python~python_3_11_x86_64-pc-windows-msvc; starting
    Fetching repository @@rules_foreign_cc~~tools~cmake-3.23.2-windows-x86_64; starting

@dmitry-j-mikhin
Copy link
Contributor Author

It's a bit more involved than I thought

image

dmitry-j-mikhin added a commit to dmitry-j-mikhin/rules_foreign_cc that referenced this issue Aug 2, 2024
full_label(name + "_fg") may produce different result then (name + "_fg")
(name + "_fg") is used in srcs attr, so we make cmd attr to use the same
value.
dmitry-j-mikhin added a commit to dmitry-j-mikhin/rules_foreign_cc that referenced this issue Aug 2, 2024
on Windows rules_cc are called
dmitry-j-mikhin added a commit to dmitry-j-mikhin/rules_foreign_cc that referenced this issue Aug 2, 2024
dmitry-j-mikhin added a commit to dmitry-j-mikhin/rules_foreign_cc that referenced this issue Aug 3, 2024
dmitry-j-mikhin added a commit to dmitry-j-mikhin/rules_foreign_cc that referenced this issue Aug 3, 2024
@dmitry-j-mikhin
Copy link
Contributor Author

dmitry-j-mikhin added a commit to dmitry-j-mikhin/rules_foreign_cc that referenced this issue Aug 19, 2024
This fix error message like this in case of bzlmod usage:
invalid registered toolchain '@rules_foreign_cc//toolchains:preinstalled_nmake_toolchain': No repository visible as '@rules_foreign_cc' from main repository
dmitry-j-mikhin added a commit to dmitry-j-mikhin/rules_foreign_cc that referenced this issue Aug 19, 2024
This fix following error:
The repository '@@[unknown repo 'rules_cc' requested from @@rules_foreign_cc~~tools~glib_dev]' could not be resolved: No repository visible as '@rules_cc' from repository '@@rules_foreign_cc~~tools~glib_dev'. and referenced by '@@rules_foreign_cc~//toolchains/private:pkgconfig_tool_msvc_build_'
@dmitry-j-mikhin
Copy link
Contributor Author

@jsharpe I created a clean PR that fixes this bug - #1264
I tested it here - bazelbuild/bazel-central-registry#2512

dmitry-j-mikhin added a commit to dmitry-j-mikhin/rules_foreign_cc that referenced this issue Aug 19, 2024
This fix following error:
The repository '@@[unknown repo 'rules_cc' requested from @@rules_foreign_cc~~tools~glib_dev]' could not be resolved: No repository visible as '@rules_cc' from repository '@@rules_foreign_cc~~tools~glib_dev'. and referenced by '@@rules_foreign_cc~//toolchains/private:pkgconfig_tool_msvc_build_'
dmitry-j-mikhin added a commit to dmitry-j-mikhin/rules_foreign_cc that referenced this issue Aug 28, 2024
This fix error message like this in case of bzlmod usage:
invalid registered toolchain '@rules_foreign_cc//toolchains:preinstalled_nmake_toolchain': No repository visible as '@rules_foreign_cc' from main repository
dmitry-j-mikhin added a commit to dmitry-j-mikhin/rules_foreign_cc that referenced this issue Aug 31, 2024
This fix error message like this in case of bzlmod usage:
invalid registered toolchain '@rules_foreign_cc//toolchains:preinstalled_nmake_toolchain': No repository visible as '@rules_foreign_cc' from main repository
jsharpe pushed a commit that referenced this issue Sep 4, 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
2 participants