rust-lang / rust-lang/cargo

Add cargo:rustc-dynamic-link-search for setting LD_LIBRARY_PATH during cargo run/cargo test

Open
#4,895 21 comments 32 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-build-scripts A-linkage C-feature-request S-needs-design
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

Currently when building we tell cargo where to find static and shared libraries with cargo:rustc-link-search.

However, if you call cargo run or cargo test, while it will still compile, it won't run because LD_LIBRARY_PATH or DYLD_LIBRARY_PATH need to be set. If crates could explicitly emit dylib search paths with cargo:rustc-dynamic-link-search then we could print a list of them at the end of compilation (the same way we do for staticlibs, something like "run this with LD_LIBRARY_PATH=foo:bar:baz"), and if folks use cargo run or cargo test we can run those with this appended to the dynamic lib path

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files or tests are named in the issue. Start by tracing how cargo:rustc-link-search is handled and how cargo run and cargo test launch binaries; done means crates can emit dynamic library search paths and those paths are applied or reported for the relevant platform.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.