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

A no_std Rust binary -- link_args feature has been removed #87

Closed
ralismark opened this issue Jul 26, 2022 · 1 comment
Closed

A no_std Rust binary -- link_args feature has been removed #87

ralismark opened this issue Jul 26, 2022 · 1 comment
Assignees

Comments

@ralismark
Copy link

Where's the problem at?
https://fasterthanli.me/series/making-our-own-executable-packer/part-12

No, seriously, where is it?

The fourth way is to.. opt into another unstable feature:
[Rust code]
[Shell session]
Hey, it built!

Describe the issue and a fix if you know it
This errors out with a recent rustc (I'm using rustc 1.62.0 (Arch Linux rust 1:1.62.0-1)):

error[E0557]: feature has been removed
 --> src/sel4user/main.rs:5:12
  |
5 | #![feature(link_args)]
  |            ^^^^^^^^^ feature has been removed
  |
  = note: removed in favor of using `-C link-arg=ARG` on command line, which is available from cargo build scripts with `cargo:rustc-link-arg` now

error: cannot find attribute `link_args` in this scope
 --> src/sel4user/main.rs:8:3
  |
8 | #[link_args = "-nostartfiles"]
  |   ^^^^^^^^^ help: a built-in attribute with a similar name exists: `linkage`

For more information about this error, try `rustc --explain E0557`.

I've managed to get it to work with this build.rs build script

fn main() {
    // don't link with stdlib
    println!("cargo:rustc-link-arg-bin=<NAME OF BINARY>=-nostartfiles");
}
@fasterthanlime
Copy link
Owner

Thanks for the research! I've updated the article.

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

No branches or pull requests

2 participants