Skip to content

"cargo:rustc-link-arg=-Wl,-export-dynamic" is *silently* ignored when emitted from a dependency #16880

@Kixunil

Description

@Kixunil

Problem

println!("cargo:rustc-link-arg=-Wl,-export-dynamic"); is respected in binaries but silently ignored when emitted by a library. This can lead to frustrating chasing of mysterious missing symbols. An example of such scenario is when trying to link a crate that integrates OCaml runtime via ocaml-interop.

Steps

  1. create a binary crate with a build script that emits cargo:rustc-link-arg=-Wl,-export-dynamic
  2. observe the build with cargo -v - the export-dynamic flag is present
  3. move the build script into a dependency
  4. observe the build of the binary - the flag is not present

Possible Solution(s)

The simplest would be to just pass the argument but I can understand it might be undesirable, in which case an error message should be emitted. However, if not allowing libraries to emit that argument is desired, it'd be good to have some other way of exporting proper symbols (perhaps by listing them) because it'd be annoying having to add a build script to properly use a dependency.

Notes

This issue was originally filed at rust-lang/rust#155240 where it was determined it's a problem with cargo.

Version

cargo 1.95.0-nightly (f298b8c82 2026-02-24)
release: 1.95.0-nightly
commit-hash: f298b8c82da0cba538516b45b04a480fc501d4c0
commit-date: 2026-02-24
host: x86_64-unknown-linux-gnu
libgit2: 1.9.2 (sys:0.20.4 vendored)
libcurl: 8.15.0-DEV (sys:0.4.83+curl-8.15.0 vendored ssl:OpenSSL/3.5.4)
ssl: OpenSSL 3.5.4 30 Sep 2025
os: Debian 12.0.0 (bookworm) [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-build-scriptsArea: build.rs scriptsC-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions