Repository navigation
Closed
Labels
0.kind: bugSomething is broken
Description
Nixpkgs version
- Unstable (26.11)
Describe the bug
arm-none-eabi-gcc --version reports segment fault, other binutils too
Test environment is wsl2 Ubuntu 26.04 x86-64
Steps to reproduce
Use the following flake.nix, run nix develop .#broken -c arm-none-eabi-gcc --version
LLM has made a fix in the same flake.nix. It fixes the problem on my machine
Minimal reproducer
{
description = "gcc-arm-embedded segfaults because of the patchelf call order in nixpkgs";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
outputs = { self, nixpkgs }:
let
lib = nixpkgs.lib;
eachSystem = f: lib.genAttrs [ "x86_64-linux" "aarch64-linux" ]
(system: f nixpkgs.legacyPackages.${system});
# nixpkgs' preFixup runs `--set-interpreter` and then `--set-rpath`.
# The interpreter pass adds a PT_LOAD for the 83-byte nix loader (the
# binaries only reserve 28 bytes for .interp), and the rpath pass then
# has to grow .dynstr and relocates .dynamic to 0x400c18 -- a page that
# the following read-only PT_LOAD also covers. ld.so patches .dynamic
# in place at startup and write-faults there -> SIGSEGV.
# Doing the rpath first makes patchelf re-lay out the whole file, which
# keeps .dynamic inside a writable PT_LOAD.
fixed = pkgs: pkgs.gcc-arm-embedded.overrideAttrs (_: {
preFixup = lib.optionalString pkgs.stdenv.hostPlatform.isLinux ''
find $out -type f | while read f; do
patchelf "$f" > /dev/null 2>&1 || continue
patchelf --set-rpath ${
lib.makeLibraryPath [
"$out"
pkgs.stdenv.cc.cc
pkgs.ncurses6
pkgs.libxcrypt-legacy
pkgs.xz
pkgs.zstd
]
} "$f" || true
patchelf --set-interpreter $(cat ${pkgs.stdenv.cc}/nix-support/dynamic-linker) "$f" || true
done
'';
});
in
{
devShells = eachSystem (pkgs: {
# nix develop .#broken -c arm-none-eabi-gcc --version -> SegFault
broken = pkgs.mkShell { packages = [ pkgs.gcc-arm-embedded ]; };
# nix develop .#fixed -c arm-none-eabi-gcc --version -> OK
fixed = pkgs.mkShell { packages = [ (fixed pkgs) ]; };
default = pkgs.mkShell { packages = [ (fixed pkgs) ]; };
});
};
}Expected behaviour
arm-none-eabi-gcc and binutils work
Screenshots
No response
Relevant log output
Additional context
flake.lock is
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1792502884,
"narHash": "sha256-IoNisKcGbUjdd45qCqywGMCYmZ5EnkxezvLII0FWwNA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "02c087f3fe673c9e317f206a627cb6b910336dbe",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}
System metadata
error, NIX_PATH is empty
Notify maintainers
Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)
I assert that this issue is relevant for Nixpkgs
- I assert that this is a bug and not a support request.
- I assert that this is not a duplicate of an existing issue.
- I assert that I have read the NixOS Code of Conduct and agree to abide by it.
- I assert that I have read the automation/AI policy and that this issue report complies with it.
Is this issue important to you?
Add a 👍 reaction to issues you find important.
Metadata
Metadata
Assignees
Labels
0.kind: bugSomething is broken
Activity
QiroNT commentedon Oct 22, 2026
also a NixOS/patchelf#674 issue
prusnak commentedon Oct 22, 2026
@f-zl fix in #577329 - can you please test if that fixes your issue?
gcc-arm-embedded-{13,14,15}: set RPATH before the interpreter