On Mon, Dec 12, 2022 at 10:58 AM Sérgio Basto <ser...@serjux.com> wrote:
>
> Hi,
>
> I how solved this ? [1]
> Thank you

I suggest that you take a look at the Rust packaging guidelines, or at
how other packages in similar situations have handled this.

You need to configure the cargo build system correctly, i.e.
1. tell it to not try to download dependencies over the internet,
2. tell it how to use dependencies from Fedora instead,
2. use correct cargo build flags, and
3. use correct Rust compiler flags.

All these should be possible without too much trouble:

A. Add a call of the "%cargo_prep" macro in the "%prep" scriptlet.
Probably doesn't matter where, except that it needs to be after
unpacking sources.
This sets up cargo configuration that disables loading dependencies
over the internet, and specifies the location where cargo can find
packaged Rust dependencies.

B. Add a build dependency on the "cxx" crate. I looked at the source
code, and it seems to be the only Rust dependency - and it's already
packaged for Fedora:
BuildRequires: (crate(cxx/default) >= 1.0.0 with crate(cxx/default) < 2.0.0~)

C. Make sure "cargo build" is called with the correct flags for cargo
and the Rust compiler.
It looks like cmake just calls "cargo build --release", which ignores
Fedora default compiler flags (which is forbidden). You can look at
the "%cargo_build" flag for which flags you need:

$ rpm -E "%cargo_build"
/usr/bin/env CARGO_HOME=.cargo RUSTC_BOOTSTRAP=1
RUSTFLAGS='-Copt-level=3 -Cdebuginfo=2 -Ccodegen-units=1
-Clink-arg=-Wl,-z,relro -Clink-arg=-Wl,-z,now --cap-lints=warn'
/usr/bin/cargo build -j16 -Z avoid-dev-deps --release

I think RUSTC_BOOTSTRAP=1 is not necessary in this case, but at least
setting RUSTFLAGS is mandatory (for example, debuginfo doesn't work if
you don't, and these flags also produce better code at the cost of
slightly slower compile times).

I haven't looked at how cmake calls "cargo build --release", but you
might need to patch the CMakeLists.txt file that contains this call to
include the flags above, and/or set RUSTFLAGS environment variable
before running the build.

Fabio
_______________________________________________
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue

Reply via email to