fix(cl): handle plain char on unsigned-char targets

Đang mở
#1,150 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 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
55/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c, go
Lĩnh vực
build-system, tooling

Hướng nghiên cứu

Start with the C type mapping and macro argument generation implicated by the CXType_Char_U versus CXType_UChar distinction. Reproduce on Linux arm64 with the stated CI command, then compare generated output for cl/_testc/function and the cl/_testc/macrofn_auto/in.h fixture. Done means plain char bindings and forwarding macro string arguments generate successfully with behavior that respects target char signedness.

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

Mô tả

On Linux arm64, Clang reports plain C char as CXType_Char_U. llcppg currently maps Char_U and explicit unsigned char (CXType_UChar) together to Go uint8. This makes ordinary char * bindings incompatible with c.Str, which returns *c.Char.

Reproduction

On Linux arm64, run the existing CI command:

llgo test -v -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt ./...

The existing cl/_testc/macrofn_auto/in.h fixture contains this forwarding macro:

#define ZLIB_VERSION "1.3.1"
int deflateInit_(z_streamp strm, int level, const char *version, int stream_size);
#define z_deflateInit(strm, level) \
    deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))

Actual behavior

The const char *version parameter is mapped to *uint8, but the automatically generated macro call passes c.Str("1.3.1"), whose type is *c.Char. Generation panics because *c.Char cannot be passed as *uint8.

The generated output also differs from the existing fixtures for ordinary char * declarations. For example, cl/_testc/function produces Xprintf(fmt *uint8, ...) while the expected output uses *c.Char.

Expected behavior

Plain char bindings and string arguments in forwarding macros should work on Linux arm64 without a generation panic. Handling should account for the distinction between plain char and explicit unsigned char, as well as the target's char signedness.

Environment and evidence

Reproduced on Ubuntu 24.04 arm64 with LLVM 22, LLGo 1.0.8, Go 1.27.0, and github.com/goplus/lib v0.7.1, based on main commit b36e6307e67751c67654da37297ab654ef0ef0e3. The Linux arm64 job added in #1149 reproduces the failure: https://github.com/goplus/llcppg/actions/runs/42154256948/job/127684520612

Ngôn ngữ chính
Go
Star
40
Fork
13
Merge trung bình
2 giờ 44 phút
Pull request đã merge (30 ngày)
112

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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 goplus/llcppg

Tất cả issue của goplus/llcppg

Issue tương tự

Thêm issue về Go

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.