2025년 3월 27일부터 AOSP를 빌드하고 기여하려면 aosp-main
대신 android-latest-release
를 사용하는 것이 좋습니다. 자세한 내용은 AOSP 변경사항을 참고하세요.
바이너리 모듈
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Rust 바이너리는 rust_binary
모듈 유형을 사용하여 생성할 수 있습니다. 예를 들면 다음과 같습니다.
rust_binary {
name: "hello_rust",
srcs: ["src/hello_rust.rs"],
}
마찬가지로, rust_binary_host
를 사용하여 호스트 전용 모듈을 생성할 수 있습니다.
주목할 만한 rust_binary 속성
다음은 주요 공통 속성 외에도 중요하거나 rust_binary
모듈 유형의 고유한 동작을 나타내는 속성입니다.
- static_executable: 이 바이너리를 정적 바이너리로서 빌드하고,
prefer_rlib
가 true
임을 암시합니다. 완전 정적 실행 파일은 Bionic 타겟용으로만 생성할 수 있습니다. Bionic이 아닌 타겟의 경우에는 prefer_rlib
가 true
임을 암시하기만 하며, 여전히 libc
와 libdl
을 동적으로 연결합니다.
- prefer_rlib:
rustlibs
링크가 기기 타겟용으로 기본적으로 rlib
링크를 선택하도록 변경하고, 기기 타겟에서 libstd
를 rlib
로서 연결합니다. 이는 호스트 타겟의 기본 동작이므로 호스트 타겟에 영향을 미치지 않습니다.
링크
기기를 타겟팅하는 rust_binary
모듈은 기본적으로 항상 libstd
에 동적으로 링크되며, prefer_rlib
가 true
가 아닌 이상 rustlibs
에 나열된 종속 항목으로 기본적으로 dylib
라이브러리를 선호합니다. 완전 정적 바이너리가 필요한 경우 static_executable
속성을 참고하세요.
호스트 모듈은 항상 libstd
에 정적으로 연결되며, rustlibs
에 나열된 종속 항목으로 기본적으로 rlib
라이브러리를 선호합니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[null,null,["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["# Binary modules\n\nRust binaries can be produced using the `rust_binary` module type; for example: \n\n rust_binary {\n name: \"hello_rust\",\n srcs: [\"src/hello_rust.rs\"],\n }\n\nSimilarly, you can use `rust_binary_host` to provide a host-only\nmodule.\n\nNotable rust_binary properties\n------------------------------\n\nIn addition to the [Important common properties](/docs/setup/build/rust/building-rust-modules/android-rust-modules#important-common-properties),\nthe following properties are also either important, or exhibit unique behavior\nspecific to the `rust_binary` module type:\n\n- **static_executable** : Builds this binary as a static binary, and implies `prefer_rlib` is `true`. Fully static executables can only be produced for bionic targets. For non-bionic targets, this implies only that `prefer_rlib` is `true`, but it still links `libc` and `libdl` dynamically.\n- **prefer_rlib** : Changes the `rustlibs` linkage to select the `rlib` linkage by default for device targets, and links `libstd` as an `rlib` on device targets. Note that this is the default behavior for host targets, and has no impact on them.\n\nLinkage\n-------\n\nBy default, `rust_binary` modules that are targeting devices are always linked\ndynamically against `libstd` and by default will prefer `dylib` libraries for\ndependencies listed in `rustlibs` unless `prefer_rlib` is `true`. If fully\nstatic binaries are required, see the `static_executable` property.\n\nHost modules are always linked statically against `libstd` and\nby default prefer `rlib` libraries for dependencies that are listed in\n`rustlibs`."]]