Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 Sep 2024 18:19:54 -0600
From:      Alan Somers <asomers@freebsd.org>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        Jacques Fourie <jacques.fourie@gmail.com>, 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:  <CAOtMX2ihT%2BwDu3LCe1aWAFUnp2virMPojVHfPXX-7wKSUbiK6g@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
On Wed, Sep 4, 2024 at 6:12=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 l=
ibc.
> > >
> >
> > Looking at the Rust libc bindings I see the following:
> > https://github.com/rust-lang/libc/blob/72c40004a3568849055c0bab5c92c997=
5b4eb132/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs#L8
> > https://github.com/rust-lang/libc/blob/72c40004a3568849055c0bab5c92c997=
5b4eb132/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 pl=
ace
> 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.

The short answer is that Rust binaries still assume a FreeBSD 11 ABI.

The slightly longer answer is that while definitions are in place for
FreeBSD 12, 13, and 14, there's actually no way to enable them outside
of libc's CI system.  CARGO_FEATURE_RUSTC_DEP_OF_STD is a variable set
while building the standard library.  It allows the standard library
to use a different FreeBSD ABI version than libc.

And here is the PR that will finally raise the ABI to FreeBSD 12.
It's not getting much attention, unfortunately, because none of either
libc nor rustc's maintainers are FreeBSD developers, and they're
afraid to make changes like this.

https://github.com/rust-lang/libc/pull/2406



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOtMX2ihT%2BwDu3LCe1aWAFUnp2virMPojVHfPXX-7wKSUbiK6g>