Date: Wed, 4 Sep 2024 18:10:06 -0700 From: Jacques Fourie <jacques.fourie@gmail.com> To: Konstantin Belousov <kostikbel@gmail.com> Cc: Cy Schubert <Cy.Schubert@cschubert.com>, Jan Knepper <jan@digitaldaemon.com>, Mark Delany <x9k@charlie.emu.st>, freebsd-hackers@freebsd.org Subject: Re: Rust: kernel vs user-space Message-ID: <CALX0vxBerLn4Mmu8D6DyAHyvg3iFMrVRjt-K1jCjF5RVVELAGQ@mail.gmail.com> In-Reply-To: <Ztj3ITmqq68bRBbI@kib.kiev.ua> References: <0.2.0-final-1725440949.866-0xb4bb20@qmda.emu.st> <78BC157F-6E30-49C4-931D-9EB539BD0322@digitaldaemon.com> <20240904221522.63E0366@slippy.cwsent.com> <Ztjh773c6Rwo6BTQ@kib.kiev.ua> <CALX0vxCq0hVocahyoe_wk7NG2nF55T2ue7enUR33sPZHtKnqUw@mail.gmail.com> <Ztj3ITmqq68bRBbI@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
--000000000000243d8b062154f445 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Sep 4, 2024 at 5:13=E2=80=AFPM Konstantin Belousov <kostikbel@gmail= .com> wrote: > On Wed, Sep 04, 2024 at 04:43:31PM -0700, Jacques Fourie wrote: > > On Wed, Sep 4, 2024 at 3:41=E2=80=AFPM Konstantin Belousov <kostikbel@g= mail.com> > > wrote: > > > > > On Wed, Sep 04, 2024 at 03:15:22PM -0700, Cy Schubert wrote: > > > > In message <78BC157F-6E30-49C4-931D-9EB539BD0322@digitaldaemon.com>= , > > > Jan > > > > Kneppe > > > > r writes: > > > > > D > > > > > > > > > > www.dlang.org > > > > > > > > The problem with D is data structure definitions need to also be > > > mirrored > > > > (duplicated) in D. For example, when 64-bit inodes were implemented= D > > > > failed to build and generate any code. The reason for this was > > > > ufs/ufs/inode.h now defined 64-bit inodes while the D representatio= n > as > > > > provided by the D language were still 32-bit. I had opened an issue > with > > > > upstream regarding this. To this day they still haven't figured out > how > > > to > > > > implement 64-bit inodes on newer FreeBSD systems while maintaining > > > 32-bit > > > > inode backward compatibility on older FreeBSD systems (as FreeBSD > > > > implemented this using ifunc). > > > > > > Rust is same. It still uses pre-ino64 bindings for both stdlib and > libc. > > > > > > > Looking at the Rust libc bindings I see the following: > > > https://github.com/rust-lang/libc/blob/72c40004a3568849055c0bab5c92c9975b= 4eb132/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs#L8 > > > https://github.com/rust-lang/libc/blob/72c40004a3568849055c0bab5c92c9975b= 4eb132/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs#L5 > > > > Seems to have changed to 64 bit for FreeBSD 12 and up? > > Rust libc seems to make some strange things to follow FreeBSD ABI > evolution, which is not done e.g. for glibc. But anyway, the relevant > place > to look seems to be a comment and decision code at > > https://github.com/rust-lang/libc/blob/72c40004a3568849055c0bab5c92c9975b= 4eb132/build.rs#L44 > > By default they seems to use FreeBSD 11 ABI from freebsd11 module still. > I do not know what is CARGO_FEATURE_RUSTC_DEP_OF_STD. > > CARGO_FEATURE_RUSTC_DEP_OF_STD is an environment variable set by cargo when libc is built with the rustc-dep-of-std feature, as is done when building the std library. What this means is that the std library uses a libc ABI that is backwards compatible with FreeBSD 12. When using a standalone libc from crates.io you will get libc bindings that are backwards compatible with FreeBSD 11. Definitely not entirely clear to me. I made a small sample app that prints the size of libc::ino_t. Building this app without any environment variables defined results in a size of 4. Building with `LIBC_CI=3D1` results in a size of 8, as does building with `CARGO_FEATURE_RUSTC_DEP_OF_STD=3D1`. These tests were done on a host runni= ng FreeBSD 15. --000000000000243d8b062154f445 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">= <div dir=3D"ltr" class=3D"gmail_attr">On Wed, Sep 4, 2024 at 5:13=E2=80=AFP= M Konstantin Belousov <<a href=3D"mailto:kostikbel@gmail.com">kostikbel@= gmail.com</a>> wrote:<br></div><blockquote class=3D"gmail_quote" style= =3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;= border-left-color:rgb(204,204,204);padding-left:1ex">On Wed, Sep 04, 2024 a= t 04:43:31PM -0700, Jacques Fourie wrote:<br> > On Wed, Sep 4, 2024 at 3:41=E2=80=AFPM Konstantin Belousov <<a href= =3D"mailto:kostikbel@gmail.com" target=3D"_blank">kostikbel@gmail.com</a>&g= t;<br> > wrote:<br> > <br> > > On Wed, Sep 04, 2024 at 03:15:22PM -0700, Cy Schubert wrote:<br> > > > In message <<a href=3D"mailto:78BC157F-6E30-49C4-931D-9EB= 539BD0322@digitaldaemon.com" target=3D"_blank">78BC157F-6E30-49C4-931D-9EB5= 39BD0322@digitaldaemon.com</a>>,<br> > > Jan<br> > > > Kneppe<br> > > > r writes:<br> > > > > D<br> > > > ><br> > > > > <a href=3D"http://www.dlang.org" rel=3D"noreferrer" tar= get=3D"_blank">www.dlang.org</a><br> > > ><br> > > > The problem with D is data structure definitions need to als= o be<br> > > mirrored<br> > > > (duplicated) in D. For example, when 64-bit inodes were impl= emented D<br> > > > failed to build and generate any code. The reason for this w= as<br> > > > ufs/ufs/inode.h now defined 64-bit inodes while the D repres= entation as<br> > > > provided by the D language were still 32-bit. I had opened a= n issue with<br> > > > upstream regarding this. To this day they still haven't = figured out how<br> > > to<br> > > > implement 64-bit inodes on newer FreeBSD systems while maint= aining<br> > > 32-bit<br> > > > inode backward compatibility on older FreeBSD systems (as Fr= eeBSD<br> > > > implemented this using ifunc).<br> > ><br> > > Rust is same.=C2=A0 It still uses pre-ino64 bindings for both std= lib and libc.<br> > ><br> > <br> > Looking at the Rust libc bindings I see the following:<br> > <a href=3D"https://github.com/rust-lang/libc/blob/72c40004a3568849055c= 0bab5c92c9975b4eb132/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs#L8" = rel=3D"noreferrer" target=3D"_blank">https://github.com/rust-lang/libc/blob= /72c40004a3568849055c0bab5c92c9975b4eb132/src/unix/bsd/freebsdlike/freebsd/= freebsd11/mod.rs#L8</a><br> > <a href=3D"https://github.com/rust-lang/libc/blob/72c40004a3568849055c= 0bab5c92c9975b4eb132/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs#L5" = rel=3D"noreferrer" target=3D"_blank">https://github.com/rust-lang/libc/blob= /72c40004a3568849055c0bab5c92c9975b4eb132/src/unix/bsd/freebsdlike/freebsd/= freebsd12/mod.rs#L5</a><br> > <br> > Seems to have changed to 64 bit for FreeBSD 12 and up?<br> <br> Rust libc seems to make some strange things to follow FreeBSD ABI<br> evolution, which is not done e.g. for glibc.=C2=A0 But anyway, the relevant= place<br> to look seems to be a comment and decision code at<br> <a href=3D"https://github.com/rust-lang/libc/blob/72c40004a3568849055c0bab5= c92c9975b4eb132/build.rs#L44" rel=3D"noreferrer" target=3D"_blank">https://= github.com/rust-lang/libc/blob/72c40004a3568849055c0bab5c92c9975b4eb132/bui= ld.rs#L44</a><br> <br> By default they seems to use FreeBSD 11 ABI from freebsd11 module still.<br= > I do not know what is CARGO_FEATURE_RUSTC_DEP_OF_STD.<br> <br></blockquote><div>CARGO_FEATURE_RUSTC_DEP_OF_STD is an environment vari= able set by cargo when libc is built with the rustc-dep-of-std=C2=A0feature= , as is done when building the std library. What this means is that the std= library uses a libc ABI that is backwards compatible with FreeBSD 12. When= using a standalone libc from <a href=3D"http://crates.io">crates.io</a> yo= u will get libc bindings that are backwards compatible with FreeBSD 11. Def= initely not entirely clear to me. I made a small sample app that prints the= size of libc::ino_t. Building this app without any environment variables d= efined results in a size of 4. Building with `LIBC_CI=3D1` results in a siz= e of 8, as does building with `CARGO_FEATURE_RUSTC_DEP_OF_STD=3D1`. These t= ests were done on a host running FreeBSD 15.</div></div></div> --000000000000243d8b062154f445--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CALX0vxBerLn4Mmu8D6DyAHyvg3iFMrVRjt-K1jCjF5RVVELAGQ>