rust-lang / rust-lang/rust

Unable to statically link a native library if there a dynamic library in the same directory.

Open
#124,462 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-linkage C-bug S-needs-repro T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Code
rustc -L native='/usr/local/Cellar/libplist/2.4.0/lib' -l static=plist-2.0 main.rs
Meta

rustc --version --verbose:

rustc 1.79.0-nightly (aed2187d5 2024-04-27)
binary: rustc
commit-hash: aed2187d53b8789e3a37f50ae36f894a2a679077
commit-date: 2024-04-27
host: x86_64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.4
Error output
There were both of a dynamic library file and a static library file in the lib directory.
The program was built successfully, but it was linked with a dynamic library rather than the static library.

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

Start by reproducing the rustc command with both dynamic and static library files in the native library directory, using the reported nightly version and macOS environment. Trace native library selection and linking behavior, then verify that the static library is selected and add a regression test covering the directory contents and command-line options.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, compilers
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.