Building shared libraries on Mac requires '-undefined dynamic_lookup' #62874
Labels
A-linkage
Area: linking into static, shared libraries and binaries
O-macos
Operating system: macOS
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Problem
A shared library used as a plugin will often reference symbols in the host program. These symbols will remain unresolved at build time, but will be resolved at the time the shared library is loaded into the host program.
Cargo on Mac fails to build any shared library that can't resolve the symbols at build time.
I expect cargo to build a crate containing unresolved symbols successfully; which works fine on ubuntu.
Steps
A crate with the following
Cargo.toml
:and
src/lib.rs
:Possible Solution(s)
A workaround is to specify:
[build] rustflags = ["-Clink-args=-undefined dynamic_lookup"]
in
.cargo/config
, but that's not acceptable for a crate author (https://github.com/jeff-davis/postgres-extension.rs), who doesn't have control over the crate users' config files.Notes
Output of
cargo version
:cargo 1.36.0 (c4fcfb725 2019-05-15)
18.6.0 Darwin Kernel Version 18.6.0
The text was updated successfully, but these errors were encountered: