Proposal: Use llarhub/libc as the default platform-specific C standard library

Đang mở
#1,144 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ó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
28/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c, cpp, go
Lĩnh vực
build-system, tooling

Hướng nghiên cứu

Read the dependency resolver and header lookup behavior described in the issue, along with the platform-specific layout from #1125. Trace how standard headers map to Go types through the existing github.com/goplus/lib/c association. Done means target-specific llarhub/libc headers are selected consistently, with clear handling for unavailable targets, explicit Stdlib, and generating libc itself.

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

Mô tả

proposal

Summary

Make github.com/llarhub/libc a default dependency when llcppg parses C/C++ headers, and select its headers for the requested GOOS and GOARCH. This builds on the platform-specific layout in #1125.

Motivation

When Stdlib is empty, llcppg currently discovers the host Clang's standard include directories. A platform-specific conversion can pass a different target to libclang while still adding those host directories. For example, generating Linux ARM64 bindings on a Linux AMD64 host may encounter host system headers instead of the target's headers.

When generating for a different target, projects currently must prepare and configure matching standard-library headers themselves to avoid relying on host headers. A default libc dependency would make the target header source consistent across projects and avoid repeating that configuration.

Proposal

Use llarhub/libc as an implicit dependency for header parsing, without requiring every project to add libc to Deps. Resolve its include directory for the selected target platform. For the same target and libc version, the selected libc headers should not depend on the machine running llcppg.

For example, given a platform-specific project containing:

#include <sys/types.h>

struct file_info {
    off_t offset;
};
Target libc header used for <sys/types.h>
linux/amd64 libc/c/linux-amd64/include/sys/types.h
linux/arm64 libc/c/linux-arm64/include/sys/types.h
darwin/arm64 libc/c/darwin-arm64/include/sys/types.h

These paths illustrate the current platform directories in llarhub/libc. The target selection follows #1125; the same Linux host can request Linux ARM64 or Darwin ARM64 generation.

Current limitations

The current dependency resolver appends include to the dependency's C module directory and does not select a platform subdirectory. Separately, standard headers are associated with github.com/goplus/lib/c by the current generator. Defaulting to llarhub/libc therefore needs to account for both header lookup and the Go types associated with those headers.

The libc repository currently contains linux-amd64, linux-arm64, and darwin-arm64 C header directories; darwin-amd64 is not present in its c branch.

Open questions

  • How should llcppg select the libc version and handle a target whose headers are unavailable?
  • How should the default dependency work when generating llarhub/libc itself?
  • How should it interact with an explicitly configured Stdlib and the existing github.com/goplus/lib/c type mappings?
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.