Skip to main content

dep_paths_for_args

Function dep_paths_for_args 

Source
fn dep_paths_for_args(
    unit: &Unit,
    build_runner: &BuildRunner<'_, '_>,
) -> Vec<PathBuf>
Expand description

Generate a list of paths for the rustc -L args.

To generate the list of paths we walk the dependency graph using DFS with a stack.

We try to avoid bloating the amount of args passed rustc as it can cause issues with OS limits for large projects. (and generally just makes the rustc command ugly!). Below are the rules for excluding build units from the args.

  1. Don’t include build script out dir in the args to reduce rustc command bloat.
  2. Proc macros are statically linked, so when including a proc-macro dependency we can skip adding it’s dependencies. Note that we still do add them when we are compiling the proc-macro itself.
  3. Don’t include direct dependencies because they are passed with --extern and rustc does not need -L if it was already passed as --extern