rust.toolchain(strip_level = ...) is silently ignored

Đang mở Phù hợp với người mới
#4,223 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
rust
Lĩnh vực
build-system

Hướng nghiên cứu

Bắt đầu trong rust/private/repositories.bzl và theo dõi cách rust_register_toolchains chuyển tiếp strip_level đến rust_repository_set. So sánh với cách xử lý opt_level_by_triple hiện có và xác minh rằng cấu hình fastbuild tạo ra thiết lập strip được yêu cầu trong các đối số của tác vụ Rustc, thay vì strip=none.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

The rust.toolchain tag's strip_level dict is keyed by compilation mode, but rust_register_toolchains forwards it unchanged to rust_repository_set, which looks it up by target triple (strip_level.get(toolchain.target_triple)) and finds nothing, so the setting is dropped without an error. opt_level from the same tag had the same problem and was fixed by re-keying (opt_level_by_triple in rust/private/repositories.bzl); strip_level needs the same treatment.

$ bazel --version
bazel 9.2.0
$ cat MODULE.bazel
bazel_dep(name = "rules_rust", version = "0.73.0")

rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
rust.toolchain(
    edition = "2021",
    opt_level = {"dbg": "0", "fastbuild": "1", "opt": "3"},
    strip_level = {"fastbuild": "debuginfo"},
    versions = ["1.92.0"],
)
use_repo(rust, "rust_toolchains")
register_toolchains("@rust_toolchains//:all")
$ cat BUILD.bazel
load("@rules_rust//rust:defs.bzl", "rust_binary")

rust_binary(
    name = "hello",
    srcs = ["src/main.rs"],
)
$ echo 'fn main() {}' > src/main.rs
$ bazel aquery 'mnemonic("Rustc", //:hello)' | grep -oE -- '--codegen=(opt-level|strip)=[^ ]*'
--codegen=opt-level=1
--codegen=strip=none

opt_level from the same tag lands in the argv; strip_level = {"fastbuild": "debuginfo"} does not (strip=none is the fastbuild default).

Ngôn ngữ chính
Starlark
Star
854
Fork
684
Merge trung bình
2 ngày 22 giờ
Pull request đã merge (30 ngày)
21

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của bazelbuild/rules_rust

Tất cả issue của bazelbuild/rules_rust

Issue tương tự

Thêm issue về Build System

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.