Skip to content

expose --link-args to rustc #1294

New issue

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

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

Already on GitHub? # to your account

Closed
wants to merge 4 commits into from
Closed

expose --link-args to rustc #1294

wants to merge 4 commits into from

Conversation

erickt
Copy link
Contributor

@erickt erickt commented Dec 14, 2011

This is useful for writing configure scripts for extension libraries. It also includes a typo fix, some code cleanup, and a test for getopts.

@brson
Copy link
Contributor

brson commented Dec 14, 2011

Can you add --link-args to the man page as well?

@graydon
Copy link
Contributor

graydon commented Dec 14, 2011

I'm curious if this needs to exist as a flag, or can migrate up into an attribute.

The rule of thumb I'm aiming for is "anything a crate actually needs, to compile-link-run, should be expressible in the source code via an attribute or something, not a mandatory command-line flag". IOW, I'd like "rustc foo.rc" to compile a crate in a default-sane mode as best it can, and reserve options merely for variations-on-a-build (optimization, debugging, profiling, libraries in an unusual spot, etc.) that a user may or may not want to influence.

@brson
Copy link
Contributor

brson commented Dec 14, 2011

I added #1301 to allow link_args on crates. #612 (config files) and #1242 (applying attributes by cfg) could be helpful to make .rc files more useful for describing the build.

@erickt
Copy link
Contributor Author

erickt commented Dec 15, 2011

I updated the pull request with the man page change.

@brson
Copy link
Contributor

brson commented Dec 15, 2011

erickt, could your use case be satisfied by a combination of 1) adding a crate-level #[link_args] attribute, 2) adding a mechanism to select attributes base on configuration, e.g. #[cfg_attr(target_os = "macos", link_args = "-framework opengl")], and 3) using the existing --cfg flag?

Regardless of whether we want a --link-args flag, we should merge the other three commits.

@erickt
Copy link
Contributor Author

erickt commented Dec 15, 2011

I wanted to use this to link a .o file into the rust library. It could be replaced with a static library though. I'll withdraw this request for now and resubmit it with the other three commits.

@erickt erickt closed this Dec 15, 2011
bjorn3 added a commit to bjorn3/rust that referenced this pull request Mar 15, 2023
coastalwhite pushed a commit to coastalwhite/rust that referenced this pull request Aug 5, 2023
celinval pushed a commit to celinval/rust-dev that referenced this pull request Jun 4, 2024
Kobzol pushed a commit to Kobzol/rust that referenced this pull request Dec 30, 2024
bors pushed a commit to rust-lang-ci/rust that referenced this pull request Jan 2, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants