rust-lang / rust-lang/rust

building dynamic libraries on mac sets id/name for linker to something questionable

Open
#121,674 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-linkage O-macos T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

If I build a "cdylib", it tells the linker that the library is located in the target/release directory.

Here is the output for otool -l:

Load command 4
          cmd LC_ID_DYLIB
      cmdsize 96
         name /Users/vanessa/dev/rust/forks/regex/target/release/deps/librure.dylib (offset 24)
   time stamp 1 Wed Dec 31 19:00:01 1969
      current version 0.0.0
compatibility version 0.0.0

This means I can't install the shared library by copying the .dylib to /usr/local/lib; I have to run install_name_tool on the build result before distributing.

I think building a library should set the name to something like @rpath/librure.dylib

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 issue's cdylib build and inspect target/release/deps/librure.dylib with otool -l, focusing on the LC_ID_DYLIB name. Trace the Rust build and linker handling for macOS dynamic libraries; done means the generated install name uses an appropriate @rpath path rather than the build directory, with coverage for the behavior.

Written by the indexing model from the issue text.

Assessment

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