rust dylibs and providing multiple --extern fields for rust binaries

7 views
Skip to first unread message

Aaron Wood

unread,
Oct 31, 2025, 1:29:06 PM (7 days ago) Oct 31
to gn-dev
rustc has a new option that allows the type metadata to be omitted from the compiled .so of a dylib.  This can save a bunch of space for us on Fuchsia.  However, it requires that rustc is passed both the .so and the .rmeta file that contains the type metadata as `--extern <cratename>=<path>` when compiling rust binaries that link against the dylib.

We (fuchsia), have explored a couple different options, and the simplest is to just pass all dylib outputs that the toolchain documents in the `rust_dylib` tool as externs, but that seems heavy-handed.

Another option would be for dylibs (or other tools that provide a `link_output` argument to provide a list of `link_outputs` instead, or for the tools for the various rust libraries to _also_ document a metadata file, that is used with link_output, when compiling and linking rust binaries.

Any preferences on approaches before we start trying to make some CLs?

Thanks,
Aaron

Dirk Pranke

unread,
Oct 31, 2025, 3:18:17 PM (7 days ago) Oct 31
to Aaron Wood, gn-dev
I am not wise in the ways of rust flags, so I don't have an informed opinion on this, but either of the latter two seem reasonable.

-- Dirk
Reply all
Reply to author
Forward
0 new messages