## Rustc

# Struct Rustc

Source

    pub struct Rustc {
        cmd: Command,
        target: Option<String>,
    }

Expand description

A `rustc` invocation builder.

## Fields§

§`cmd: Command`§`target: Option<String>`

## Implementations§

Source§

### impl Rustc

Source

#### pub fn into_raw_command(self) -> Command

In very rare circumstances, you may need a e.g. `bare_rustc()` or `bare_rustdoc()` with host runtime libs configured, but want the underlying raw `std::process::Command` (e.g. for manipulating pipes or whatever). This function will consume the command wrapper and extract the underlying `std::process::Command`.

Caution: this will mean that you can no longer use the convenience methods on the command wrapper. Use as a last resort.

Source

#### pub fn env<K, V>(&mut self, key: K, value: V) -> &mut Self
where K: AsRef<OsStr>, V: AsRef<OsStr>,

Specify an environment variable.

Source

#### pub fn env_remove<K>(&mut self, key: K) -> &mut Self
where K: AsRef<OsStr>,

Remove an environmental variable.

Source

#### pub fn arg<S>(&mut self, arg: S) -> &mut Self
where S: AsRef<OsStr>,

Generic command argument provider. Prefer specific helper methods if possible. Note that for some executables, arguments might be platform specific. For C/C++ compilers, arguments might be platform and compiler specific.

Source

#### pub fn args<V, S>(&mut self, args: V) -> &mut Self
where V: AsRef<[S]>, S: AsRef<OsStr>,

Generic command arguments provider. Prefer specific helper methods if possible. Note that for some executables, arguments might be platform specific. For C/C++ compilers, arguments might be platform and compiler specific.

Source

#### pub fn stdin<T: Into<Stdio>>(&mut self, cfg: T) -> &mut Self

Configuration for the child process’s standard input (stdin) handle.

See `std::process::Command::stdin`.

Source

#### pub fn stdout<T: Into<Stdio>>(&mut self, cfg: T) -> &mut Self

Configuration for the child process’s standard output (stdout) handle.

See `std::process::Command::stdout`.

Source

#### pub fn stderr<T: Into<Stdio>>(&mut self, cfg: T) -> &mut Self

Configuration for the child process’s standard error (stderr) handle.

See `std::process::Command::stderr`.

Source

#### pub fn inspect<I>(&mut self, inspector: I) -> &mut Self
where I: FnOnce(&Command),

Inspect what the underlying `Command` is up to the current construction.

Source

#### pub fn set_aux_fd<F: Into<OwnedFd>>( &mut self, new_fd: RawFd, fd: F, ) -> &mut Self

Set an auxiliary stream passed to the process, besides the stdio streams.

Source

#### pub fn run(&mut self) -> CompletedProcess

Run the constructed command and assert that it is successfully run.

Source

#### pub fn run_fail(&mut self) -> CompletedProcess

Run the constructed command and assert that it does not successfully run.

Source

#### pub fn run_unchecked(&mut self) -> CompletedProcess

Run the command but do not check its exit status. Only use if you explicitly don’t care about the exit status. Prefer to use `Self::run` and `Self::run_fail` whenever possible.

Source

#### pub fn current_dir<P: AsRef<Path>>(&mut self, path: P) -> &mut Self

Set the path where the command will be run.

Source§

### impl Rustc

Source

#### pub fn new() -> Self

Construct a new `rustc` invocation. This will automatically set the library search path as `-L cwd()`, configure the compilation target and enable dynamic linkage by default on musl hosts. Use `bare_rustc` to avoid this.

Source

#### pub fn bare() -> Self

Construct a bare `rustc` invocation with no flags set.

Source

#### pub fn cfg(&mut self, s: &str) -> &mut Self

Configure the compilation environment.

Source

#### pub fn opt(&mut self) -> &mut Self

Specify default optimization level `-O` (alias for `-C opt-level=3`).

Source

#### pub fn opt_level(&mut self, option: &str) -> &mut Self

Specify a specific optimization level.

Source

#### pub fn metadata(&mut self, meta: &str) -> &mut Self

Incorporate a hashed string to mangled symbols.

Source

#### pub fn extra_filename(&mut self, suffix: &str) -> &mut Self

Add a suffix in each output filename.

Source

#### pub fn emit<S: AsRef<str>>(&mut self, kinds: S) -> &mut Self

Specify type(s) of output files to generate.

Source

#### pub fn extern_<P: AsRef<Path>>( &mut self, crate_name: &str, path: P, ) -> &mut Self

Specify where an external library is located.

Source

#### pub fn remap_path_prefix<P: AsRef<Path>, P2: AsRef<Path>>( &mut self, from: P, to: P2, ) -> &mut Self

Remap source path prefixes in all output.

Source

#### pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self

Specify path to the input file.

Source

#### pub fn set_backtrace_level<R: AsRef<OsStr>>(&mut self, level: R) -> &mut Self

Source

#### pub fn output<P: AsRef<Path>>(&mut self, path: P) -> &mut Self

Specify path to the output file. Equivalent to `-o`` in rustc.

Source

#### pub fn out_dir<P: AsRef<Path>>(&mut self, path: P) -> &mut Self

Specify path to the output directory. Equivalent to `–out-dir`` in rustc.

Source

#### pub fn lto(&mut self, option: &str) -> &mut Self

This flag enables LTO in the specified form.

Source

#### pub fn linker_plugin_lto(&mut self, option: &str) -> &mut Self

This flag defers LTO optimizations to the linker.

Source

#### pub fn panic(&mut self, option: &str) -> &mut Self

Specify what happens when the code panics.

Source

#### pub fn codegen_units(&mut self, units: usize) -> &mut Self

Specify number of codegen units

Source

#### pub fn incremental<P: AsRef<Path>>(&mut self, path: P) -> &mut Self

Specify directory path used for incremental cache

Source

#### pub fn profile_generate<P: AsRef<Path>>(&mut self, path: P) -> &mut Self

Specify directory path used for profile generation

Source

#### pub fn profile_use<P: AsRef<Path>>(&mut self, path: P) -> &mut Self

Specify directory path used for profile usage

Source

#### pub fn symbol_mangling_version(&mut self, option: &str) -> &mut Self

Specify option of `-C symbol-mangling-version`.

Source

#### pub fn prefer_dynamic(&mut self) -> &mut Self

Specify `-C prefer-dynamic`.

Source

#### pub fn error_format(&mut self, format: &str) -> &mut Self

Specify error format to use

Source

#### pub fn json(&mut self, items: &str) -> &mut Self

Specify json messages printed by the compiler

Source

#### pub fn ui_testing(&mut self) -> &mut Self

Normalize the line number in the stderr output

Source

#### pub fn target<S: AsRef<str>>(&mut self, target: S) -> &mut Self

Specify the target triple, or a path to a custom target json spec file.

Source

#### pub fn target_cpu<S: AsRef<str>>(&mut self, target_cpu: S) -> &mut Self

Specify the target CPU.

Source

#### pub fn crate_type(&mut self, crate_type: &str) -> &mut Self

Specify the crate type.

Source

#### pub fn library_search_path<P: AsRef<Path>>(&mut self, path: P) -> &mut Self

Add a directory to the library search path. Equivalent to `-L` in rustc.

Source

#### pub fn specific_library_search_path<P: AsRef<Path>>( &mut self, kind: &str, path: P, ) -> &mut Self

Add a directory to the library search path with a restriction, where `kind` is a dependency type. Equivalent to `-L KIND=PATH` in rustc.

Source

#### pub fn sysroot<P: AsRef<Path>>(&mut self, path: P) -> &mut Self

Override the system root. Equivalent to `--sysroot` in rustc.

Source

#### pub fn edition(&mut self, edition: &str) -> &mut Self

Specify the edition year.

Source

#### pub fn print(&mut self, request: &str) -> &mut Self

Specify the print request.

Source

#### pub fn link_arg(&mut self, link_arg: &str) -> &mut Self

Add an extra argument to the linker invocation, via `-Clink-arg`.

Source

#### pub fn link_args(&mut self, link_args: &str) -> &mut Self

Add multiple extra arguments to the linker invocation, via `-Clink-args`.

Source

#### pub fn stdin_buf<I: AsRef<[u8]>>(&mut self, input: I) -> &mut Self

Specify a stdin input buffer.

Source

#### pub fn crate_name<S: AsRef<OsStr>>(&mut self, name: S) -> &mut Self

Specify the crate name.

Source

#### pub fn linker(&mut self, linker: &str) -> &mut Self

Specify the linker

Source

#### pub fn linker_flavor(&mut self, linker_flavor: &str) -> &mut Self

Specify the linker flavor

Source

#### pub fn debuginfo(&mut self, level: &str) -> &mut Self

Specify `-C debuginfo=...`.

Source

#### pub fn split_debuginfo(&mut self, split_kind: &str) -> &mut Self

Specify `-C split-debuginfo={packed,unpacked,off}`.

Source

#### pub fn split_dwarf_out_dir(&mut self, out_dir: Option<&str>) -> &mut Self

Source

#### pub fn verbose(&mut self) -> &mut Self

Pass the `--verbose` flag.

Source

#### pub fn extra_rs_cxx_flags(&mut self) -> &mut Self

`EXTRARSCXXFLAGS`

Source

#### pub fn codegen_source_order(&mut self) -> &mut Self

Make that the generated LLVM IR is in source order.

## Trait Implementations§

Source§

### impl Debug for Rustc

Source§

#### fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

## Auto Trait Implementations§

§

### impl Freeze for Rustc

§

### impl !RefUnwindSafe for Rustc

§

### impl Send for Rustc

§

### impl Sync for Rustc

§

### impl Unpin for Rustc

§

### impl !UnwindSafe for Rustc

## Blanket Implementations§

Source§

### impl<T> Any for T
where T: 'static + ?Sized,

Source§

#### fn type_id(&self) -> TypeId

Gets the `TypeId` of `self`. Read more
Source§

### impl<T> Borrow<T> for T
where T: ?Sized,

Source§

#### fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

### impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

#### fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

### impl<T> From<T> for T

Source§

#### fn from(t: T) -> T

Returns the argument unchanged.

Source§

### impl<T, U> Into<U> for T
where U: From<T>,

Source§

#### fn into(self) -> U

Calls `U::from(self)`.

That is, this conversion is whatever the implementation of `From<T> for U` chooses to do.

Source§

### impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

#### type Error = Infallible

The type returned in the event of a conversion error.
Source§

#### fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

### impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

#### type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

#### fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

## Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain `repr(...)` attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 328 bytes