commit: fac64988b906620226a56c12369fbdc877b7edb7 Author: Violet Purcell <vimproved <AT> inventati <DOT> org> AuthorDate: Sun May 11 19:32:59 2025 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Wed May 21 21:10:33 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fac64988
sys-kernel/scx: add 1.0.12 Signed-off-by: Violet Purcell <vimproved <AT> inventati.org> Part-of: https://github.com/gentoo/gentoo/pull/42035 Signed-off-by: Sam James <sam <AT> gentoo.org> sys-kernel/scx/Manifest | 2 + sys-kernel/scx/files/scx-1.0.12-musl-ioctl.patch | 33 ++++++ sys-kernel/scx/scx-1.0.12.ebuild | 133 +++++++++++++++++++++++ 3 files changed, 168 insertions(+) diff --git a/sys-kernel/scx/Manifest b/sys-kernel/scx/Manifest index 798831fc16e4..a0dfe5e37280 100644 --- a/sys-kernel/scx/Manifest +++ b/sys-kernel/scx/Manifest @@ -2,3 +2,5 @@ DIST scx-1.0.10-crates.tar.xz 29845260 BLAKE2B 366a068bfb81f7be8d167831ace5c933c DIST scx-1.0.10.tar.gz 4634807 BLAKE2B 84a396b451a74be275730cd5d00c4476ad9b38008087594d11b80581d851f3ca7449367ace796888dbec66a66a165202c9d7b7bb060fe29cdc8d89673122b3ed SHA512 143bcd93d5c1f73d6d2b366460c702e14d7c6d5c7d83d9c83ff561e8b329d8520a8009c4551fce0775efe4d065f6cb6c2550dc626509170b6a7fe36aa884c3c4 DIST scx-1.0.11-crates.tar.xz 29897084 BLAKE2B a1296db87cdc61b1c78a196878500f6e6a8de8cfa7d4cf55127a1ad589fcfdadca21d7034a1855d712f61e616bd726c12aaadc4823583a5a9b496d9cc9dc7d72 SHA512 5c3e9961b82c2bfa94dddecb01094bd1fec9084c66feb84043e182fc1cedb15bc7d8f5e2219bfb35781046931fae7866d20ce86c5866dba325d5f352c028a8b8 DIST scx-1.0.11.tar.gz 4665784 BLAKE2B fe22bc65e7ffe548d363f000abe6f246d0b22b73c2c1e87eed76c22f62e71390426859e5ae56f15aaeac5786d0a9204b8fe3bce8b29329001ec0233ab16138f8 SHA512 21b75384ce29cae3b0cb8afbc18fa38a5aadc2444b2bd1f20ff44c4ebc81ad1bea8be14e95259c4a2e8753152dd448173f465a9e3ffa479bcd0b145b17630f4b +DIST scx-1.0.12-crates.tar.xz 30612908 BLAKE2B eb18a835fff1a6482ab0a745355de64b9bba557bc574fb7b7f94c3115b8bd23b31fb5ac1944e95f70f9d50b1a146cabbf45ec7117ba03323e53687afcf344355 SHA512 b0fffefdfd44b2f326898bc6fd757d69f2445a8916061128058764e904ee4c21e1a41f0328e1e2db81c1d913442c734f27eb0ba825c935a1aba70ad6ad5f97e0 +DIST scx-1.0.12.tar.gz 4702884 BLAKE2B fe812e98986bd6eda63f6a0b51774da08e75832805e27e57085a0eee8f8b5309d56daeee8d28ad7dda54f980442fa7a1834474edaff98fd984e4ed523c9a115e SHA512 5ee06c65c516b3f9a72d81865efb05dab68552ce781b856eb936622b9afe0935f1423f92daddb5b17e3159d6574bb79fa6c4dcc15a8a124ee0c23fe212458632 diff --git a/sys-kernel/scx/files/scx-1.0.12-musl-ioctl.patch b/sys-kernel/scx/files/scx-1.0.12-musl-ioctl.patch new file mode 100644 index 000000000000..0747ee80c28d --- /dev/null +++ b/sys-kernel/scx/files/scx-1.0.12-musl-ioctl.patch @@ -0,0 +1,33 @@ +Upstream-PR: https://github.com/sched-ext/scx/pull/1860 + +From 47622a1081ff849d224dc925752a4d860c217c4e Mon Sep 17 00:00:00 2001 +From: Violet Purcell <[email protected]> +Date: Sun, 11 May 2025 16:08:49 -0400 +Subject: [PATCH] scx_utils: cast ioctl opcodes to libc::Ioctl + +The opcode type that ioctl() accepts can differ between platforms, +namely between glibc where it accepts an unsigned 32-bit int, and musl +where it accepts a signed 32-bit int. Either way, the underlying value +of the opcode is a 32-bit integer. Currently, bindgen is storing the +enum values defined in perf_bindings.h as u32, which is fine for glibc, +but not musl (which wants an i32). This commit casts the opcodes to +libc::Ioctl before passing them to fix this. +--- a/rust/scx_utils/src/perf.rs ++++ b/rust/scx_utils/src/perf.rs +@@ -52,11 +52,11 @@ pub mod ioctls { + + #[allow(clippy::missing_safety_doc)] + pub unsafe fn enable(fd: c_int, arg: c_uint) -> c_int { +- unsafe { libc::ioctl(fd, perf::bindings::ENABLE.into(), arg) } ++ unsafe { libc::ioctl(fd, perf::bindings::ENABLE as libc::Ioctl, arg) } + } + + #[allow(clippy::missing_safety_doc)] + pub unsafe fn reset(fd: c_int, arg: c_uint) -> c_int { +- unsafe { libc::ioctl(fd, perf::bindings::RESET.into(), arg) } ++ unsafe { libc::ioctl(fd, perf::bindings::RESET as libc::Ioctl, arg) } + } + } +-- +2.49.0 + diff --git a/sys-kernel/scx/scx-1.0.12.ebuild b/sys-kernel/scx/scx-1.0.12.ebuild new file mode 100644 index 000000000000..1e24cab979a8 --- /dev/null +++ b/sys-kernel/scx/scx-1.0.12.ebuild @@ -0,0 +1,133 @@ +# Copyright 2024-2025 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +LLVM_COMPAT=( {16..19} ) + +CRATES=" +" + +RUST_MIN_VER="1.74.1" + +inherit llvm-r1 linux-info cargo rust-toolchain toolchain-funcs meson + +DESCRIPTION="sched_ext schedulers and tools" +HOMEPAGE="https://github.com/sched-ext/scx" +SRC_URI=" + https://github.com/sched-ext/scx/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz + ${CARGO_CRATE_URIS} +" +if [[ ${PKGBUMPING} != ${PVR} ]]; then + SRC_URI+=" + https://github.com/gentoo-crate-dist/scx/releases/download/v${PV}/scx-${PV}-crates.tar.xz + " +fi + +LICENSE="GPL-2" +# Dependent crate licenses +LICENSE+=" + Apache-2.0 BSD-2 BSD CC0-1.0 ISC MIT MPL-2.0 Unicode-3.0 ZLIB +" +SLOT="0" +KEYWORDS="~amd64" +IUSE="systemd" + +DEPEND=" + virtual/libelf:= + sys-libs/zlib:= + >=dev-libs/libbpf-1.5:= +" +RDEPEND=" + ${DEPEND} +" +BDEPEND=" + app-misc/jq + >=dev-util/bpftool-7.5.0 + $(llvm_gen_dep ' + llvm-core/clang:${LLVM_SLOT}=[llvm_targets_BPF(-)] + ') +" + +CONFIG_CHECK=" + ~BPF + ~BPF_EVENTS + ~BPF_JIT + ~BPF_SYSCALL + ~DEBUG_INFO_BTF + ~FTRACE + ~SCHED_CLASS_EXT +" + +PATCHES=( + "${FILESDIR}/${PN}-1.0.12-musl-ioctl.patch" +) + +QA_PREBUILT="/usr/bin/scx_loader" + +pkg_setup() { + linux-info_pkg_setup + llvm-r1_pkg_setup + rust_pkg_setup +} + +src_prepare() { + default + + if tc-is-cross-compiler; then + # Inject the rust_abi value into install_rust_user_scheds + sed -i "s;\${MESON_BUILD_ROOT};\${MESON_BUILD_ROOT}/$(rust_abi);" \ + meson-scripts/install_rust_user_scheds || die + fi + + # bug #944832 + sed -i 's;^#!/usr/bin/;#!/sbin/;' \ + services/openrc/scx.initrd || die +} + +src_configure() { + BUILD_DIR="${BUILD_DIR:-${WORKDIR}/${P}-build}" + + local emesonargs=( + -Dbpf_clang="$(get_llvm_prefix)/bin/clang" + -Dbpftool=disabled + -Dlibbpf_a=disabled + -Dcargo="${EPREFIX}/usr/bin/cargo" + -Dcargo_home="${ECARGO_HOME}" + -Doffline=true + -Denable_rust=true + -Dlibalpm=disabled + -Dopenrc=disabled + $(meson_feature systemd) + ) + + cargo_env meson_src_configure +} + +src_compile() { + cargo_env meson_src_compile +} + +src_test() { + cargo_env meson_src_test +} + +src_install() { + cargo_env meson_src_install + + dodoc README.md + + local readme readme_name + for readme in scheds/{rust,c}/*/README.md ./rust/*/README.md; do + [[ -e ${readme} ]] || continue + readme_name="${readme#*/rust/}" + readme_name="${readme_name#*/c/}" + readme_name="${readme_name%/README.md}" + newdoc "${readme}" "${readme_name}.md" + done + + newinitd services/openrc/scx.initrd scx + insinto /etc/default + doins services/scx + dosym ../default/scx /etc/conf.d/scx +}
