Nonzero pointer address spaces are silently erased in generated bindings and static wrappers
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
Hướng nghiên cứu
Tái hiện vấn đề với input.h, lệnh gọi bindgen được hiển thị, cùng các đầu ra được tạo của bindings.rs và wrapper. Theo dõi cách các không gian địa chỉ khác không được biểu diễn trong các khai báo Rust được tạo và các wrapper C cho hàm static. Hoàn tất nghĩa là đầu ra giữ lại không gian địa chỉ ở nơi được hỗ trợ, hoặc chẩn đoán và bỏ qua một khai báo Rust không thể biểu diễn, đồng thời Clang chấp nhận wrapper.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Input C/C++ Header
static inline int __attribute__((address_space(1))) *
phase8_as1_identity(
int __attribute__((address_space(1))) *value
) {
return value;
}
Clang accepts this declaration on the target used below. The function takes
and returns an address space 1 pointer.
Bindgen Invocation
$ bindgen input.h \
--wrap-static-fns \
--wrap-static-fns-path wrapper \
--rust-target 1.75 \
--no-layout-tests \
--no-rustfmt-bindings \
--output bindings.rs
Actual Results
The generated Rust declaration silently uses ordinary pointers:
extern "C" {
#[link_name = "phase8_as1_identity__extern"]
pub fn phase8_as1_identity(
value: *mut ::std::os::raw::c_int,
) -> *mut ::std::os::raw::c_int;
}
The generated C wrapper drops the address space too:
int *phase8_as1_identity__extern(int *value) {
return phase8_as1_identity(value);
}
Clang rejects that wrapper:
error: passing 'int *' to parameter of type
'__attribute__((address_space(1))) int *' changes address space of pointer
The two declarations also lower to different LLVM function types. These are
the signatures from the tools listed below:
; clang-15, correct C wrapper
define dso_local i32 addrspace(1)* @phase8_as1_identity__extern(
i32 addrspace(1)* %value)
; rustc 1.75, caller using the generated binding
declare noundef ptr @phase8_as1_identity__extern(ptr noundef)
Expected Results
Bindgen should not emit an ordinary pointer for a nonzero address space.
The C wrapper can preserve the source declaration:
int __attribute__((address_space(1))) *
phase8_as1_identity__extern(
int __attribute__((address_space(1))) *value
) {
return phase8_as1_identity(value);
}
Stable Rust does not have a general source-level pointer type for arbitrary
LLVM address spaces. If the selected Rust output cannot represent this type,
I would expect bindgen to diagnose it and omit the misleading declaration
instead of changing it to *mut c_int.
Environment
bindgen current main: 9d26c6eddeff9192ddedb563192abe3128fc5aae
bindgen release: 0.72.1
clang: 15.0.7
rustc: 1.75.0
target: x86_64-unknown-linux-gnu
Current main and 0.72.1 both generate the same invalid wrapper at O0 and O2.
- Ngôn ngữ chính
- Rust
- Star
- 5.3k
- Fork
- 846
- Merge trung bình
- 2 ngày 6 giờ
- Pull request đã merge (30 ngày)
- 11
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rust-lang/rust-bindgen
-
--enable-cxx-namespaces panics on namespace [[deprecated]] { ("[" is not a valid Ident)Có thể đã có người làm @lwz23 đã nhận 49 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
rust-lang/rust-bindgen#3485 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
rust-lang/rust-bindgen#3483 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
rust-lang/rust-bindgen#3370 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
rust-lang/rust-bindgen#3363 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
rust-lang/rust-bindgen#3540 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của rust-lang/rust-bindgen
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
swc-project/swc-ai-issues#432 ·
-
SPLADE `/embed_sparse` output depends on the other inputs in the batch (candle BertModel / DistilBertModel)Có thể đã có người làm @0z5a đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
huggingface/text-embeddings-inference#979 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
servo/rust-smallvec#874 ·
-
Expression with ill-formed typeĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 94/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 2 ngày