diff options
| -rw-r--r-- | src/config.rs | 6 | ||||
| -rw-r--r-- | src/lib.rs | 2 | ||||
| -rw-r--r-- | src/metadata.rs | 12 |
3 files changed, 20 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs index 0cf02e2bbb5..e59a0cb0a23 100644 --- a/src/config.rs +++ b/src/config.rs @@ -5,10 +5,14 @@ fn bool_env_var(key: &str) -> bool { env::var(key).as_ref().map(|val| &**val) == Ok("1") } +/// The mode to use for compilation. #[derive(Copy, Clone, Debug)] pub enum CodegenMode { + /// AOT compile the crate. This is the default. Aot, + /// JIT compile and execute the crate. Jit, + /// JIT compile and execute the crate, but only compile functions the first time they are used. JitLazy, } @@ -25,6 +29,7 @@ impl FromStr for CodegenMode { } } +/// Configuration of cg_clif as passed in through `-Cllvm-args` and various env vars. #[derive(Clone, Debug)] pub struct BackendConfig { /// Should the crate be AOT compiled or JIT executed. @@ -76,6 +81,7 @@ impl Default for BackendConfig { } impl BackendConfig { + /// Parse the configuration passed in using `-Cllvm-args`. pub fn from_opts(opts: &[String]) -> Result<Self, String> { fn parse_bool(name: &str, value: &str) -> Result<bool, String> { value.parse().map_err(|_| format!("failed to parse value `{}` for {}", value, name)) diff --git a/src/lib.rs b/src/lib.rs index 2c989520f6a..5a75b9be0cb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -119,6 +119,8 @@ impl<F: Fn() -> String> Drop for PrintOnPanic<F> { } } +/// The codegen context holds any information shared between the codegen of individual functions +/// inside a single codegen unit with the exception of the Cranelift [`Module`](cranelift_module::Module). struct CodegenCx<'tcx> { tcx: TyCtxt<'tcx>, global_asm: String, diff --git a/src/metadata.rs b/src/metadata.rs index 7bd9ebbb611..978a1e722dd 100644 --- a/src/metadata.rs +++ b/src/metadata.rs @@ -14,6 +14,18 @@ use rustc_target::spec::Target; use crate::backend::WriteMetadata; +/// The metadata loader used by cg_clif. +/// +/// The metadata is stored in the same format as cg_llvm. +/// +/// # Metadata location +/// +/// <dl> +/// <dt>rlib</dt> +/// <dd>The metadata can be found in the `lib.rmeta` file inside of the ar archive.</dd> +/// <dt>dylib</dt> +/// <dd>The metadata can be found in the `.rustc` section of the shared library.</dd> +/// </dl> pub(crate) struct CraneliftMetadataLoader; fn load_metadata_with( |
