mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-08-31 20:54:56 +00:00
A release tarball carries generated files that a git tree does not, and
two of those bit us.
`MD5SUMS` is generated when a tarball is rolled. Each sub-source
extractor asserted `[[ -f MD5SUMS ]]` before copying it, so every one of
them failed outright the moment `monorepoSrc` was a git tree:
unpacking source archive /nix/store/...-source
source root is source
<exit 1>
Copy it only when it is there.
The generated sources are the other half: a checkout lacks
`gengtype-lex.cc` and friends, which a tarball ships pre-built, so they
have to be regenerated. Take flex and bison as native inputs when
`fromVCS` says the source is a checkout.
Tarball builds are unaffected either way.
Assisted-by: Claude Code (Claude Opus 5)
107 lines
1.9 KiB
Nix
107 lines
1.9 KiB
Nix
{
|
|
lib,
|
|
stdenv,
|
|
gcc_meta,
|
|
release_version,
|
|
version,
|
|
getVersionFile,
|
|
monorepoSrc ? null,
|
|
fetchpatch,
|
|
autoreconfHook269,
|
|
runCommand,
|
|
}:
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
pname = "libssp";
|
|
inherit version;
|
|
|
|
src = runCommand "libssp-src-${version}" { src = monorepoSrc; } (
|
|
''
|
|
runPhase unpackPhase
|
|
|
|
mkdir -p "$out/gcc"
|
|
cp gcc/BASE-VER "$out/gcc"
|
|
cp gcc/DATESTAMP "$out/gcc"
|
|
|
|
cp -r libssp "$out"
|
|
|
|
cp -r config "$out"
|
|
cp -r multilib.am "$out"
|
|
|
|
cp config.guess "$out"
|
|
cp config.rpath "$out"
|
|
cp config.sub "$out"
|
|
cp config-ml.in "$out"
|
|
cp ltmain.sh "$out"
|
|
cp install-sh "$out"
|
|
cp mkinstalldirs "$out"
|
|
|
|
''
|
|
# `MD5SUMS` exists only in release tarballs, not in a VCS checkout.
|
|
+ ''
|
|
if [[ -f MD5SUMS ]]; then cp MD5SUMS "$out"; fi
|
|
''
|
|
);
|
|
|
|
outputs = [
|
|
"out"
|
|
"dev"
|
|
];
|
|
|
|
patches = [
|
|
(fetchpatch {
|
|
name = "regular-libdir-includedir.patch";
|
|
url = "https://inbox.sourceware.org/gcc-patches/20250720172933.2404828-1-git@JohnEricson.me/raw";
|
|
hash = "sha256-W7dcy1Tm3O2reK7kx83DRv8W97qUfaqDbKLiLXIegRw=";
|
|
})
|
|
(getVersionFile "libssp/force-regular-dirs.patch")
|
|
];
|
|
|
|
postUnpack = ''
|
|
mkdir -p ./build
|
|
buildRoot=$(readlink -e "./build")
|
|
'';
|
|
|
|
preAutoreconf = ''
|
|
sourceRoot=$(readlink -e "./libssp")
|
|
cd $sourceRoot
|
|
'';
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
nativeBuildInputs = [
|
|
autoreconfHook269
|
|
];
|
|
|
|
configurePlatforms = [
|
|
"build"
|
|
"host"
|
|
];
|
|
|
|
configureFlags = [
|
|
"--disable-dependency-tracking"
|
|
"cross_compiling=true"
|
|
"--disable-multilib"
|
|
];
|
|
|
|
preConfigure = ''
|
|
cd "$buildRoot"
|
|
configureScript=$sourceRoot/configure
|
|
'';
|
|
|
|
hardeningDisable = [
|
|
"fortify"
|
|
# Because we are building it!
|
|
"stackprotector"
|
|
];
|
|
|
|
doCheck = true;
|
|
|
|
passthru = {
|
|
isGNU = true;
|
|
};
|
|
|
|
meta = gcc_meta // {
|
|
homepage = "https://gcc.gnu.org/";
|
|
};
|
|
})
|