Repository navigation
libc used with "link-arg=-nostartfiles"? #5683
|
Can rustflags = [-"C", "link-arg=-nostartfiles"]or with rustflags = [
"-C", "link-arg=-nostartfiles",
"-C", "target-feature=-crt-static"
]? Goal: Simple I understand that libc's but I'm getting either or (just as a side note): a SIGSEGV from the build script - if I apply I'm |
Replies: 2 comments 1 reply
|
There are two separate things to fix here. With libc 0.2.191 on [dependencies]
libc = { version = "=0.2.191", default-features = false }The crate is already Scope the startup flag to the target and pass # .cargo/config.toml
[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "link-arg=-nostartfiles"]cargo build --release --target x86_64-unknown-linux-gnuEven when host and target match, the explicit target keeps those flags away from host build scripts. Also check for existing There is a third detail with a raw ELF entry: the kernel does not call The native Ubuntu check used Rust 1.99.1 and libc 0.2.191. Debug and release each printed the exact output and exited successfully in three separate runs. It also checked both host build-script witnesses, reproduced the missing-link and global-host-flag failures, verified the ELF entry and libc imports, checked a failed write, and required a deliberately reachable panic to fail at link. This is a narrow GNU/Linux x86_64 example. Bypassing CRT initialization does not establish support for arbitrary libc APIs; for an application needing normal C runtime setup, retaining startup and exposing C |
|
Wow, thank you @tevinch. Side note: All I needed from
https://github.com/peter-lyons-kehl/panic-never-rs/tree/master/examples |
There are two separate things to fix here.
With libc 0.2.191 on
x86_64-unknown-linux-gnu, use:The crate is already
no_std. Its default feature namedstdassumes Rust's actualstdsupplies the native library links; with that feature disabled, this release emits the GNU/Linux native links itself, includingc.-nostartfilesomits CRT startup objects but does not itself add-lc.Scope the startup flag to the target and pass
--targetexplicitly:Even when host and tar…