Skip to content
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

rustc: Implement -l and include! tweaks #18470

Merged
merged 1 commit into from
Nov 3, 2014
Merged

Conversation

alexcrichton
Copy link
Member

This is an implementation of the rustc bits of RFC 403. This adds a new
flag to the compiler, -l, as well as tweaking the include! macro (and
related source-centric macros).

The compiler's new -l flag is used to link libraries in from the command line.
This flag stacks with #[link] directives already found in the program. The
purpose of this flag, also stated in the RFC, is to ease linking against native
libraries which have wildly different requirements across platforms and even
within distributions of one platform. This flag accepts a string of the form
NAME[:KIND] where KIND is optional or one of dylib, static, or framework.
This is roughly equivalent to if the equivalent #[link] directive were just
written in the program.

The include! macro has been modified to recursively expand macros to allow
usage of concat! as an argument, for example. The use case spelled out in RFC
403 was for env! to be used as well to include compile-time generated files.
The macro also received a bit of tweaking to allow it to expand to either an
expression or a series of items, depending on what context it's used in.

Closes #18473

// option. This file may not be copied, modified, or distributed
// except according to those terms.

// ignore-test: this is not a test
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it'd be less sketchy to put these in auxilliary.

@brson
Copy link
Contributor

brson commented Oct 31, 2014

r=me with comments addressed

This is an implementation of the rustc bits of [RFC 403][rfc]. This adds a new
flag to the compiler, `-l`, as well as tweaking the `include!` macro (and
related source-centric macros).

The compiler's new `-l` flag is used to link libraries in from the command line.
This flag stacks with `#[link]` directives already found in the program. The
purpose of this flag, also stated in the RFC, is to ease linking against native
libraries which have wildly different requirements across platforms and even
within distributions of one platform. This flag accepts a string of the form
`NAME[:KIND]` where `KIND` is optional or one of dylib, static, or framework.
This is roughly equivalent to if the equivalent `#[link]` directive were just
written in the program.

The `include!` macro has been modified to recursively expand macros to allow
usage of `concat!` as an argument, for example. The use case spelled out in RFC
403 was for `env!` to be used as well to include compile-time generated files.
The macro also received a bit of tweaking to allow it to expand to either an
expression or a series of items, depending on what context it's used in.

[rfc]: rust-lang/rfcs#403
@tomaka
Copy link
Contributor

tomaka commented Oct 31, 2014

Shouldn't include_src! and include_bin! be modified too?

@alexcrichton
Copy link
Member Author

The helper function that I modified was actually called by both of them as well, so that whole family of macros should benefit!

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Oct 31, 2014
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Nov 3, 2014
@bors bors merged commit 8e6e846 into rust-lang:master Nov 3, 2014
@alexcrichton alexcrichton deleted the dash-l branch November 3, 2014 23:14
lnicola pushed a commit to lnicola/rust that referenced this pull request Nov 4, 2024
Allow interpreting consts and statics with interpret function command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement the -l flag for native linking
5 participants