diff --git a/.gitignore b/.gitignore index 85c2ebd..5179f75 100644 --- a/.gitignore +++ b/.gitignore @@ -63,7 +63,7 @@ benchmarks/stdin/piping/FAILED-benchmark.txt # ---> fastwc build artifacts bin/ -fastwc +/fastwc compile_commands.json .cache/ @@ -81,3 +81,6 @@ depcomp install-sh missing + +# autoconf backup from in-tree regeneration +configure~ diff --git a/packaging/README.md b/packaging/README.md new file mode 100644 index 0000000..6b1602f --- /dev/null +++ b/packaging/README.md @@ -0,0 +1,49 @@ +# Packaging + +Build recipes for the distributions that matter. Each one follows the +same recipe: unpack the release archive, regenerate the autotools +files (`autoreconf -fi` — the generated `configure`/`Makefile.in` are +not committed), `configure`, `make`, `make install`. The binary is a +single static-ish ELF that only needs glibc. + +| Distro | File | Tooling | +|--------|------|---------| +| Arch | `arch/PKGBUILD` | `makepkg` | +| Gentoo | `gentoo/app-misc/fastwc/fastwc-0.1.0.ebuild` | `ebuild` / `emerge` (drop into a local repo or `app-portage/eselect-repository`) | +| NixOS | `nix/default.nix` | `nix build -f default.nix` (or a `callPackage` from a nixpkgs overlay) | +| Void | `void/template` | `xbps-src pkg fastwc` (in a `void-packages` checkout: `cp -r ../fastwc/packaging/void srcpkgs/fastwc`) | +| Fedora | `fedora/fastwc.spec` | `rpmbuild -ba fastwc.spec` (or `fedpkg`/`mock`) | + +## Before the first build + +Each recipe points at the Gitea release archive +`https://git.spectoria.dev/huntedbytheirs/fastwc/archive/v0.1.0.tar.gz`, +which does not exist until a `v0.1.0` tag is pushed: + +```sh +git tag -a v0.1.0 -m "fastwc 0.1.0" +git push origin v0.1.0 +``` + +Then fill in the integrity placeholders each distro demands: + +- **Arch**: replace `sha256sums=('SKIP')` with the hash `makepkg` reports on the first attempt. +- **NixOS**: `lib.fakeHash` makes the first build fail with the real hash — paste it in. +- **Void**: replace `checksum=SKIP` with the sha256 `xbps-src` wants (it will refuse to build until then). +- **Gentoo / Fedora**: hashes live outside the recipe (the `Manifest` file / source RPM metadata), so nothing to fill in here. + +## Notes + +- **Gitea archive layout**: these archives extract to a top-level + directory named after the repo (`fastwc/`, no version suffix), which + is why the recipes `cd fastwc`, set `S="${WORKDIR}/fastwc"`, or use + `%autosetup -n fastwc`. If a future host renames the layout, adjust + those three spots. +- **Architecture**: the SIMD kernels dispatch AVX-512/AVX-2/SSE2 at + runtime with a scalar fallback, so the code builds anywhere — the + recipes currently declare `x86_64` because that is what the benchmark + contract is validated on. Loosen if you build elsewhere. +- **`-pthread`** is in `AM_CFLAGS`; glibc >= 2.34 provides pthreads in + libc, so there is no separate runtime dependency. +- The `fastwc` binary installs to `$(bindir)/fastwc` and does not + shadow `wc` — nothing conflicts with coreutils. diff --git a/packaging/arch/PKGBUILD b/packaging/arch/PKGBUILD new file mode 100644 index 0000000..df3f8bb --- /dev/null +++ b/packaging/arch/PKGBUILD @@ -0,0 +1,27 @@ +# Maintainer: huntedbytheirs +pkgname=fastwc +pkgver=0.1.0 +pkgrel=1 +pkgdesc="A wc replacement that beats GNU wc - SIMD kernels, mmap, threads" +arch=('x86_64') +url="https://git.spectoria.dev/huntedbytheirs/fastwc" +license=('MIT') +depends=('glibc') +makedepends=('autoconf' 'automake' 'libtool') +# requires a v0.1.0 tag on the Gitea remote; replace SKIP with the real +# sha256sum once the tag exists (makepkg prints it on the first failed build) +source=("$pkgname-$pkgver.tar.gz::https://git.spectoria.dev/huntedbytheirs/fastwc/archive/v$pkgver.tar.gz") +sha256sums=('SKIP') + +build() { + # Gitea archives extract to a directory named after the repo + cd "$pkgname" + autoreconf -fi + ./configure --prefix=/usr + make +} + +package() { + cd "$pkgname" + make DESTDIR="$pkgdir" install +} diff --git a/packaging/fedora/fastwc.spec b/packaging/fedora/fastwc.spec new file mode 100644 index 0000000..6ec0698 --- /dev/null +++ b/packaging/fedora/fastwc.spec @@ -0,0 +1,43 @@ +Name: fastwc +Version: 0.1.0 +Release: 1%{?dist} +Summary: A wc replacement that beats GNU wc + +License: MIT +URL: https://git.spectoria.dev/huntedbytheirs/fastwc +# requires a v0.1.0 tag on the Gitea remote +Source0: %{url}/archive/v%{version}.tar.gz + +BuildRequires: gcc +BuildRequires: make +BuildRequires: autoconf +BuildRequires: automake +BuildRequires: libtool + +%description +fastwc is a single-file wc replacement. It counts lines, words, and +bytes with SIMD kernels (AVX-512, AVX-2, SSE2, runtime-dispatched), +maps regular files instead of copying them, and splits large files +across cores. It never loses to GNU wc on the benchmark suite, and +never disagrees with its counts. + +%prep +# Gitea archives extract to a directory named after the repo +%autosetup -n fastwc + +%build +autoreconf -fi +%configure +%make_build + +%install +%make_install + +%files +%{_bindir}/fastwc +%license LICENSE +%doc README.md docs/PERFORMANCE.md + +%changelog +* Sat Aug 29 2026 huntedbytheirs - 0.1.0-1 +- Initial packaging diff --git a/packaging/gentoo/app-misc/fastwc/fastwc-0.1.0.ebuild b/packaging/gentoo/app-misc/fastwc/fastwc-0.1.0.ebuild new file mode 100644 index 0000000..d1ecb88 --- /dev/null +++ b/packaging/gentoo/app-misc/fastwc/fastwc-0.1.0.ebuild @@ -0,0 +1,29 @@ +# Copyright 1999-2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit autotools + +DESCRIPTION="A wc replacement that beats GNU wc - SIMD kernels, mmap, threads" +HOMEPAGE="https://git.spectoria.dev/huntedbytheirs/fastwc" +# requires a v0.1.0 tag on the Gitea remote +SRC_URI="https://git.spectoria.dev/huntedbytheirs/fastwc/archive/v${PV}.tar.gz" + +LICENSE="MIT" +SLOT="0" +KEYWORDS="~amd64" + +# Gitea archives extract to a directory named after the repo +S="${WORKDIR}/fastwc" + +BDEPEND=" + >=sys-devel/autoconf-2.69 + sys-devel/automake + sys-devel/libtool +" + +src_prepare() { + default + eautoreconf +} diff --git a/packaging/nix/default.nix b/packaging/nix/default.nix new file mode 100644 index 0000000..122ad63 --- /dev/null +++ b/packaging/nix/default.nix @@ -0,0 +1,29 @@ +{ lib, stdenv, fetchFromGitea, autoconf, automake, libtool }: + +stdenv.mkDerivation (finalAttrs: { + pname = "fastwc"; + version = "0.1.0"; + + src = fetchFromGitea { + domain = "git.spectoria.dev"; + owner = "huntedbytheirs"; + repo = "fastwc"; + # requires a v0.1.0 tag on the Gitea remote; the fake hash makes the + # first build fail with the real one printed - drop it in, then rebuild + rev = "v${finalAttrs.version}"; + hash = lib.fakeHash; + }; + + nativeBuildInputs = [ autoconf automake libtool ]; + + preConfigure = '' + autoreconf -fi + ''; + + meta = with lib; { + description = "A wc replacement that beats GNU wc - SIMD kernels, mmap, threads"; + homepage = "https://git.spectoria.dev/huntedbytheirs/fastwc"; + license = licenses.mit; + platforms = platforms.linux; + }; +}) diff --git a/packaging/void/template b/packaging/void/template new file mode 100644 index 0000000..280af4d --- /dev/null +++ b/packaging/void/template @@ -0,0 +1,18 @@ +# Template file for 'fastwc' +pkgname=fastwc +version=0.1.0 +revision=1 +build_style=gnu-configure +hostmakedepends="autoconf automake libtool" +short_desc="A wc replacement that beats GNU wc - SIMD kernels, mmap, threads" +maintainer="huntedbytheirs " +license="MIT" +homepage="https://git.spectoria.dev/huntedbytheirs/fastwc" +# requires a v0.1.0 tag on the Gitea remote; replace SKIP with the real +# checksum once the tag exists (xbps-src prints it on the first attempt) +distfiles="https://git.spectoria.dev/huntedbytheirs/fastwc/archive/v${version}.tar.gz" +checksum=SKIP + +pre_configure() { + autoreconf -fi +}