`-nostartfiles` not found
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 :)
What target are you using?
x86_64-unknown-linux-none
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.
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...
I don't know.
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.
You could try adding
-e _startas 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)
Weird, even with cargo +nightly r --target x86_64-unknown-linux-gnu --release and -nostartfiles it doesn't generate any code in .text section...
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?
And now my console gets flooded with errors of not found types for -none target
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?
I suspect so, yeah. The errors seem to come from not knowing types without the gnu impl