You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For build reproductions of static glibc, musl, eyra (with "hello world" std and no_std examples) a revised unified reference example can be found at: docs: hello-world-small example size update #50
Extracted to separate issues from discussions in this issue:
libc + no_std:
Unlike the static no_std example below, the revised variant instead avoids the libc crate calls - which removes the need for glibc/musl targets to include:
// Uses the internal rust libc (glibc/musl) for static builds instead? For this to work:// - `Cargo.toml` should not have a `libc` dependency specified.// - Do not build std via the `-Z build-std=std` option, which would replace the prebuilt private copy.#![feature(rustc_private)]externcrate libc;
Alternatively with cargo add libc --no-default-features instead you do not need those two lines in src/main.rs.
With libc crate in Cargo.toml, now -Z build-std will be compatible to build with (redundant for no_std?), but doing so requires additional RUSTFLAGS depending on glibc or musl target (just like the above linked revised no_std example):
--target x86_64-unknown-linux-gnu will need:
-C link-arg=/usr/lib64/libc.a -C link-arg=/usr/lib/gcc/x86_64-redhat-linux/14/libgcc_eh.a. These locations for *.a static libs are specific to Fedora 41 from the glibc-static package.
Alternatively could be expressed as -L /usr/lib64 -L link-arg=/usr/lib/gcc/x86_64-redhat-linux/14 -C link-arg=-lgcc_eh (-C link-arg=-lc is implicit from libc crate?). The -L hints don't seem necessary in this case, -C link-arg=-lgcc_eh alone works.
--target x86_64-unknown-linux-musl will need -C link-arg=-lc which pairs with the implicit -C link-self-contained=yes for this target (without =yes that -lc may unintentionally dynamically link the host libc library, update: may vary by environment/linker?).
NOTE: Related to these caveats for libc usage, if considering the optimizations detailed in the sunfishcode/origin tiny example README, the -N / --omagic link arg introduces a segfault with -musl target and the implicit -C link-self-contained=yes, but not when set to =no explicitly (or using -Z build-std which has roughly the same effect).
Original message
I am used to building with the *-musl target, but noticed that eyra is not compatible (default hello world example generated from cargo init).
--target :
✔️ x86_64-unknown-linux-gnu
❌ x86_64-unknown-linux-musl
I know the README clarifies the support constraints to linux, but doesn't highlight the -gnu vs -musl target compatibility? I didn't think it would matter with eyra?
Might be worthwhile to convey that incompatibility in the README too?
UPDATE (7th Oct 2024):
no_stdexamples) a revised unified reference example can be found at: docs:hello-world-smallexample size update #50no_stdadditions specific to eyra forpanic = "abort"usage via theunwindingcrate (avoid theeh_personalityrequirement)libc+no_std:Unlike the static
no_stdexample below, the revised variant instead avoids thelibccrate calls - which removes the need for glibc/musl targets to include:Alternatively with
cargo add libc --no-default-featuresinstead you do not need those two lines insrc/main.rs.With
libccrate inCargo.toml, now-Z build-stdwill be compatible to build with (redundant forno_std?), but doing so requires additionalRUSTFLAGSdepending on glibc or musl target (just like the above linked revisedno_stdexample):--target x86_64-unknown-linux-gnuwill need:-C link-arg=/usr/lib64/libc.a -C link-arg=/usr/lib/gcc/x86_64-redhat-linux/14/libgcc_eh.a. These locations for*.astatic libs are specific to Fedora 41 from theglibc-staticpackage.-L /usr/lib64 -L link-arg=/usr/lib/gcc/x86_64-redhat-linux/14 -C link-arg=-lgcc_eh(-C link-arg=-lcis implicit fromlibccrate?). The-Lhints don't seem necessary in this case,-C link-arg=-lgcc_ehalone works.--target x86_64-unknown-linux-muslwill need-C link-arg=-lcwhich pairs with the implicit-C link-self-contained=yesfor this target (without=yesthat-lcmay unintentionally dynamically link the host libc library, update: may vary by environment/linker?).NOTE: Related to these caveats for
libcusage, if considering the optimizations detailed in thesunfishcode/origintiny example README, the-N/--omagiclink arg introduces a segfault with-musltarget and the implicit-C link-self-contained=yes, but not when set to=noexplicitly (or using-Z build-stdwhich has roughly the same effect).Original message
I am used to building with the
*-musltarget, but noticed thateyrais not compatible (default hello world example generated fromcargo init).--target:x86_64-unknown-linux-gnux86_64-unknown-linux-muslI know the README clarifies the support constraints to linux, but doesn't highlight the
-gnuvs-musltarget compatibility? I didn't think it would matter witheyra?Might be worthwhile to convey that incompatibility in the README too?
Reproduction
Some error messages from
-musltarget attempt:Potentially related to?:
libccrate musl compatibility (may be resolved forlibc 0.3release)-C link-arg=-nostartfileson musl target