Skip to content

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

Closed
@ralismark

Description

@ralismark

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");
}

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions