Skip to content

Commit 69102db

Browse files
committed
Add some documentation
1 parent ff38b37 commit 69102db

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

src/config.rs

+6
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ fn bool_env_var(key: &str) -> bool {
55
env::var(key).as_ref().map(|val| &**val) == Ok("1")
66
}
77

8+
/// The mode to use for compilation.
89
#[derive(Copy, Clone, Debug)]
910
pub enum CodegenMode {
11+
/// AOT compile the crate. This is the default.
1012
Aot,
13+
/// JIT compile and execute the crate.
1114
Jit,
15+
/// JIT compile and execute the crate, but only compile functions the first time they are used.
1216
JitLazy,
1317
}
1418

@@ -25,6 +29,7 @@ impl FromStr for CodegenMode {
2529
}
2630
}
2731

32+
/// Configuration of cg_clif as passed in through `-Cllvm-args` and various env vars.
2833
#[derive(Clone, Debug)]
2934
pub struct BackendConfig {
3035
/// Should the crate be AOT compiled or JIT executed.
@@ -76,6 +81,7 @@ impl Default for BackendConfig {
7681
}
7782

7883
impl BackendConfig {
84+
/// Parse the configuration passed in using `-Cllvm-args`.
7985
pub fn from_opts(opts: &[String]) -> Result<Self, String> {
8086
fn parse_bool(name: &str, value: &str) -> Result<bool, String> {
8187
value.parse().map_err(|_| format!("failed to parse value `{}` for {}", value, name))

src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ impl<F: Fn() -> String> Drop for PrintOnPanic<F> {
119119
}
120120
}
121121

122+
/// The codegen context holds any information shared between the codegen of individual functions
123+
/// inside a single codegen unit with the exception of the Cranelift [`Module`](cranelift_module::Module).
122124
struct CodegenCx<'tcx> {
123125
tcx: TyCtxt<'tcx>,
124126
global_asm: String,

src/metadata.rs

+12
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@ use rustc_target::spec::Target;
1414

1515
use crate::backend::WriteMetadata;
1616

17+
/// The metadata loader used by cg_clif.
18+
///
19+
/// The metadata is stored in the same format as cg_llvm.
20+
///
21+
/// # Metadata location
22+
///
23+
/// <dl>
24+
/// <dt>rlib</dt>
25+
/// <dd>The metadata can be found in the `lib.rmeta` file inside of the ar archive.</dd>
26+
/// <dt>dylib</dt>
27+
/// <dd>The metadata can be found in the `.rustc` section of the shared library.</dd>
28+
/// </dl>
1729
pub(crate) struct CraneliftMetadataLoader;
1830

1931
fn load_metadata_with(

0 commit comments

Comments
 (0)