Re: Rust build system

2025-04-25 Thread Nikolaos Chatzikonstantinou
On Fri, Apr 25, 2025 at 8:51 AM Nikolaos Chatzikonstantinou
 wrote:
>
> On Fri, Apr 25, 2025 at 6:33 AM Bruno Haible  wrote:
> >
> > Nikolaos Chatzikonstantinou wrote:
> > > > One problem I see with Rust is that currently it does not integrate well
> > > > with the GNU Build system, in particular with VPATH builds (see [3] for
> > > > an example integration). Any improvements on that front would be 
> > > > welcome.
> > > >
> > > > [3] 
> > > > https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=tree;f=gettext-tools/examples/hello-rust;hb=HEAD
> > >
> > > What is the issue with VPATH builds?
> >
> > The issue is that 'cargo' mandates a certain directory layout of the
> > package, that is incompatible with VPATH builds.
>
> In the comments of configure.ac hello-rust claims to solve this issue
> though, is that not enough? I noticed that you're the author of it, so
> you must have something in mind.

Ah, here's a cheating solution:

mkdir -p "$BUILD_DIR" && cd "$BUILD_DIR"
ln -s "$SOURCE_DIR" $(basename "$SOURCE_DIR")
printf "[workspace]\nmembers = [ \"$SOURCE_DIR\" ]\n" > "Cargo.toml"
cargo build

In the above, SOURCE_DIR is set to the root of the source directory
and BUILD_DIR should be the VPATH directory.

Works like a charm!

Regards,
Nikolaos Chatzikonstantinou



Re: Rust build system

2025-04-25 Thread Nikolaos Chatzikonstantinou
On Fri, Apr 25, 2025 at 6:33 AM Bruno Haible  wrote:
>
> Nikolaos Chatzikonstantinou wrote:
> > > One problem I see with Rust is that currently it does not integrate well
> > > with the GNU Build system, in particular with VPATH builds (see [3] for
> > > an example integration). Any improvements on that front would be welcome.
> > >
> > > [3] 
> > > https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=tree;f=gettext-tools/examples/hello-rust;hb=HEAD
> >
> > What is the issue with VPATH builds?
>
> The issue is that 'cargo' mandates a certain directory layout of the
> package, that is incompatible with VPATH builds.

In the comments of configure.ac hello-rust claims to solve this issue
though, is that not enough? I noticed that you're the author of it, so
you must have something in mind.

> > I read the comments in
> > configure.ac of that link, it seems to copy certain files into the
> > build directory and then uses cargo. Would you rather if it used rustc
> > directly?
>
> How can a package not use 'cargo' if it needs some Rust libraries?

At least in my case of reimplementing m4 in Rust, I can probably do it
only using std Rust, and then it's easy to use the rustc compiler
directly avoiding cargo.

Regards,
Nikolaos Chatzikonstantinou



Re: Rust build system

2025-04-25 Thread Jeffrey Walton
On Fri, Apr 25, 2025 at 7:28 AM Bruno Haible  wrote:
>
> Jeffrey Walton wrote:
> > Also see Rust's Platform Support,
> > . Tier 1
> > is expected to build and run correctly. Tier 1 is i686, x86_64 and
> > some aarch64. Everything else, Tiers 2 & 3, are a best effort with no
> > guarantees.
>
> The web page that you point to summarizes it differently:
>   - Tier 1 is "guaranteed to work".
>   - Tier 2 is "guaranteed to build" and "often works".
>   - Tier 3 is best effort.
>
> And that is not very different from Gnulib's target platform policies [1].
> arm-linux-androideabi, i686-unknown-haiku, powerpc64-ibm-aix,
> m68k-unknown-linux-gnu are also "best effort" for Gnulib.
>
> Therefore the list of platform support is not deterring me from Rust.

Well, good luck with things!



Re: Rust build system

2025-04-25 Thread Bruno Haible via Gnulib discussion list
Jeffrey Walton wrote:
> Also see Rust's Platform Support,
> . Tier 1
> is expected to build and run correctly. Tier 1 is i686, x86_64 and
> some aarch64. Everything else, Tiers 2 & 3, are a best effort with no
> guarantees.

The web page that you point to summarizes it differently:
  - Tier 1 is "guaranteed to work".
  - Tier 2 is "guaranteed to build" and "often works".
  - Tier 3 is best effort.

And that is not very different from Gnulib's target platform policies [1].
arm-linux-androideabi, i686-unknown-haiku, powerpc64-ibm-aix,
m68k-unknown-linux-gnu are also "best effort" for Gnulib.

Therefore the list of platform support is not deterring me from Rust.

Bruno

[1] https://www.gnu.org/software/gnulib/manual/html_node/Target-Platforms.html






Re: Rust build system

2025-04-25 Thread Jeffrey Walton
On Fri, Apr 25, 2025 at 6:34 AM Bruno Haible via Gnulib discussion
list  wrote:
>
> Nikolaos Chatzikonstantinou wrote:
> > > One problem I see with Rust is that currently it does not integrate well
> > > with the GNU Build system, in particular with VPATH builds (see [3] for
> > > an example integration). Any improvements on that front would be welcome.
> > >
> > > [3] 
> > > https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=tree;f=gettext-tools/examples/hello-rust;hb=HEAD
> >
> > What is the issue with VPATH builds?
>
> The issue is that 'cargo' mandates a certain directory layout of the
> package, that is incompatible with VPATH builds.
>
> > I read the comments in
> > configure.ac of that link, it seems to copy certain files into the
> > build directory and then uses cargo. Would you rather if it used rustc
> > directly?
>
> How can a package not use 'cargo' if it needs some Rust libraries?
>
> It's very much possible that I did not see/find some "obvious" solution,
> though.
>
> > I can try to tackle support for Rust too.
>
> That would be welcome!

Another sharp edge with Rust is, sometimes it cannot build its own
cargos. I experienced this problem when trying to port some Rust
programs from x86_64 to arm, arm64, mips and powerpc.

Also see Rust's Platform Support,
. Tier 1
is expected to build and run correctly. Tier 1 is i686, x86_64 and
some aarch64. Everything else, Tiers 2 & 3, are a best effort with no
guarantees.

[Sorry to post here. I cannot find the original message in my Inbox.]

Jeff



Re: Rust build system

2025-04-25 Thread Bruno Haible via Gnulib discussion list
Nikolaos Chatzikonstantinou wrote:
> > One problem I see with Rust is that currently it does not integrate well
> > with the GNU Build system, in particular with VPATH builds (see [3] for
> > an example integration). Any improvements on that front would be welcome.
> >
> > [3] 
> > https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=tree;f=gettext-tools/examples/hello-rust;hb=HEAD
> 
> What is the issue with VPATH builds?

The issue is that 'cargo' mandates a certain directory layout of the
package, that is incompatible with VPATH builds.

> I read the comments in
> configure.ac of that link, it seems to copy certain files into the
> build directory and then uses cargo. Would you rather if it used rustc
> directly?

How can a package not use 'cargo' if it needs some Rust libraries?

It's very much possible that I did not see/find some "obvious" solution,
though.

> I can try to tackle support for Rust too.

That would be welcome!

Bruno