Skip to content

Investigate alternatives to use of nightly features (and other Gentoo build issues) #397

Closed
@Kangie

Description

@Kangie

Gentoo has some requirements for building packages that are causing issues with my attempt to update our package to 0.12.1.

  1. The use of nightly features to build a shared library

Gentoo users compile software locally, and our package manager will use the installed Rust to build this package.

As per #345 this fails when using cbindgen unless you use a nightly comipler or disable stability guarantees, but maybe we don't need to run cbindgen for release builds?

We vendor the cbindgen generated rustls.h in-repo, which would avoid needing cbindgen or nightly rustc, but I think the cargo-c build process is regenerating it as part of its build. Possibly one fix is figuring out if that's necessary at all.

  1. Compilation outside the src_compile phase

If we attempt to work around this with RUSTC_BOOTSTRAP=1, I see compilation when cargo cinstall is run if the src_test phase has been called (i.e. if cargo ctest has been run between cargo cbuild and cargo cinstall)

 abi_x86_64.amd64: running multilib-minimal_abi_src_install
       Dirty cfg-if v1.0.0: the profile configuration changed
   Compiling cfg-if v1.0.0
       Dirty untrusted v0.9.0: the profile configuration changed
   Compiling untrusted v0.9.0
       Dirty rustls-pki-types v1.3.1: the profile configuration changed
   Compiling rustls-pki-types v1.3.1
       Dirty spin v0.9.8: the profile configuration changed
   Compiling spin v0.9.8
       Dirty log v0.4.21: the profile configuration changed
   Compiling log v0.4.21
       Dirty zeroize v1.7.0: the profile configuration changed
   Compiling zeroize v1.7.0
       Dirty base64 v0.21.5: the profile configuration changed
   Compiling base64 v0.21.5
       Dirty subtle v2.5.0: the profile configuration changed
   Compiling subtle v2.5.0

We don't allow this in Gentoo - compilation should happen in the appropriate src_compile phase.

Current state of the Gentoo Ebuild:

# Copyright 2022-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

CRATES="
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]+wasi-snapshot-preview1
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
        [email protected]
"

inherit cargo multilib-minimal rust-toolchain

DESCRIPTION="C-to-rustls bindings"
HOMEPAGE="https://github.com/rustls/rustls-ffi"
SRC_URI="https://github.com/rustls/rustls-ffi/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"
SRC_URI+=" $(cargo_crate_uris)"

# From cargo-ebuild (note that webpki is also just ISC)
LICENSE="|| ( MIT Apache-2.0 ) BSD Boost-1.0 ISC MIT MPL-2.0 Unicode-DFS-2016"
# Dependent crate licenses
LICENSE+=" ISC MIT Unicode-DFS-2016"
# For Ring (see its LICENSE)
LICENSE+=" ISC openssl SSLeay MIT"
SLOT="0/${PV}"
KEYWORDS="~amd64"

BDEPEND="dev-util/cargo-c"

QA_FLAGS_IGNORED="usr/lib.*/librustls.*"

src_prepare() {
        default

        multilib_copy_sources
}

multilib_src_compile() {
        local cargoargs=(
                --library-type=cdylib
                --prefix=/usr
                --libdir="/usr/$(get_libdir)"
                --target="$(rust_abi)"
                $(usev !debug '--release')
        )

        cargo cbuild "${cargoargs[@]}" || die "cargo cbuild failed"
}

multilib_src_test() {
        local cargoargs=(
                --prefix=/usr
                --libdir="/usr/$(get_libdir)"
                --target="$(rust_abi)"
                $(usex debug '--debug' '--release')
        )

        cargo ctest "${cargoargs[@]}" || die "cargo ctest failed"
}

multilib_src_install() {
        local cargoargs=(
                --library-type=cdylib
                --prefix=/usr
                --libdir="/usr/$(get_libdir)"
                --target="$(rust_abi)"
                --destdir="${ED}"
                $(usex debug '--debug' '--release')
        )

        cargo cinstall "${cargoargs[@]}" || die "cargo cinstall failed"
}

pinging @thesamesam as the actual Gentoo package maintainer, I just touched some curl-y stuff related to rustls detection and realised that cURL 8.7.1 needs rustls >=0.12.0 :)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions