Skip to content

-nostartfiles not found #154

Open
Open

Description

@DasLixou

I'm doing something wrong but don't know what. I'm trying to replicate tiny-hello example but get this error:

error: linking with `rust-lld` failed: exit status: 1
  = note: rust-lld: error: unknown argument '-nostartfiles'

When I remove the

println!("cargo:rustc-link-arg=-nostartfiles");

from the build.rs, the resulting binary has no .text section at all.

I'm compiling with nightly and use origin = { version = "0.24.0", default-features = false, features = ["origin-start", "nightly"] }.

Thanks for your help :)

Activity

  1. sunfishcode commented on Feb 25, 2025

    @sunfishcode
    Owner

    What target are you using?

  2. DasLixou commented on Feb 25, 2025

    @DasLixou
    Author

    x86_64-unknown-linux-none

  3. sunfishcode commented on Feb 25, 2025

    @sunfishcode
    Owner

    Origin currently assumes it's using the x86_64-unknown-linux-gnu target (and similar targets for other architectures). It disables the actual glibc implementation (that's what that -nostartfiles flag is for) and uses its own implementations.

    In theory it should be possible to support the x86_64-unknown-linux-none target in origin; it just hasn't been done yet.

  4. DasLixou commented on Feb 26, 2025

    @DasLixou
    Author

    Hmmm looking at the code for a bit, I don't understand why it didn't generate any code with the none Target and without the linker flag...

  5. sunfishcode commented on Feb 26, 2025

    @sunfishcode
    Owner

    I don't know.

  6. bjorn3 commented on Feb 26, 2025

    @bjorn3
    Contributor

    You could try adding -e _start as argument. Also check if there were any linker warnings. A rustc PR to show linker warnings by default was recently merged, so make sure you have a new enough nightly.

  7. DasLixou commented on Feb 27, 2025

    @DasLixou
    Author

    You could try adding -e _start as argument. Also check if there were any linker warnings. A rustc PR to show linker warnings by default was recently merged, so make sure you have a new enough nightly.

    No linker errors, -e _start also sadly didn't help :c (yes, I updated and run the latest nightly from 02-26)

  8. DasLixou commented on Feb 27, 2025

    @DasLixou
    Author

    Weird, even with cargo +nightly r --target x86_64-unknown-linux-gnu --release and -nostartfiles it doesn't generate any code in .text section...

  9. DasLixou commented on Feb 27, 2025

    @DasLixou
    Author

    Okay, I tried everything and... found a solution! I don't know why it works or why it's needed, but the only thing I had to write is an explicit extern crate origin; at the top of the file.... can anybody explain this to me?

  10. DasLixou commented on Feb 27, 2025

    @DasLixou
    Author

    And now my console gets flooded with errors of not found types for -none target

  11. bjorn3 commented on Feb 27, 2025

    @bjorn3
    Contributor

    I don't know why it works or why it's needed, but the only thing I had to write is an explicit extern crate origin; at the top of the file.... can anybody explain this to me?

    Right, without extern crate origin;, use origin as _; or some other reference to origin in the source code, rustc will not load origin as dependency and thus not link it.

    And now my console gets flooded with errors of not found types for -none target

    You are building origin with the std feature disabled?

  12. DasLixou commented on Feb 27, 2025

    @DasLixou
    Author

    I suspect so, yeah.
    The errors seem to come from not knowing types without the gnu impl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions