Package Details: ksud 1.0.1-2

Git Clone URL: https://aur.archlinux.org/ksud.git (read-only, click to copy)
Package Base: ksud
Description: KernelSU userspace cli
Upstream URL: https://kernelsu.org/
Keywords: kernelsu
Licenses: GPL-3.0-or-later
Submitter: chise0713
Maintainer: chise0713
Last Packager: chise0713
Votes: 0
Popularity: 0.000000
First Submitted: 2024-05-19 10:45 (UTC)
Last Updated: 2024-08-29 13:08 (UTC)

Latest Comments

chise0713 commented on 2024-08-26 03:35 (UTC)

@nyaruta Thank you for your feedback and suggestions!

I've discovered that the error with LTO occurs only when the build.rs linking functionality is not used. Please try the following patch:

diff --git a/userspace/ksud/build.rs b/userspace/ksud/build.rs
index 021418ac..8a16bff8 100644
--- a/userspace/ksud/build.rs
+++ b/userspace/ksud/build.rs
@@ -34,6 +34,7 @@ fn get_git_version() -> Result<(u32, String), std::io::Error> {
 }

 fn main() {
+    println!("cargo:rustc-link-lib=zstd"); 
     let (code, name) = match get_git_version() {
         Ok((code, name)) => (code, name),
         Err(_) => {

This patch should resolve the LTO linking issue. If it works, I will update the PKGBUILD accordingly. Additionally, if we are not fetching our own magiskboot, we can remove the unzip makedepends.

nyaruta commented on 2024-08-14 05:52 (UTC) (edited on 2024-08-14 06:56 (UTC) by nyaruta)

Here is my PKGBUILD

# Maintainer: chise0713 <chise0713 at protonmail dot com>

pkgname=ksud
pkgver=1.0.1
pkgrel=1
pkgdesc='KernelSU userspace cli'
arch=('i686' 'x86_64' 'armv7h' 'aarch64')
url='https://kernelsu.org/'
license=('GPL-3.0-or-later')
depends=('magiskboot-bin')
makedepends=('cargo' 'unzip')
_srcname='KernelSU'
source=("$_srcname-$pkgver.tar.gz::https://github.com/tiann/$_srcname/archive/v$pkgver.tar.gz"
        "android12-5.10_kernelsu_$pkgver.ko::https://github.com/tiann/$_srcname/releases/download/v$pkgver/android12-5.10_kernelsu.ko"
        "android13-5.10_kernelsu_$pkgver.ko::https://github.com/tiann/$_srcname/releases/download/v$pkgver/android13-5.10_kernelsu.ko"
        "android13-5.15_kernelsu_$pkgver.ko::https://github.com/tiann/$_srcname/releases/download/v$pkgver/android13-5.15_kernelsu.ko"
        "android14-5.15_kernelsu_$pkgver.ko::https://github.com/tiann/$_srcname/releases/download/v$pkgver/android14-5.15_kernelsu.ko"
        "android14-6.1_kernelsu_$pkgver.ko::https://github.com/tiann/$_srcname/releases/download/v$pkgver/android14-6.1_kernelsu.ko"
)
sha512sums=('a327bd8b6c5abce0da971153759785753470041df285f4a8e9b09049d539c7b4b28cc2adfdceb27edb65a96053cfa9e9e0c43f06f129bca0f9f1f0ca8cd06586'
            'dd971c4fa3f1d1003b34e7746117e09beb14db2efbc690bd2dab10b91604dd1c730e5a56cbfeb25d3783851fe48b4b2bd4610bc9f5e4e4e45296ad64c122aef0'
            'a461d9d07531c662861b020d4251d197320c4bdd8f7e532c8e5221c364b815b9be345d18902d818ca528d12ae875a2144aff478ba3a34f2a61cc2bb68908a0b1'
            '58437823be316e9e558dc32c2baa3e59f852e9ffe1459f55177dbad8656b54b98eaef5afe30025cbbc2569156cb6a6e042ae44ed12c1a1bd3db9e25e36a3e63a'
            '05fc22d63a6fec6820bb7bc27b9ff236b4df94d47f9a9a861aedc1e65f656f79805cbdf65bb6e6d6bb344bcbda7121f88bf22b5ad4aca2354209029682a3f7ec'
            'db0ee7f47a300c9f9b0e5bd1da0c10550705bb277457e71f0c0dc78f81823e267f6055aa136ed5d0631411bc144abaef11c32d44d64fcbaf7a2ff39d190b07ee'
)

options=(!lto)

prepare() {
    cd "$_srcname-$pkgver/userspace/ksud/"

    export RUSTUP_TOOLCHAIN=stable

    cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"

    for ko in $srcdir/*.ko; do
        _ko=${ko##*/}
        _ko=${_ko%_$pkgver.ko}
        install -v -Dm644 "$ko" "bin/aarch64/$_ko.ko"
        unset _ko
    done
}

build() {
    cd "$_srcname-$pkgver/userspace/ksud/"

    export RUSTUP_TOOLCHAIN=stable
    export CARGO_TARGET_DIR=target

    cargo build --frozen --release --all-features
}

package() {
    cd "$_srcname-$pkgver"

    install -Dm755 "userspace/ksud/target/release/$pkgname"     -t "$pkgdir/usr/bin/"
    install -Dm644 "LICENSE"                                    -t "$pkgdir/usr/share/licenses/$pkgname/"
}

nyaruta commented on 2024-08-14 05:50 (UTC) (edited on 2024-08-14 05:50 (UTC) by nyaruta)

Cannot build
Output:

= note: /usr/bin/ld: /build/ksud/src/KernelSU-1.0.1/userspace/ksud/target/release/deps/ksud-bedf0849440e9464.ksud.8fb589a703c351ac-cgu.12.rcgu.o: in function `<zip::read::ZipFile as core::ops::drop::Drop>::drop':
          ksud.8fb589a703c351ac-cgu.12:(.text._ZN60_$LT$zip..read..ZipFile$u20$as$u20$core..ops..drop..Drop$GT$4drop17h4aea84ebc1daec75E+0x23b): undefined reference to `ZSTD_freeDCtx'
...
= note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)

Solved by adding options=(!lto)

chise0713 commented on 2024-05-19 13:00 (UTC) (edited on 2024-05-22 19:24 (UTC) by chise0713)

Usage example:

#!/bin/bash

# Get a boot image
curl -L https://github.com/tiann/KernelSU/releases/download/v0.9.4/android12-5.10.205_2024-03-boot-lz4.img.gz |\
        zcat > android12-5.10.205_2024-03-boot-lz4.img

# Patch kernel image
ksud boot-patch -b android12-5.10.205_2024-03-boot-lz4.img