CachyOS / CachyOS/linux-cachyos

[BUG] Hardcoded GNU strip in _package-headers() fails on Clang builds due to fakeroot interference

Open
#894 0 comments 1 reaction 2 assignees Claimed by @ptr1337 View on GitHub
bug
Dominant language
Shell
Stars
4.5k
Forks
160
Avg merge
2d 12h
Merged PRs (30d)
1

Description

### Pre-flight checklist

- [x] I have searched existing issues and this is not a duplicate.
- [x] I have read the [Contributing Guidelines](https://github.com/CachyOS/linux-cachyos/blob/master/CONTRIBUTING.md).
- [x] I have verified the issue is reproducible with the latest available CachyOS kernel.
- [x] I have tried to reproduce the issue on Arch Linux's `linux` kernel.

### Upstream / vanilla kernel check

I tested with a vanilla/upstream kernel and the issue does NOT reproduce there (CachyOS-specific bug)

### Kernel variant

linux-cachyos (EEVDF, Clang)

### System information (cachyos-bugreport.sh)

```text
https://paste.cachyos.org/p/f23439d.txt
```

### Manual system information (if cachyos-bugreport.sh is unavailable)

```text

```

### Bug description

When building `linux-cachyos` via `makepkg` from the AUR using the default, unmodified `PKGBUILD`, the build consistently fails during the `_package-headers()` phase. The script crashes when stripping `scripts/selinux/mdp/mdp` and `vmlinux`, throwing `file format not recognized`, followed by `fakeroot` crashing.

The root cause is a toolchain mismatch combined with `fakeroot` interference. The default `PKGBUILD` uses Clang/LLVM (`_use_llvm_lto=thin`), but the `_package-headers()` function hardcodes the standard GNU `strip` command for its final loop. When GNU `strip` runs under `fakeroot` (`LD_PRELOAD`) to process a Clang-compiled PIE binary on modern hardware, `fakeroot` fails to properly intercept the AVX-optimized `glibc` memory paths, corrupting the read buffer and causing GNU `strip` to fail.

The maintainers correctly implemented a `strip_bin` check in the `_sign_modules()` function to use `llvm-strip` for Clang builds, but omitted this safety check in `_package-headers()`.

### Steps to reproduce

1. Clone the `linux-cachyos` AUR package.
2. Run `makepkg -si` on a modern x86-64-v3 CPU.
3. Wait for the compilation to reach the `_package-headers()` stripping phase.

### Expected behavior

The headers and `vmlinux` are stripped successfully and the package finishes building. Then, it installs without any issues.

### Actual behavior

Standard GNU `strip` is incorrectly called on the LLVM PIE binaries. It throws a format error due to memory corruption from fakeroot, violently aborting `makepkg` and causing `fakeroot` to throw semaphore errors.

### Logs / stack traces

```text
Stripping build tools...
strip: /home/amogh/.cache/yay/linux-cachyos/pkg/linux-cachyos-headers/usr/lib/modules/7.1.1-2-cachyos/build/scripts/selinux/mdp/mdp: file format not recognized
==> ERROR: A failure occurred in package_linux-cachyos-headers().
Aborting...
libfakeroot internal error: payload not recognized!
fakeroot internal error #43: Identifier removed
semop(2): encountered an error: Invalid argument
```

### Additional system information

### System Information

**Hardware:**
* **Host:** Lenovo ThinkBook 16 G7 ARP (21MW)
* **CPU:** AMD Ryzen 7 7735HS (16 threads) @ 4.83 GHz *(x86-64-v3 architecture)*
* **GPU:** AMD Radeon 680M [Integrated]
* **Memory:** 16 GiB Total (12.71 GiB usable)

**Software Environment:**
* **OS:** Arch Linux x86_64
* **Kernel:** Linux 7.0.13-arch1-1
* **Compiler:** Clang/LLVM (Default in PKGBUILD)
* **Build Method:** AUR (makepkg)
* **DE / WM:** GNOME 50.2 / Mutter (Wayland)
* **Shell & Terminal:** zsh 5.9.1 / ghostty 1.3.1

**The Fix:**
Apply the exact same logic used in `_sign_modules()` to the `_package-headers()` function.

Before the `while read` loop in `_package-headers()`, add:

```bash
if [ "$_use_llvm_lto" != "none" ]; then
local strip_bin="llvm-strip"
else
local strip_bin="strip"
fi
```

Then replace the hardcoded `strip -v` commands with `${strip_bin}`. (Note: The `-v` flag must be removed, as `llvm-strip` does not support it).

**Verification:**
1. Manually modifying the PKGBUILD to use `env -u LD_PRELOAD strip ...` succeeds, proving fakeroot is the active cause of the corruption.
2. Modifying the PKGBUILD to use `llvm-strip` succeeds cleanly, as LLVM's internal memory mapping doesn't trigger the fakeroot/glibc AVX bug.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.