1{
2 lib,
3 stdenv,
4 gcc_meta,
5 release_version,
6 version,
7 getVersionFile,
8 monorepoSrc ? null,
9 fetchpatch,
10 autoreconfHook269,
11 runCommand,
12}:
13stdenv.mkDerivation (finalAttrs: {
14 pname = "libssp";
15 inherit version;
16
17 src = runCommand "libssp-src-${version}" { src = monorepoSrc; } ''
18 runPhase unpackPhase
19
20 mkdir -p "$out/gcc"
21 cp gcc/BASE-VER "$out/gcc"
22 cp gcc/DATESTAMP "$out/gcc"
23
24 cp -r libssp "$out"
25
26 cp -r config "$out"
27 cp -r multilib.am "$out"
28
29 cp config.guess "$out"
30 cp config.rpath "$out"
31 cp config.sub "$out"
32 cp config-ml.in "$out"
33 cp ltmain.sh "$out"
34 cp install-sh "$out"
35 cp mkinstalldirs "$out"
36
37 [[ -f MD5SUMS ]]; cp MD5SUMS "$out"
38 '';
39
40 outputs = [
41 "out"
42 "dev"
43 ];
44
45 patches = [
46 (fetchpatch {
47 name = "regular-libdir-includedir.patch";
48 url = "https://inbox.sourceware.org/gcc-patches/20250720172933.2404828-1-git@JohnEricson.me/raw";
49 hash = "sha256-W7dcy1Tm3O2reK7kx83DRv8W97qUfaqDbKLiLXIegRw=";
50 })
51 (getVersionFile "libssp/force-regular-dirs.patch")
52 ];
53
54 postUnpack = ''
55 mkdir -p ./build
56 buildRoot=$(readlink -e "./build")
57 '';
58
59 preAutoreconf = ''
60 sourceRoot=$(readlink -e "./libssp")
61 cd $sourceRoot
62 '';
63
64 enableParallelBuilding = true;
65
66 nativeBuildInputs = [
67 autoreconfHook269
68 ];
69
70 configurePlatforms = [
71 "build"
72 "host"
73 ];
74
75 configureFlags = [
76 "--disable-dependency-tracking"
77 "cross_compiling=true"
78 "--disable-multilib"
79 ];
80
81 preConfigure = ''
82 cd "$buildRoot"
83 configureScript=$sourceRoot/configure
84 '';
85
86 hardeningDisable = [
87 "fortify"
88 # Because we are building it!
89 "stackprotector"
90 ];
91
92 doCheck = true;
93
94 passthru = {
95 isGNU = true;
96 };
97
98 meta = gcc_meta // {
99 homepage = "https://gcc.gnu.org/";
100 };
101})