git clone https://github.com/google/open-dice.git
git submodule update --init --recursive
source bootstrap.sh
gn gen out
ninja -C out
sijin@Sijin:~/open-dice/out$ tree -d -L 2
.
├── gen
│ ├── generate_open_dice_tools_python_distribution
│ ├── open_dice_build_venv
│ └── third_party
├── host_debug
│ ├── gen
│ └── obj
├── host_fuzz
│ ├── gen
│ └── obj
├── host_optimized
│ ├── gen
│ └── obj
├── obj
│ └── third_party
├── protocol_buffer
│ └── gen
├── python
│ ├── gen
│ └── obj
└── python-venv
├── bin
├── include
├── lib
└── lib64 -> lib
26 directories
| host_debug | host_optimized | host_fuzz | |
|---|---|---|---|
| 용도 | debug용 빌드, test suite | 보안 취약점이나 버그 발견을 위한 Fuzzing 테스트용 빌드 | 배포용 최적화 빌드 |
| 컴파일 옵션 | debug 정보 포함, sanitizer 활성화 | -fsanitize=fuzzer, AddressSanitizer 등 | 크기/성능 최적화 (-Os 등) |
| 포함 파일 | test용 실행파일, 디버그용 라이브러리 등 | fuzzing 관련 실행파일, fuzzing용 라이브러리 등 | 메인 실행파일, 최적화된 라이브러리 등 |
toolchain/BUILD.gn에 들어있다config("common_config") {
include_dirs = [ "//include" ]
# No language extensions, to promote portability.
cflags_c = [
"-Wvla",
"-std=c99",
"-pedantic",
]
# Modern C++ for test and tooling.
cflags_cc = [ "-std=c++20" ]
}
_host_debug = {
# Pigweed의 clang_debug 툴체인을 기반으로 사용
_toolchain_base = pw_target_toolchain_host.clang_debug
defaults = {
default_configs += [
"//toolchains:common_config", # 공통 설정
"//toolchains:enable_sanitizers", # 메모리 안전성 검사
]
}
}
_host_fuzz = {
_toolchain_base = pw_target_toolchain_host.clang_debug
defaults = {
default_configs += [
"//toolchains:common_config", # 공통 설정
"//toolchains:enable_sanitizers", # 메모리 안전성 검사
"//toolchains:enable_fuzzer", # 퍼징 기능
]
}
}
_host_optimized = {
# Pigweed의 크기 최적화 툴체인 사용
_toolchain_base = pw_target_toolchain_host.clang_size_optimized
defaults = {
default_configs += [
"//toolchains:common_config" # 공통 설정만 (Sanitizer 없음)
]
}
}
config("enable_sanitizers") {
cflags = [
"-fsanitize=address,undefined,integer", # 3가지 Sanitizer
"-fsanitize-blacklist=$filter_path", # 필터링 규칙
]
ldflags = cflags # 링킹 시에도 동일한 플래그
inputs = [ "sanitize_filter.txt" ] # 제외할 파일 목록
}
config("enable_fuzzer") {
cflags = [
"-fsanitize=fuzzer", # libFuzzer 활성화
"-O1", # 가벼운 최적화
"-fno-omit-frame-pointer", # 스택 트레이스 보존
"-fno-optimize-sibling-calls", # 디버깅 정보 보존
]
}
https://github.com/google/open-dice/blob/main/BUILD.gn
group("default") {
deps = [
":fuzzers(//toolchains:host_fuzz)",
":optimized_libs(//toolchains:host_optimized)",
":python.install",
":tests.run(//toolchains:host_debug)",
]
}
:fuzzers(//toolchains:host_fuzz)sijin@Sijin:~/open-dice/out/host_debug/obj/test$ ./dice_test
INF [==========] Running all tests.
INF [ RUN ] DiceTest.KnownAnswer
INF [ OK ] DiceTest.KnownAnswer
INF [ RUN ] DiceTest.HashFail
INF [ OK ] DiceTest.HashFail
INF [ RUN ] DiceTest.KdfFail
INF [ OK ] DiceTest.KdfFail
INF [ RUN ] DiceTest.CertFail
INF [ OK ] DiceTest.CertFail
INF [ RUN ] DiceTest.CertTooSmall
INF [ OK ] DiceTest.CertTooSmall
INF [ RUN ] DiceTest.NoExtraneousOps
INF [ OK ] DiceTest.NoExtraneousOps
INF [ RUN ] DiceTest.NoCertParamsPreservesCDIs
INF [ OK ] DiceTest.NoCertParamsPreservesCDIs
INF [==========] Done running all tests.
INF [ PASSED ] 7 test(s).