Skip to content

Frivolous native-static-libs warning when building a cdylib with Cargo-C on macOS #142582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
amyspark opened this issue Jun 16, 2025 · 5 comments · Fixed by #142595
Closed

Frivolous native-static-libs warning when building a cdylib with Cargo-C on macOS #142582

amyspark opened this issue Jun 16, 2025 · 5 comments · Fixed by #142595
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@amyspark
Copy link
Contributor

amyspark commented Jun 16, 2025

Code

Try building GStreamer's gst-plugins-rs against the 1.26 SDK. (Linked the branch in which I had this issue happen.)

Do not use cargo build, use cargo-c's cargo cbuild command in order to generate the dylibs and the pkg-config modules:

cargo +nightly cbuild --release --library-type cdylib

Current output

   Compiling cfg-if v1.0.0
   (...continues...)
   Compiling gst-plugin-webrtc-signalling-protocol v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/webrtc/protocol)
warning: cannot output linkage information without staticlib crate-type

note: consider `--crate-type staticlib` to print linkage information

warning: `gst-plugin-webrtc-signalling-protocol` (lib) generated 1 warning
   Compiling byteorder_slice v3.0.0
   Compiling cookie-factory v0.3.3
   Compiling web-transport-proto v0.2.6
   Compiling yasna v0.5.2
   Compiling lru v0.12.5
   Compiling headers-core v0.3.0
   Compiling nanorand v0.7.0
   Compiling sprintf v0.4.2
   Compiling itertools v0.12.1
   Compiling bstr v1.12.0
   Compiling toml_datetime v0.6.9
   Compiling same-file v1.0.6
   Compiling weezl v0.1.8
   Compiling smawk v0.3.2
   Compiling scoped-tls v1.0.1
   Compiling new_debug_unreachable v1.0.6
   Compiling cdg v0.1.0
   Compiling unicode-width v0.2.0
   Compiling unicode-linebreak v0.1.5
   Compiling bitstream-io v2.6.0
   Compiling color_quant v1.1.0
   Compiling winnow v0.7.10
   Compiling fallible-iterator v0.3.0
   Compiling jiff v0.2.14
   Compiling gif v0.13.1
   Compiling sdp-types v0.1.8
   Compiling textwrap v0.16.2
   Compiling cdg_renderer v0.8.0
   Compiling warp v0.3.7
   Compiling walkdir v2.5.0
   Compiling toml_edit v0.22.26
   Compiling async-stream v0.3.6
   Compiling gst-plugin-rav1e v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/video/rav1e)
   Compiling gst-plugin-textwrap v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/text/wrap)
   Compiling gst-plugin-uriplaylistbin v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/utils/uriplaylistbin)
   Compiling gst-plugin-raptorq v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/raptorq)
   Compiling gst-plugin-webrtchttp v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/webrtchttp)
   Compiling gst-plugin-inter v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/generic/inter)
   Compiling gst-plugin-ndi v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/ndi)
   Compiling env_logger v0.11.8
   Compiling gst-plugin-rtsp v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/rtsp)
   Compiling gst-plugin-regex v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/text/regex)
   Compiling gst-plugin-skia v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/video/skia)
   Compiling gst-plugin-hlssink3 v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/hlssink3)
   Compiling gst-plugin-aws v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/aws)
   Compiling gst-plugin-gopbuffer v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/generic/gopbuffer)
   Compiling gst-plugin-relationmeta v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/relationmeta)
   Compiling gst-plugin-mp4 v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/mux/mp4)
   Compiling gst-plugin-hsv v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/video/hsv)
   Compiling gst-plugin-json v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/text/json)
   Compiling gst-plugin-reqwest v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/reqwest)
   Compiling gst-plugin-claxon v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/audio/claxon)
   Compiling gst-plugin-textahead v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/text/ahead)
   Compiling gst-plugin-quinn v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/quinn)
   Compiling gst-plugin-streamgrouper v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/generic/streamgrouper)
   Compiling gst-plugin-lewton v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/audio/lewton)
   Compiling gst-plugin-webrtc v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/webrtc)
   Compiling gst-plugin-gif v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/video/gif)
   Compiling gst-plugin-originalbuffer v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/generic/originalbuffer)
   Compiling gst-plugin-mpegtslive v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/mpegtslive)
   Compiling gst-plugin-ffv1 v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/video/ffv1)
   Compiling gst-plugin-cdg v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/video/cdg)
   Compiling gst-plugin-fallbackswitch v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/utils/fallbackswitch)
   Compiling gst-plugin-livesync v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/utils/livesync)
   Compiling gst-plugin-onvif v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/onvif)
   Compiling gst-plugin-png v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/video/png)
   Compiling gst-plugin-tracers v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/utils/tracers)
   Compiling rustls-platform-verifier v0.5.3
   Compiling gst-plugin-audiofx v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/audio/audiofx)
   Compiling gst-plugin-fmp4 v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/mux/fmp4)
   Compiling quinn-proto v0.11.12
   Compiling gst-plugin-togglerecord v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/utils/togglerecord)
   Compiling gst-plugin-rtp v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/rtp)
   Compiling rcgen v0.13.2
   Compiling flume v0.11.1
   Compiling aws-config v1.5.18
   Compiling rtsp-types v0.1.3
   Compiling gst-plugin-threadshare v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/generic/threadshare)
   Compiling headers v0.4.0
   Compiling aws-sdk-s3 v1.76.0
   Compiling pcap-file v2.0.0
   Compiling web-transport-quinn v0.5.1
   Compiling gst-plugin-webrtc-signalling v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/webrtc/signalling)
   Compiling png v0.17.16
   Compiling pangocairo v0.21.0 (https://github.com/gtk-rs/gtk-rs-core?branch=main#8b1c516f)
   Compiling polling v3.7.4
   Compiling ctrlc v3.4.7
   Compiling async-channel v2.3.1
   Compiling gstreamer-analytics v0.24.0 (https://gitlab.freedesktop.org/gstreamer/gstreamer-rs?branch=main#c3d3ce5f)
   Compiling serde_with v3.12.0
   Compiling hrtf v0.8.1
   Compiling skia-safe v0.84.0
warning: `gst-plugin-webrtc-signalling` (lib) generated 1 warning (1 duplicate)
   (...continues...)

Desired output

$ cargo +nightly cbuild --release --library-type cdylib 
   Compiling cfg-if v1.0.0
   (...continues...)
   Compiling gst-plugin-webrtc-signalling-protocol v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/webrtc/protocol)
   Compiling byteorder_slice v3.0.0
   Compiling cookie-factory v0.3.3
   Compiling web-transport-proto v0.2.6
   Compiling yasna v0.5.2
   Compiling lru v0.12.5
   Compiling headers-core v0.3.0
   Compiling nanorand v0.7.0
   Compiling sprintf v0.4.2
   Compiling itertools v0.12.1
   Compiling bstr v1.12.0
   Compiling toml_datetime v0.6.9
   Compiling same-file v1.0.6
   Compiling weezl v0.1.8
   Compiling smawk v0.3.2
   Compiling scoped-tls v1.0.1
   Compiling new_debug_unreachable v1.0.6
   Compiling cdg v0.1.0
   Compiling unicode-width v0.2.0
   Compiling unicode-linebreak v0.1.5
   Compiling bitstream-io v2.6.0
   Compiling color_quant v1.1.0
   Compiling winnow v0.7.10
   Compiling fallible-iterator v0.3.0
   Compiling jiff v0.2.14
   Compiling gif v0.13.1
   Compiling sdp-types v0.1.8
   Compiling textwrap v0.16.2
   Compiling cdg_renderer v0.8.0
   Compiling warp v0.3.7
   Compiling walkdir v2.5.0
   Compiling toml_edit v0.22.26
   Compiling async-stream v0.3.6
   Compiling gst-plugin-rav1e v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/video/rav1e)
   Compiling gst-plugin-textwrap v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/text/wrap)
   Compiling gst-plugin-uriplaylistbin v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/utils/uriplaylistbin)
   Compiling gst-plugin-raptorq v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/raptorq)
   Compiling gst-plugin-webrtchttp v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/webrtchttp)
   Compiling gst-plugin-inter v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/generic/inter)
   Compiling gst-plugin-ndi v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/ndi)
   Compiling env_logger v0.11.8
   Compiling gst-plugin-rtsp v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/rtsp)
   Compiling gst-plugin-regex v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/text/regex)
   Compiling gst-plugin-skia v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/video/skia)
   Compiling gst-plugin-hlssink3 v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/hlssink3)
   Compiling gst-plugin-aws v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/aws)
   Compiling gst-plugin-gopbuffer v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/generic/gopbuffer)
   Compiling gst-plugin-relationmeta v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/relationmeta)
   Compiling gst-plugin-mp4 v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/mux/mp4)
   Compiling gst-plugin-hsv v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/video/hsv)
   Compiling gst-plugin-json v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/text/json)
   Compiling gst-plugin-reqwest v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/reqwest)
   Compiling gst-plugin-claxon v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/audio/claxon)
   Compiling gst-plugin-textahead v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/text/ahead)
   Compiling gst-plugin-quinn v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/quinn)
   Compiling gst-plugin-streamgrouper v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/generic/streamgrouper)
   Compiling gst-plugin-lewton v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/audio/lewton)
   Compiling gst-plugin-webrtc v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/webrtc)
   Compiling gst-plugin-gif v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/video/gif)
   Compiling gst-plugin-originalbuffer v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/generic/originalbuffer)
   Compiling gst-plugin-mpegtslive v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/mpegtslive)
   Compiling gst-plugin-ffv1 v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/video/ffv1)
   Compiling gst-plugin-cdg v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/video/cdg)
   Compiling gst-plugin-fallbackswitch v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/utils/fallbackswitch)
   Compiling gst-plugin-livesync v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/utils/livesync)
   Compiling gst-plugin-onvif v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/onvif)
   Compiling gst-plugin-png v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/video/png)
   Compiling gst-plugin-tracers v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/utils/tracers)
   Compiling rustls-platform-verifier v0.5.3
   Compiling gst-plugin-audiofx v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/audio/audiofx)
   Compiling gst-plugin-fmp4 v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/mux/fmp4)
   Compiling quinn-proto v0.11.12
   Compiling gst-plugin-togglerecord v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/utils/togglerecord)
   Compiling gst-plugin-rtp v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/rtp)
   Compiling rcgen v0.13.2
   Compiling flume v0.11.1
   Compiling aws-config v1.5.18
   Compiling rtsp-types v0.1.3
   Compiling gst-plugin-threadshare v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/generic/threadshare)
   Compiling headers v0.4.0
   Compiling aws-sdk-s3 v1.76.0
   Compiling pcap-file v2.0.0
   Compiling web-transport-quinn v0.5.1
   Compiling gst-plugin-webrtc-signalling v0.14.0-alpha.1 (/Volumes/Centricular/gstreamer/subprojects/gst-plugins-rs/net/webrtc/signalling)
   Compiling png v0.17.16
   Compiling pangocairo v0.21.0 (https://github.com/gtk-rs/gtk-rs-core?branch=main#8b1c516f)
   Compiling polling v3.7.4
   Compiling ctrlc v3.4.7
   Compiling async-channel v2.3.1
   Compiling gstreamer-analytics v0.24.0 (https://gitlab.freedesktop.org/gstreamer/gstreamer-rs?branch=main#c3d3ce5f)
   Compiling serde_with v3.12.0
   Compiling hrtf v0.8.1
   Compiling skia-safe v0.84.0
   (...continues...)

Rationale and extra context

#138139 introduced a new warning for when native-static-libs is used against a non-staticlib crate. This rustc flag is used by Cargo-C to determine the link line that should go inside the pkg-config module for the corresponding library.

I do not know why the warning was introduced, but in non-staticlib, non-cdylib crates like the one highlighted earlier, it seems to be redundant.

Other cases

Rust Version

rustc 1.89.0-nightly (e703dff8f 2025-06-11)
binary: rustc
commit-hash: e703dff8fe220b78195c53478e83fb2f68d8499c
commit-date: 2025-06-11
host: aarch64-apple-darwin
release: 1.89.0-nightly
LLVM version: 20.1.5

Anything else?

Downstream bug report: lu-zero/cargo-c#469

@amyspark amyspark added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 16, 2025
@workingjubilee
Copy link
Member

cc @xizheyin @ChrisDenton

@ChrisDenton
Copy link
Member

Personally I'd be in favour of just reverting it.

@workingjubilee workingjubilee changed the title Spurious native-static-libs warning when building a cdylib with Cargo-C on macOS Frivolous native-static-libs warning when building a cdylib with Cargo-C on macOS Jun 16, 2025
@workingjubilee
Copy link
Member

The warning does not seem to be spurious, in that it is technically correct.

It just seems to be of dubious value in its current overeager state.

@workingjubilee
Copy link
Member

Specifically, I think the warning focuses on --print native-static-libs instead of considering --emit metadata, which is what makes it so we won't emit the relevant binary, to be the "true offender" here.

@xizheyin
Copy link
Contributor

The warning about --print native-static-libs may be problematic because it doesn't consider the complexity of modern build systems. When using tools like Cargo-C to build a cdylib, this warning is potentially confusing, since the user's intent is clearly to build a dynamic library.

We could target a narrower set of use cases or shifts focus to --emit instead of --print native-static-libs. This would make the compiler's feedback more meaningful in real-world build scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants