Builds are not reproducible: cgo snippet paths in debug info
メンテナーはふだん 1 日以内に返信
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- go
- 領域
- build-system, devtools
調査の方向性
cgo スニペットファイルがコンパイルされる builder/build.go を読み、issue が前例として挙げている builder/library.go と一時パスの扱いを比較してください。pico と examples/serial を -opt=2 と空のキャッシュで使って再現し、繰り返し生成した ELF ファイルの .debug_str に引き続き差があるか確認してください。各ビルドで cgo スニペットをコンパイルする際、一時ディレクトリが固定パスにマッピングされれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Two builds of the same program, from an empty cache, give different ELF files. The loaded sections (.text, .data and the .bss layout) are identical, but .debug_str differs, because it contains the random temporary directory of the build:
/tmp/tinygo1796750898/cgosnippet-bc020a35…-43.c
/tmp/tinygo727058795/cgosnippet-bc020a35…-43.c
Reproduce with pico, examples/serial, -opt=2, built three times with an empty cache. The three files have different SHA-256 hashes, and .debug_str differs in size by a few bytes.
builder/build.go writes each cgo header to cgosnippet-<hash>-<n>.c in the temporary directory from os.MkdirTemp("", "tinygo"), and compiles it with clang. It maps that directory to a fixed path only when -trimpath is set:
if config.TrimPath() {
flags = append(flags, compileopts.FilePrefixMap(tmpdir, config.CSourcePath(pkg.RecordedDir())))
}
Without -trimpath, clang records the random path in the debug info.
builder/library.go already solves this for library builds. It always passes -fdebug-prefix-map, with this comment: "-fdebug-prefix-map is necessary to make the output archive reproducible. Otherwise the temporary directory is stored in the archive itself, which varies each run." The cgo snippet compile needs the same treatment: map the temporary directory to a fixed path in every build, not only with -trimpath.
- 主要言語
- Go
- スター
- 17.8k
- フォーク
- 1.1k
- 平均マージ
- 1日 4時間
- マージ済み PR(30日)
- 380
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
tinygo-org/tinygo のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
tinygo-org/tinygo#6727 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
tinygo-org/tinygo#6711 ·
メンテナーはふだん 1 日以内に返信
-
Fix the targets that tinygo build -target rejects対応中かも @narguis が 2 日前に担当しました。 オープンbug good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
tinygo-org/tinygo#6617 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 62/100
tinygo-org/tinygo#6312 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
tinygo-org/tinygo#6161 ·
メンテナーはふだん 1 日以内に返信
tinygo-org/tinygo の issue をすべて見る
似ている issue
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
sresarehumantoo/cc-artex#456 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
ollama/ollama#20021 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
factory:subtask
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
release
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
github/gh-aw-mcpg#17603 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
bboerst/stratum-work#351 ·
メンテナーはふだん 1 日以内に返信