Project

General

Profile

Feature #155 » MISSING_5_2_IN_8_27_PLAN.md

walkero, 06/18/2026 11:08 PM

 

Coreutils 8.27 gap plan vs 5.2 patch stack

This is a focused gap-check of coreutils/5.2/patches against:

  • coreutils/8.27/patches
  • gnulib/for-coreutils-8.27/patches

Goal: identify likely necessary items from 5.2 that are not clearly carried into 8.27.


1) High-confidence gaps (likely required)

A. copy.c fstat/stat workaround is missing

From 5.2 patch 0005-Don-t-call-fstat-when-compiling-for-AmigaOS4.patch:

  • In copy_reg, 5.2 used stat(src_path, ...) on AmigaOS4 instead of fstat(source_desc, ...).
  • Rationale in patch message: fstat() inode/device behavior is broken for that use case.

In 8.27 patch set:

  • src/copy.c is touched, but only for mkfifo override handling.
  • No equivalent fstat fallback is present there.

Plan action P1: port/adapt this fix into 8.27 src/copy.c (or revalidate and prove unnecessary).


B. Amiga path semantics are not globally ported (coverage likely incomplete)

5.2 base patch changed global-ish behavior (e.g. ISSLASH handling with : for Amiga paths) and touched many files.

8.27 patch:

  • Adds Amiga path handling in some utilities (comments in patch history mention this),
  • but does not include broad config-level equivalent of the 5.2 config.hin ISSLASH adaptation.

Risk:

  • path handling may work in some commands (ls, cp, etc.) but remain inconsistent in others.

Plan action P1: run targeted path semantics audit across key tools (at least cp, mv, rm, pathchk, realpath, test, ln, install, sort/split temp path logic).


C. Newlib-specific correctness bits from 5.2 are not present in 8.27

From 5.2:

  • 0007: force HAVE_WORKING_READDIR for __amigaos4__ && __NEWLIB__.
  • 5.2 base patch had more __NEWLIB__-specific paths.

In 8.27:

  • Most logic appears CLIB2-centric (__CLIB2__ guards are common in patch).
  • No explicit carry-over of HAVE_WORKING_READDIR behavior found.

Plan action P1: if newlib is in scope, re-check and likely port these bits.


2) Medium-confidence gaps (depends on target/runtime goals)

D. Environment/usergroup support model changed, not clearly replaced for non-clib2

5.2 had lib/amigaos.c + lib/amigaos.h with environment and user/group wrappers.

8.27 does not carry these files; README notes suggest clib2 runtime took over parts of this behavior.

This is fine if target is strictly clib2 and those runtime behaviors are reliable.

Plan action P2: decide if we need support for:

  • clib2 only, or
  • clib2 + newlib, or
  • clib2 + clib4 + newlib.

If broader than clib2-only, reintroduce/adapt missing env/user wrappers as needed.


E. Host build portability update (config.guess/config.sub) not carried as a coreutils patch

5.2 0009 updated config/config.guess and config/config.sub for modern hosts (e.g. aarch64 Linux builders).

8.27 does not include an equivalent patch in coreutils.

However 8.27 bootstrap is gnulib-driven and points to ../../gnulib/repo; if gnulib is modern enough, this may already be satisfied.

Plan action P2: verify on target build hosts (especially aarch64 Linux) whether bootstrap/configure path resolves correctly without extra patching.


3) Items already covered by 8.27 + gnulib patches

  • Mounted filesystem detection hard-fail -> warning/hack:
    • covered by gnulib/for-coreutils-8.27/patches/0001.
  • Disable/avoid stty build path:
    • covered in 8.27 configure.ac / src/local.mk changes.
  • Remove docs/man/test integration for build simplification:
    • covered by 8.27 Makefile.am and configure-side reductions.
  • RLIMIT_DATA/clib2 flavor fix in sort:
    • appears covered in 8.27 sort changes.

4) Practical execution plan

Phase 1 — quick wins / likely fixes

  1. Add/port the copy.c fstat fallback logic from 5.2 (P1-A).
  2. Add a compact path-semantics compatibility layer strategy for 8.27 (P1-B):
    • either central macro approach,
    • or complete utility-level coverage list + patches.
  3. If newlib target exists: port HAVE_WORKING_READDIR and related newlib-specific behavior (P1-C).

Phase 2 — target matrix alignment

  1. Decide libc support matrix (clib2 only vs multi-libc).
  2. If multi-libc: recover/adapt missing runtime wrappers from 5.2 where still required.
  3. Validate host build portability (aarch64 etc.) and patch config helper flow only if needed.

Phase 3 — validation

  1. Runtime test set on AmigaOS:
    • file copy/stat behaviors,
    • absolute/relative path handling with : and /,
    • env propagation behavior,
    • selected utilities touched in old 5.2-only list (pathchk, test, uname, etc.).
  2. Build-host matrix test:
    • x86_64 Linux
    • aarch64 Linux

5) Decisions captured so far

Based on your feedback:

  1. Libc direction: move away from clib2-centric behavior and target clib4.
  2. Host build support: aarch64 host support is not required.
  3. stty: likely keep disabled for now (same behavior class as 5.2), unless explicitly requested otherwise.

Decisions finalized:

  • stty stays disabled for now.
  • Keep the old 5.2-derived sort/split replacement approach for now.

6) clib4-first migration tasks (new)

Because the 8.27 patch stack is heavily guarded with __CLIB2__, this is the priority plan:

  1. Build system switch to clib4

    • Change native build flags from -mcrt=clib2 to -mcrt=clib4 in native-build/makefile for coreutils.
    • Ensure linked libs/options are correct for clib4 runtime expectations.
  2. Audit and refactor __CLIB2__ conditionals

    • In coreutils/8.27 patch content, identify each #if defined __amigaos__ && defined __CLIB2__ block.
    • Classify each block:
      • truly clib2-specific ABI/API workaround,
      • generic AmigaOS behavior that should become libc-agnostic,
      • code that should be removed once using clib4/newer libc behavior.
  3. Re-validate with clib4 libc behavior

    • Re-test areas currently modified for clib2 assumptions:
      • locale handling (setlocale/collation paths in sort),
      • file descriptor and stdio temp-stream handling (mkstemp, fdopen, fstat paths),
      • filesystem type handling in stat (f_fstypename paths),
      • process/signal related blocks that were simplified for Amiga/clib2.
  4. Keep/port 5.2 fixes that are libc-neutral

    • copy.c fstat/stat workaround (if still reproducible with clib4).
    • path semantics consistency checks.
  5. Drop non-needed legacy substitutions where possible

    • Especially sort/split old-code replacement if clib4 allows upstream-like behavior.

7) Remaining questions to finalize patch selection

  1. stty: confirm final choice — keep disabled, or attempt implementation?
  2. sort/split: keep old replacement approach for now, or prioritize reverting toward upstream 8.27 code?
(2-2/3)