본문으로 건너뛰기
cccskills
무료GitHub에 공개한국어 소개

Toolchain development

Carbon 컴파일러 도구 체인의 구조와 처리 단계를 살펴보고, 빌드·테스트·디버깅을 진행하는 방법을 안내합니다. 진단과 오류 처리, 구현 관례, 테스트 기대 출력 갱신 방법도 다룹니다.

원문원문 설명 보기

Instructions for checking, building, debugging, and understanding the Carbon toolchain.

carbon-language/carbon-lang스타 33,929(GitHub 33,929 + cccskills 0)

실행 점수 미검증

설치 방법 보기

이럴 때 유용합니다

  • 컴파일러 단계별 구현 위치 찾기
  • Carbon 컴파일러 빌드와 테스트
  • 컴파일러 충돌 원인 조사
  • 변경 후 테스트 기대 출력 갱신

한국어 소개

할 수 있는 일

이 스킬은 Carbon 컴파일러 도구 체인의 구성과 처리 흐름을 설명합니다. 어휘 분석, 구문 분석, 의미 검사, LLVM IR로의 변환 단계가 각각 어떤 역할을 하는지 살펴보고, 관련 디렉터리와 정의 파일, 처리 핸들러의 위치를 안내합니다. 코드 변경 시 따를 구현 관례와 bazelisk를 이용한 빌드 및 테스트, 실패 원인 디버깅, 진단 메시지와 오류 처리 방식도 다룹니다. 컴파일러 동작을 바꾼 뒤 테스트 기대 출력을 전용 스크립트로 갱신하는 방법도 안내합니다.

이럴 때 유용합니다

Carbon 도구 체인을 처음 수정하거나 기존 구현의 위치와 처리 단계를 파악할 때 참고할 수 있습니다. 테스트 실행 방법을 확인하거나 충돌 원인을 조사할 때, LLVM API와 기존 데이터 구조를 활용하는 방침을 살펴볼 때도 유용합니다. 언어 서버와 내장 함수처럼 별도 스킬에서 다루는 영역도 구분해 줍니다.

사용 예시

  • “이 구문 분석 로직이 도구 체인의 어느 단계에 구현되어 있는지 찾아 주세요.”
  • “컴파일러 변경에 해당하는 테스트를 실행하고 기대 출력을 갱신해 주세요.”
  • “이 충돌의 원인을 조사하는 디버깅 절차를 알려 주세요.”

주의 사항

Carbon 도구 체인을 위한 지침입니다. 빌드와 테스트에는 bazelisk를 사용하고, 테스트 출력 갱신에는 ./toolchain/autoupdate_testdata.py를 사용합니다. 언어 서버, 진단, 내장 함수 작업에는 각각 별도의 스킬을 참고하도록 안내합니다.

이 소개문은 공개된 SKILL.md를 바탕으로 AI(OpenAI Codex)가 작성했습니다. 정확한 사양은 아래 원문을 확인하세요.

문서 점검

AI가 SKILL.md의 내용에서 주의가 필요한 작업과 도입 전제를 확인했습니다. 점수는 실제로 실행한 결과(실행 검증)만으로 매깁니다.

안전성전송·삭제·명령 실행 등을 명시하고 있는가
A양호자료는 빌드, 테스트, 조사 작업을 다루며 기록 변경이나 외부 전송은 없습니다.
도입의 용이성필요한 도구나 API 키가 적고 적혀 있는가
B일부 부족빌드와 테스트에 `bazelisk`를 사용한다고 하지만 설치 절차는 없습니다.

점수에는 넣지 않았습니다. 2026년 10월 26일 기준으로 AI(OpenAI Codex)가 판정했습니다. 참고용이므로 설치 전에 원문도 확인해 주세요.

평가가 다르다고 생각되면 재검토를 요청하기

어느 항목이 왜 다르다고 생각하는지 적어 주세요. 로그인은 필요 없습니다. SKILL.md와 대조해 평가를 다시 만들고 이곳에 반영합니다.

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

포함된 파일(1)

  • SKILL.md7.6 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Toolchain development

<!-- Part of the Carbon Language project, under the Apache License v2.0 with LLVM Exceptions. See /LICENSE for license information. SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -->

Toolchain structure

  • Under toolchain/:
    • base/: Base infrastructure and common utilities.
    • check/: Semantic analysis (SemIR generation).
    • lex/: Lexing (Source -> Tokens).
    • lower/: Lowering to LLVM IR.
    • parse/: Parsing (Token -> Parse Tree).
    • sem_ir/: Semantic Intermediate Representation (SemIR) definitions.

Toolchain architecture

  • Documentation: Refer to toolchain/docs for detailed architecture design and patterns.
    • Refer to Toolchain Idioms for a comprehensive list of patterns (for example, ValueStore, formatting .def files, struct reflection) used throughout the implementation.
  • Builtin Functions: Refer to the Builtin functions skill (SKILL.md) for guidelines on registering, mapping, constant evaluating, and lowering compiler builtin primitives (e.g. "int.convert_float").
  • Language server: Refer to the Language server skill (SKILL.md) before working on toolchain/language_server/ or utils/vscode/. Neither follows the patterns described here.
  • Phases: Lex -> Parse -> Check -> Lower.
  • Definitions: Many kinds (tokens, parse nodes, SemIR instructions) are defined in .def files and expanded by way of macros.
  • Handlers:
    • Parser: Handle<StateName> in parse/handle_*.cpp.
    • Checker: HandleParseNode in check/handle_*.cpp.
    • Lowering: HandleInst in lower/handle_*.cpp.
  • Iteration: Prefer iterative algorithms over recursive ones to prevent stack exhaustion on complex codebases.

Essential commands

  • Test everything: bazelisk test //...
  • Test specific target: bazelisk test //toolchain/testing:file_test
  • Test specific file: bazelisk test //toolchain/testing:file_test --test_arg=--file_tests=<path_to_carbon_file>
  • Build toolchain: bazelisk build //toolchain/...

Updating test data

Carbon tests often use file_test (for example, //toolchain/testing/file_test). For detailed guidelines on authoring tests, including file splits, naming conventions (fail_, todo_), and generating minimal output with SemIR dumps, please refer to the Toolchain tests skill.

If you change compiler behavior, you likely need to update expected test outputs. Do not manually edit thousands of lines of expected output. Use the script:

./toolchain/autoupdate_testdata.py
# Or for a specific file:
./toolchain/autoupdate_testdata.py toolchain/check/testdata/my_test.carbon

Debugging and diagnostics

  • Compiler Diagnostics: Refer to the Diagnostics skill (SKILL.md) for strict rules on declaring, formatting, emitting, testing, and styling compiler diagnostic messages (errors, warnings, notes).
  • Printing to stderr: Use llvm::errs() << "debug info\n";.
    • Avoid std::cout (it may interfere with tool output).
  • SemIR Stringification:
    • SemIR objects often have a Print method or operator<<.
    • inst.Print(llvm::errs())
  • Debugging Crashes:
    • Bazel sandboxing can hide artifacts. Use --sandbox_debug if needed, but often running the binary directly from bazel-bin/ is easier for debugging.

Error handling

  • No exceptions: Do not use C++ exceptions.
  • ErrorOr<T>: Return ErrorOr<T> for fallible operations.
    • Check with if (auto result = Function(); result) { Use(*result); }
  • llvm::Expected<T>: Similar to ErrorOr, used when interfacing with LLVM.

Context-Aware Diagnostics

When declaring and emitting errors, ensure semantic wording matches the exact context:

  • Semantic Precision: Do not reference "types" when raising errors for unsized expressions like IntLiteral or FloatLiteral. For example, use RealLiteralTooLargeForUnsizedInt instead of a diagnostic referencing an "integer type".
  • Wording Consistency: Before declaring a new diagnostic in kind.def, search for existing diagnostics in the targeted implementation files (for example, other uses of MaxIntWidth) to align message structures and parameter expectations.

Casting (LLVM style)

  • Use llvm::cast<T>(obj) (checked, asserts on failure).
  • Use llvm::dyn_cast<T>(obj) (returns null on failure).
  • Use llvm::isa<T>(obj) (boolean check).
  • Avoid dynamic_cast and standard RTTI.

Leverage LLVM APIs

Before implementing custom algorithms for mathematical, logical, or bitwise operations, inspect target LLVM ADT class APIs:

  • Builtin APIs: Verify if LLVM classes (such as APInt, APFloat, or APSInt) already offer native equivalents (for example, .pow(), ilogb(), .changeSign(), convertFromAPInt()). Avoid duplicate, naive, or inefficient custom loops.

Data structures

  • Prefer APIs in common/ and toolchain/base/ over LLVM ADTs. For example, use Map instead of llvm::DenseMap.
  • If no Carbon API exists, prefer LLVM ADTs over standard library ones (for example llvm::SmallVector, llvm::StringRef).
  • StringRef is a view; be careful with lifetimes.

Common pitfalls

  1. Legacy explorer references: The explorer prototype has been moved. Ignore references to it in proposals or old docs; focus on toolchain.
  2. Manually updating test files: Always check if autoupdate_testdata.py can do it for you.
  3. Using std::string unnecessarily: Prefer llvm::StringRef for arguments.
  4. Header includes: Use specific include orders (often enforced by clang-format).
  5. Parse node order: Semantics processes parse nodes in post-order; ensure your parser transitions support this.
  6. Builtin implementation gaps: If adding a primitive builtin function, make sure you address all phases of the lifecycle: macro definition registration, signature validation, compile-time constant evaluation (interpreter), LLVM IR lowering, and prelude modular implementation bindings (avoiding orphan rules). Refer to the Builtin functions skill (SKILL.md) for details.
  7. Premature helper abstraction: Avoid extracting tiny helper functions that are called from exactly one place and do not significantly modularize complex code. Prefer inlining directly to keep the implementation compact, readable, and localized.
  8. Redundant bounds calculations: Avoid repeating calculations of complex boundary estimations (such as lower and upper bound estimations). Refactor the logic to calculate unified values once, preserving compactness.
  9. Trusting stale clangd diagnostics: In-editor diagnostics are only as good as compile_commands.json. If it predates a newly added file, clangd falls back to a default command and reports nonsense, such as missing standard headers or "no member named None". Regenerate it with ./scripts/create_compdb.py, which only takes a few seconds.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Accessing GitHub issues

무료요약 있음

명령줄의 `gh`로 GitHub 이슈 본문과 댓글을 읽기 전용으로 확인하는 방법을 안내합니다. 번호나 URL로 이슈를 찾고 다른 저장소를 지정하는 방법, 댓글이 많은 경우 JSON과 `jq`로 내용을 추출하는 방법을 다룹니다.

  • 이슈 본문과 댓글 읽기
  • URL로 이슈 내용 확인
  • 다른 저장소의 이슈 조회
carbon-language/carbon-lang3.4만2026년 10월 26일 업데이트

Agent tools

무료요약 있음

Carbon 저장소에서 일하는 AI 도우미가 전용 환경 도구로 파일을 읽고 검색하고 편집하는 규칙을 안내합니다. 임시 파일을 둘 위치와 삭제 시점, 사용자 지정 프로그램을 허용하는 경우도 설명합니다.

  • 정해진 도구로 Carbon 파일 검색
  • 파일 변경에 맞는 전용 도구 선택
  • 임시 파일 위치와 삭제 규칙 확인
carbon-language/carbon-lang3.4만2026년 10월 26일 업데이트

Bazel usage

무료요약 있음

Carbon 프로젝트에서 Bazelisk로 빌드, 테스트, 실행하는 기본 절차를 안내합니다. 대상을 지정한 검증, ASan 활성화, 시스템 의존성 변경 후 캐시 재생성도 다룹니다.

  • Carbon 코드 빌드
  • 변경 사항과 관련된 테스트 실행
  • Bazel로 빌드한 프로그램 실행
carbon-language/carbon-lang3.4만2026년 10월 26일 업데이트

Builtin functions

무료요약 있음

Carbon 컴파일러에 내장 함수를 추가하는 절차를 안내합니다. 함수 등록과 시그니처 검증부터 상수 평가, 런타임 호출의 LLVM IR 생성, Prelude 연결, 최소 Prelude를 이용한 개별 테스트까지 다룹니다.

  • 내장 함수 등록
  • 상수 평가 구현
  • LLVM IR 생성 추가
carbon-language/carbon-lang3.4만2026년 10월 26일 업데이트

Code style

무료요약 있음

Carbon 툴체인의 Bazel, C++, Carbon, Markdown, Python 파일 서식 기준을 안내합니다. 주석, 문서, 이름, 설계 원칙과 변경 내용을 설명하는 커밋 메시지 작성법도 다룹니다.

  • Carbon 코드와 관련 파일 서식 정리
  • 주석과 문서 검토
  • 이름이 실제 의미에 맞는지 확인
carbon-language/carbon-lang3.4만2026년 10월 26일 업데이트

Diagnostics

무료요약 있음

Carbon 도구 체인에서 오류와 경고 진단을 추가하거나 수정하는 방법을 안내합니다. 진단 종류 등록, 형식이 지정된 인수로 메시지 구성, 소스 위치에 라벨과 문맥 연결, 문구 규칙 및 테스트 범위 확인을 다룹니다.

  • 진단 메시지 추가
  • 소스 위치에 라벨 지정
  • 진단 문구 통일
carbon-language/carbon-lang3.4만2026년 10월 26일 업데이트

carbon-language의 스킬 모두 보기

이 스킬의 문제 신고