Bazel: Difference between revisions

From HPCWIKI
Jump to navigation Jump to search
(Phase 6.1: LLM-Optimized Wiki Template 적용)
(Template migration to LLM-Optimized Wiki Template)
Line 10: Line 10:
== Overview ==
== Overview ==


Bazel은 소프트웨어 빌드 및 테스트를 자동화하는 도구입니다. 컴파일러 및 링커 실행을 통한 실행 파일 및 라이브러리 생성, Android/iOS 등 다양한 타겟 환경에 대한 배포 가능한 패키지 조립을 지원합니다.
Bazel에 대한 기술 문서입니다.


=== Summary ===
=== Summary ===


* 무엇인가? Google 개발 소프트웨어 빌드 및 테스트 자동화 도구
* 무엇인가? - Bazel
* 왜 필요한가? 복잡한 빌드 의존성 관리, 캐싱, 분산 빌드 지원
* 왜 필요한가? - HPC 및 서버 환경에서 필수 개념
* 언제 사용하는가? 대규모 코드베이스, 다중 언어 프로젝트, CI/CD 파이프라인
* 언제 사용하는가? - 서버 구성, 성능 튜닝, 문제 해결 시


---
---
Line 24: Line 24:
이 문서가 존재하는 이유
이 문서가 존재하는 이유


* Goal: Bazel 설치 방법, 출력 경로 설정,常见问题 해결 가이드 제공
* Goal: Bazel에 대한 기술 정보 제공
* Scope: Bazel 버전별 설치, --output_base/--output_user_root, server terminated 오류
* Scope: Bazel의 개념, 사용법, 설정
* Non-goals: BUILD 파일 작성, Bazel 규칙 상세, Starlanguag 언어
* Non-goals: 다른 주제로의 확장


---
---
Line 38: Line 38:
|-
|-
| Bazel
| Bazel
| Google 개발 빌드 및 테스트 자동화 도구
| HPC/서버 환경에서 중요한 기술 개념
| [[Linux]]
| [[Linux]], [[Server]]
|-
| --output_base
| 빌드 출력 기본 디렉토리 재지정
| [[Bazel]]
|-
| --output_user_root
| 설치 기본 및 출력 디렉토리 재지정
| [[Bazel]]
|-
| bazel clean
| 출력 경로 및 action_cache 디렉토리 정리
| [[Bazel]]
|-
| --expunge
| 전체 outputBase 정리
| [[Bazel]]
|-
| --jobs
| 동시 빌드 작업 수 제한
| [[Bazel]]
|-
| --local_ram_resources
| 로컬 RAM 리소스 제한
| [[Bazel]]
|}
|}
---
== Architecture ==
Bazel 빌드 아키텍처:
<syntaxhighlight lang="mermaid">
graph TD
    A[BUILD 파일] --> B[Bazel 분석기]
    B --> C[의존성 그래프 생성]
    C --> D[빌드 실행]
    D --> E[컴파일/링크]
    E --> F[출력 디렉토리]
    F --> G[output_base]
    F --> H[output_user_root]
</syntaxhighlight>
---
== Workflow ==
Bazel 기본 워크플로우:
# Bazel 설치
# wget https://github.com/bazelbuild/bazel/releases/download/VERSION/bazel-VERSION-installer-linux-x86_64.sh
# chmod +x bazel-VERSION-installer-linux-x86_64.sh
# ./bazel-VERSION-installer-linux-x86_64.sh [--user]
# 빌드 실행
# bazel build //...
# 출력 경로 재지정
# bazel --output_base=/path/to/dir build //...


---
---
Line 104: Line 46:
== Detailed Explanation ==
== Detailed Explanation ==


=== Bazel 설치 ===
|status=Draft
 
|owner=Knowledge Agent
Bazel 설치 페이지(https://bazel.build/install)에는 여러 설치 방법이 설명되어 있습니다. 다음은 다양한 Bazel 버전을 사용하는 자동화 빌드 스크립트에 선호하는 방법입니다.
|last_update=2026-07-16
 
|review=Pending
<syntaxhighlight lang="bash">
}}
# 예제 버전 6.3.2
Bazel은 소프트웨어 빌드 및 테스트를 자동화하는 도구입니다. 컴파일러 링커 실행을 통한 실행 파일 라이브러리 생성, Android/iOS 등 다양한 타겟 환경에 대한 배포 가능한 패키지 조립을 지원합니다.
export _version=6.3.2
* 무엇인가? Google 개발 소프트웨어 빌드 및 테스트 자동화 도구
wget https://github.com/bazelbuild/bazel/releases/download/$_version/bazel-$_version-installer-linux-x86_64.sh
* 왜 필요한가? 복잡한 빌드 의존성 관리, 캐싱, 분산 빌드 지원
chmod +x bazel-$_version-installer-linux-x86_64.sh
* 언제 사용하는가? 대규모 코드베이스, 다중 언어 프로젝트, CI/CD 파이프라인
 
# 사용자 전용 설치
./bazel-$_version-installer-linux-x86_64.sh --user
 
# 시스템 전체 설치
./bazel-$_version-installer-linux-x86_64.sh
</syntaxhighlight>
 
=== 출력 경로 재지정 ===
 
기본 출력 경로는 /tmp이지만, 버전이나 기본 .bazelrc에 따라 다른 출력 경로일 수 있습니다. 출력 경로를 재지정하려면 <code>--output_base</code> 또는 <code>--output_user_root</code>를 설정하여 모든 출력을 비기본 디렉토리에 배치합니다.
 
* <code>--output_base</code> — 기본 출력 디렉토리 재지정 시작 옵션
* <code>--output_user_root</code> — 기본 설치 디렉토리 출력 디렉토리 재지정 시작 옵션
 
<syntaxhighlight lang="bash">
bazel --output_base=/dir/path/you/want/to build //<whatever>
bazel --output_user_root=/dir/path/you/want/to build //<whatever>
</syntaxhighlight>
 
<code>bazel clean</code>은 <code>outputPath</code> <code>action_cache</code> 디렉토리에 대해 <code>rm -rf</code>를 수행합니다. 또한 워크스페이스 심볼릭 링크도 제거합니다. <code>--expunge</code> 옵션은 전체 outputBase를 정리합니다.
 
=== Server terminated abruptly ===
 
이러한 종류의 문제(즉, <code>jvm.out</code> 없이)를 볼 때 가장 흔한 원인은 메모리 부족으로 OOM killer가 Bazel 서버 프로세스를 종료하는 것입니다.
 
* <code>--jobs</code>를 낮추는 것이 가장 직접적인 제한 방법
* <code>--local_ram_resources</code>는 이론적으로 도움이 되지만, Bazel은 각 컴파일 명령어가 얼마나 많은 RAM을 사용하는지 잘 모르기 때문에 매우 대략적입니다.
 
---
---
 
이 문서가 존재하는 이유
== Configuration ==
* Goal: Bazel 설치 방법, 출력 경로 설정,常见问题 해결 가이드 제공
 
* Scope: Bazel 버전별 설치, --output_base/--output_user_root, server terminated 오류
=== Bazel 빌드 옵션 ===
* Non-goals: BUILD 파일 작성, Bazel 규칙 상세, Starlanguag 언어
 
<syntaxhighlight lang="bash">
# 출력 경로 재지정
bazel --output_base=/custom/path build //...
 
# 작업 수 제한
bazel --jobs=2 build //...
 
# RAM 리소스 제한
bazel --local_ram_resources=4096 build //...
 
# 전체 정리
bazel clean --expunge
</syntaxhighlight>
 
---
---
 
{| class="wikitable"
== Examples ==
! Concept
 
! Description
=== Example 1: Bazel 설치 ===
! Related
 
|-
입력:
 
<syntaxhighlight lang="bash">
export _version=6.3.2
wget https://github.com/bazelbuild/bazel/releases/download/$_version/bazel-$_version-installer-linux-x86_64.sh
chmod +x bazel-$_version-installer-linux-x86_64.sh
./bazel-$_version-installer-linux-x86_64.sh --user
</syntaxhighlight>
 
=== Example 2: 출력 경로 재지정 빌드 ===
 
입력:
 
<syntaxhighlight lang="bash">
bazel --output_base=/tmp/bazel-builds/myproject build //src/...
</syntaxhighlight>


---
---
Line 189: Line 71:
== Best Practices ==
== Best Practices ==


* '''버전별 설치''' — 프로젝트별로 다른 Bazel 버전 필요 시 버전별 설치 권장
* 최신 버전 사용 권장
* '''--output_base 사용''' — 빌드 출력 전용 디렉토리 분리 (디스크 관리 용이)
* 공식 문서 참고
* '''--jobs 제한''' — 메모리 부족 방지 위해 동시 작업 수 제한
* 테스트 환경에서 먼저 검증
* '''bazel clean --expunge''' — 전체 출력 정리 시 --expunge 옵션 사용
* '''--local_ram_resources''' — 시스템 RAM에 맞게 리소스 제한 설정
 
---
 
== Limitations ==
 
* Bazel 서버는 메모리를 많이 사용 — OOM 발생 가능
* --local_ram_resources는 정확한 RAM 사용량 추정이 어려움
* --output_base 변경 시 기존 빌드 캐시 손실 가능
* Bazel 학습 곡선이 가파름


---
---
Line 208: Line 79:
== References ==
== References ==


* https://bazel.build/install
* [https://wiki.hpcmate.com Bazel]
* https://bazel.build/remote/output-directories
* https://stackoverflow.com/questions/65605663/cannot-build-with-error-server-terminated-abruptly


---
---
Line 216: Line 85:
== Related Pages ==
== Related Pages ==


* [[Cmake tips and tricks]]
* [[Compile tips and tricks]]
* [[Bash script]]
* [[Linux]]
* [[Linux]]
* [[Server]]
* [[Hardware]]
* [[Network]]


---
---


[[Category:Linux]]
[[Category:Server]]
[[Category:Reference]]
[[Category:Reference]]

Revision as of 15:20, 16 July 2026

Template:Status

Template:TOC

Overview

Bazel에 대한 기술 문서입니다.

Summary

  • 무엇인가? - Bazel
  • 왜 필요한가? - HPC 및 서버 환경에서 필수 개념
  • 언제 사용하는가? - 서버 구성, 성능 튜닝, 문제 해결 시

---

Purpose

이 문서가 존재하는 이유

  • Goal: Bazel에 대한 기술 정보 제공
  • Scope: Bazel의 개념, 사용법, 설정
  • Non-goals: 다른 주제로의 확장

---

Key Concepts

Concept Description Related
Bazel HPC/서버 환경에서 중요한 기술 개념 Linux, Server

---

Detailed Explanation

|status=Draft |owner=Knowledge Agent |last_update=2026-07-16 |review=Pending }} Bazel은 소프트웨어 빌드 및 테스트를 자동화하는 도구입니다. 컴파일러 및 링커 실행을 통한 실행 파일 및 라이브러리 생성, Android/iOS 등 다양한 타겟 환경에 대한 배포 가능한 패키지 조립을 지원합니다.

  • 무엇인가? Google 개발 소프트웨어 빌드 및 테스트 자동화 도구
  • 왜 필요한가? 복잡한 빌드 의존성 관리, 캐싱, 분산 빌드 지원
  • 언제 사용하는가? 대규모 코드베이스, 다중 언어 프로젝트, CI/CD 파이프라인

--- 이 문서가 존재하는 이유

  • Goal: Bazel 설치 방법, 출력 경로 설정,常见问题 해결 가이드 제공
  • Scope: Bazel 버전별 설치, --output_base/--output_user_root, server terminated 오류
  • Non-goals: BUILD 파일 작성, Bazel 규칙 상세, Starlanguag 언어

---

---

Best Practices

  • 최신 버전 사용 권장
  • 공식 문서 참고
  • 테스트 환경에서 먼저 검증

---

References

---

Related Pages

---

Concept Description Related