rust-lang / rust-lang/cargo

Regression in running tests with custom library search path

Open
#4,044 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Steps to reproduce:

  1. Make a crate that links to a native library which is not in system path. The crate's build script adds the library's path using cargo:rustc-link-search=native=.
  2. Make a test in the crate and run it using cargo test.

cargo 0.17 (shipped with rust 1.16.0) successfully runs the test because it adds the library path to LD_LIBRARY_PATH (on Linux).

But cargo 0.18 (shipped with rust 1.17.0) fails to run the test:

Running [path]/[test_name]-f25c1f4d7cd45ca4 --nocapture
[path]/[test_name]-f25c1f4d7cd45ca4: error while loading shared libraries: libctrt1.so: cannot open shared object file: No such file or directory

It doesn't add the library path to LD_LIBRARY_PATH anymore. The binary is linked successfully because cargo probably still supplies the path to the linker, but it's not enough to run the binary.

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

Reproduce the regression with a crate whose build script uses cargo:rustc-link-search=native= and a test run through cargo test. Compare the cargo 0.17 and 0.18 test-running environment, focusing on whether LD_LIBRARY_PATH includes the native library path; done means the test binary can load libctrt1.so again.

Written by the indexing model from the issue text.

Assessment

Tech stack
linux, rust
Domain
build-system, testing-qa
Issue type
Bug
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.