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
Finally, we add a RUSTFLAGS flag with .cargo/config.toml:
rustflags = ["-Z", "trap-unreachable=no"]
This disables the use of trap instructions, such as ud2 on x86-64, at places the compiler thinks should be unreachable, such as after the jmp in _start or after the syscall that calls exit_group, because rustix uses the noreturn inline asm option. Normally this is a very good thing, but it does take a few extra bytes.
This will not prevent an ud2 instruction from being generated after the exit_group syscall on the latest version of rustix due to bytecodealliance/rustix#1444, discussed in bytecodealliance/rustix#1433. Perhaps this should be removed from example-crates/tiny to prevent confusion. Anyone who wants to save space by omitting the ud2 instruction can use the syscalls crate to issue the relevant syscall directly.
As an alternative, bytecodealliance/rustix#1444 can be put behind a feature gate, something like seccomp-bpf-compat, or as an opt-out, no-seccomp-bpf-compat.
The text was updated successfully, but these errors were encountered:
Interesting. trap-unreachable=no still does prevent a ud2 in places the compiler thinks should be unreachable. Without it, and with bytecodealliance/rustix#1444, we now get two ud2s. trap-unreachable=no makes it only have one ud2. Agreed, we should update the README.md to mention that.
I'm not super concerned about implementing every last optimization; the README.md already describes a few others that aren't implemented as well. And at some point, if people really want the smallest possible binary where every possible byte is optimized out, they'll need to do this instead anyway.
Uh oh!
There was an error while loading. Please reload this page.
https://github.com/sunfishcode/origin/tree/d0c8ff8c6b4e39b8cb6c2571e2db0a431c2a1f71/example-crates/tiny
This will not prevent an
ud2
instruction from being generated after theexit_group
syscall on the latest version ofrustix
due to bytecodealliance/rustix#1444, discussed in bytecodealliance/rustix#1433. Perhaps this should be removed fromexample-crates/tiny
to prevent confusion. Anyone who wants to save space by omitting theud2
instruction can use the syscalls crate to issue the relevant syscall directly.As an alternative, bytecodealliance/rustix#1444 can be put behind a feature gate, something like
seccomp-bpf-compat
, or as an opt-out,no-seccomp-bpf-compat
.The text was updated successfully, but these errors were encountered: