diff --git a/src/config.rs b/src/config.rs index 0cf02e2bbb56..e59a0cb0a232 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 { fn parse_bool(name: &str, value: &str) -> Result { value.parse().map_err(|_| format!("failed to parse value `{}` for {}", value, name)) diff --git a/src/lib.rs b/src/lib.rs index 2c989520f6a5..5a75b9be0cb6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -119,6 +119,8 @@ impl String> Drop for PrintOnPanic { } } +/// 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 7bd9ebbb611c..978a1e722ddd 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 +/// +///
+///
rlib
+///
The metadata can be found in the `lib.rmeta` file inside of the ar archive.
+///
dylib
+///
The metadata can be found in the `.rustc` section of the shared library.
+///
pub(crate) struct CraneliftMetadataLoader; fn load_metadata_with(