-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Cargo doesn't allow to pass extra linker arguments per binary or for examples #9542
Comments
Have you checked out the rustc-link-arg feature? That allows you to specify per-binary linker arguments in a build script. It is currently only on nightly, but would be good to have someone test it out. |
@ehuss Unfortunately I don't see this option as available on |
The |
@ehuss, it worked!! Thank you very much, you really saved the day :) I think we won't need the feature I have requested when your option is stabilized, so please feel free to close the issue. |
However, I have one more question: is there a possibility to add this option to cargo config or manifest so that one doesn’t have to use it explicitly on command line? |
@ehuss, also, judging from the fact this option is pretty young I can guess it's kind of early to ask this, but anyway, is there any sort of vision regarding the timeline of stabilization of this flag? Thanks! |
Before it is stabilized, you can place it in the There is a proposal to stabilize it at #9557. I'm not sure how long it will take, though. We just discovered an issue with the implementation which will need to be resolved first. Closing since this seems to be resolved. |
Hello, I need to export some specific symbols from the binaries that use my library (including the examples that are in the same crate), and to do this, I have to pass some extra linker args since nothing is exported by default. But unfortunately, .cargo/config.toml doesn't allow to specify extra compiler/linker args with fine granularity: it applies the
build.rustflags
option contents to every compiler call, which is unfortunate since the dependencies of my library (and my library itself) do not contain the required symbols and thus fail to link.Ideally, I'd love to have a language attribute that would allow forwarding extra compiler args from source, but it looks like a serious and probably controversial change, so I believe this issue should be handled on cargo level.
As to my taste, the most obvious place to put extra flags is cargo.toml (since it's the place where some people, including me and the reporter of #3261, have tried to put this flag :)), but since it has not been done already, I can guess there are some arguments against it? So please share your thoughts.
Thanks!
The text was updated successfully, but these errors were encountered: