Skip to content

system_includes をロケール非依存にする#90

Merged
TwoSquirrels merged 2 commits into
mainfrom
fix/system-includes-locale
Jul 13, 2026
Merged

system_includes をロケール非依存にする#90
TwoSquirrels merged 2 commits into
mainfrom
fix/system-includes-locale

Conversation

@TwoSquirrels

@TwoSquirrels TwoSquirrels commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Fixes #73

背景

compiler.rssystem_includesgcc -v (または clang) の標準エラーを #include <...> search starts here: / End of search list. という英語の目印文字列でパースしている。LC_ALL/LANGUAGE 等を固定していないため、これらの文字列が翻訳される環境では検出が失敗しうる、という理論上の懸念に対する予防的な修正。

実機確認の結果 (Issue のコメント参照): Ubuntu 24.04 (WSL2) の gcc 14.2.0 + language-pack-ja では、該当メッセージの日本語訳が未整備で再現せず、clang++ 18.1.3 は多言語化機構自体を持たないため常に英語出力だった。したがって「今まさに壊れている」ケースの実機確認はできていないが、翻訳が進んだ将来の gcc や、翻訳カタログの充実度が異なる他ディストリでは起こり得るため、LC_ALL=C/LANGUAGE=C を明示する対処自体はほぼ無害な予防的ハードニングとして採用する。

変更内容

  • system_includes のコンパイラ起動時に LC_ALL=C / LANGUAGE=C を設定する。

テスト

  • system_includes_forces_the_c_locale を追加。偽コンパイラが LC_ALL/LANGUAGE の値を見て、C でなければ翻訳済みの目印文字列を返すようにし、呼び出し側が明示的にロケールを固定していることを確認する。
  • 修正前のコードに対してこのテストが実際に失敗する (このマシンの ambient ロケールで目印が一致せず検出に失敗する) ことを手元で確認済み。
  • cargo fmt --check / cargo clippy --all-targets --all-features -- -D warnings / cargo test --all-features すべて通過。

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved compiler include-directory detection in non-English locales.
    • Ensures include paths are parsed consistently regardless of the system language or locale settings.

gcc/clang の -v 出力を英語固定の目印文字列でパースしているため、
LANG/LC_ALL 等が英語以外のロケールカタログを指す環境では出力が
翻訳されてパースに失敗し、std の登録 (自動セットアップ含む) が
失敗しうる (#73)。LC_ALL/LANGUAGE を C に固定して回避する。
偽コンパイラで LC_ALL/LANGUAGE が C でなければ翻訳済みの目印文字列を
返すようにし、呼び出し側が明示的にロケールを固定していることを確かめる。
修正前のコードに対しては実際に失敗する (ambient ロケールが C でない
環境で目印が一致せず検出に失敗する) ことを手元で確認済み。
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7a5b7c78-45bc-47b6-a465-7ef511d69813

📥 Commits

Reviewing files that changed from the base of the PR and between 7dc0b29 and b30606a.

📒 Files selected for processing (1)
  • src/compiler.rs

📝 Walkthrough

Walkthrough

system_includes now invokes the compiler with LC_ALL and LANGUAGE set to C. A Unix test uses locale-dependent fake compiler output to verify that include-directory parsing remains successful.

Changes

Locale-independent include discovery

Layer / File(s) Summary
Force the compiler locale and test parsing
src/compiler.rs
system_includes sets LC_ALL and LANGUAGE to C, and the Unix test verifies include-directory parsing with locale-dependent compiler markers.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: making system_includes locale-independent.
Linked Issues check ✅ Passed The PR sets compiler locale env vars to C and adds a test, matching issue #73's requirement to parse compiler output independent of locale.
Out of Scope Changes check ✅ Passed The changes stay focused on locale handling in system_includes and its regression test, with no obvious unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/system-includes-locale

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@TwoSquirrels TwoSquirrels marked this pull request as ready for review July 13, 2026 20:32
@TwoSquirrels

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@TwoSquirrels TwoSquirrels merged commit 52db22d into main Jul 13, 2026
10 checks passed
@TwoSquirrels TwoSquirrels deleted the fix/system-includes-locale branch July 13, 2026 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

system_includes がロケール非依存でないため、非英語ロケールで add-std が失敗しうる

1 participant