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

オープン
#1,144 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
28/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
c, cpp, go

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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?
主要言語
Go
スター
40
フォーク
13
平均マージ
2時間 22分
マージ済み PR(30日)
125

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

goplus/llcppg のほかの issue

goplus/llcppg の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。