fork
Configure Feed
Select the types of activity you want to include in your feed.
nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
fork
Configure Feed
Select the types of activity you want to include in your feed.
1{ stdenv, lib, autoPatchelfHook, fetchzip, xz, ncurses5, readline, gmp, mpfr
2, expat, libipt, zlib, dejagnu, sourceHighlight, python3, elfutils, guile, glibc
3, majorVersion
4}:
5
6let
7 throwUnsupportedSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}";
8in
9stdenv.mkDerivation(finalAttrs:
10 let versionMap =
11 let url = "https://github.com/alire-project/GNAT-FSF-builds/releases/download/gnat-${finalAttrs.version}/gnat-${stdenv.hostPlatform.system}-${finalAttrs.version}.tar.gz";
12 in {
13 "11" = {
14 gccVersion = "11.2.0";
15 alireRevision = "4";
16 } // {
17 x86_64-darwin = {
18 inherit url;
19 hash = "sha256-FmBgD20PPQlX/ddhJliCTb/PRmKxe9z7TFPa2/SK4GY=";
20 upstreamTriplet = "x86_64-apple-darwin19.6.0";
21 };
22 x86_64-linux = {
23 inherit url;
24 hash = "sha256-8fMBJp6igH+Md5jE4LMubDmC4GLt4A+bZG/Xcz2LAJQ=";
25 upstreamTriplet = "x86_64-pc-linux-gnu";
26 };
27 }.${stdenv.hostPlatform.system} or throwUnsupportedSystem;
28 "12" = {
29 gccVersion = "12.1.0";
30 alireRevision = "2";
31 } // {
32 x86_64-darwin = {
33 inherit url;
34 hash = "sha256-zrcVFvFZMlGUtkG0p1wST6kGInRI64Icdsvkcf25yVs=";
35 upstreamTriplet = "x86_64-apple-darwin19.6.0";
36 };
37 x86_64-linux = {
38 inherit url;
39 hash = "sha256-EPDPOOjWJnJsUM7GGxj20/PXumjfLoMIEFX1EDtvWVY=";
40 upstreamTriplet = "x86_64-pc-linux-gnu";
41 };
42 }.${stdenv.hostPlatform.system} or throwUnsupportedSystem;
43 };
44 inherit (versionMap.${majorVersion}) gccVersion alireRevision upstreamTriplet;
45in {
46 pname = "gnat-bootstrap";
47 inherit (versionMap.${majorVersion}) gccVersion alireRevision;
48
49 version = "${gccVersion}${lib.optionalString (alireRevision!="") "-"}${alireRevision}";
50
51 src = fetchzip {
52 inherit (versionMap.${majorVersion}) url hash;
53 };
54
55 nativeBuildInputs = [
56 dejagnu
57 expat
58 gmp
59 guile
60 libipt
61 mpfr
62 ncurses5
63 python3
64 readline
65 sourceHighlight
66 xz
67 zlib
68 ] ++ lib.optionals stdenv.buildPlatform.isLinux [
69 autoPatchelfHook
70 elfutils
71 glibc
72 ];
73
74 postPatch = lib.optionalString (stdenv.hostPlatform.isDarwin) ''
75 substituteInPlace lib/gcc/${upstreamTriplet}/${gccVersion}/install-tools/mkheaders.conf \
76 --replace "SYSTEM_HEADER_DIR=\"/usr/include\"" "SYSTEM_HEADER_DIR=\"/include\""
77 ''
78 # The included fixincl binary that is called during header fixup has a
79 # hardcoded execvp("/usr/bin/sed", ...) call, but /usr/bin/sed isn't
80 # available in the Nix Darwin stdenv. Fortunately, execvp() will search the
81 # PATH environment variable for the executable if its first argument does not
82 # contain a slash, so we can just change the string to "sed" and zero the
83 # other bytes.
84 + ''
85 sed -i "s,/usr/bin/sed,sed\x00\x00\x00\x00\x00\x00\x00\x00\x00," libexec/gcc/${upstreamTriplet}/${gccVersion}/install-tools/fixincl
86 '';
87
88 installPhase = ''
89 mkdir -p $out
90 cp -ar * $out/
91 ''
92
93 # So far with the Darwin gnat-bootstrap binary packages, there have been two
94 # types of dylib path references to other dylibs that need fixups:
95 #
96 # 1. Dylibs in $out/lib with paths starting with
97 # /Users/runner/.../gcc/install that refer to other dylibs in $out/lib
98 # 2. Dylibs in $out/lib/gcc/*/*/adalib with paths starting with
99 # @rpath that refer to other dylibs in $out/lib/gcc/*/*/adalib
100 #
101 # Additionally, per Section 14.4 Fixed Headers in the GCC 12.2.0 manual [2],
102 # we have to update the fixed header files in current Alire GCC package, since it
103 # was built against macOS 10.15 (Darwin 19.6.0), but Nix currently
104 # builds against macOS 10.12, and the two header file structures differ.
105 # For example, the current Alire GCC package has a fixed <stdio.h>
106 # from macOS 10.15 that contains a #include <_stdio.h>, but neither the Alire
107 # GCC package nor macOS 10.12 have such a header (<xlocale/_stdio.h> and
108 # <secure/_stdio.h> in 10.12 are not equivalent; indeed, 10.15 <_stdio.h>
109 # says it contains code shared by <stdio.h> and <xlocale/_stdio.h>).
110 #
111 # [2]: https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Fixed-Headers.html
112
113 + lib.optionalString (stdenv.hostPlatform.isDarwin) ''
114 upstreamBuildPrefix="/Users/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-darwin/gcc/install"
115 for i in "$out"/lib/*.dylib "$out"/lib/gcc/*/*/adalib/*.dylib; do
116 if [[ -f "$i" && ! -h "$i" ]]; then
117 install_name_tool -id "$i" "$i" || true
118 for old_path in $(otool -L "$i" | grep "$upstreamBuildPrefix" | awk '{print $1}'); do
119 new_path=`echo "$old_path" | sed "s,$upstreamBuildPrefix,$out,"`
120 install_name_tool -change "$old_path" "$new_path" "$i" || true
121 done
122 for old_path in $(otool -L "$i" | grep "@rpath" | awk '{print $1}'); do
123 new_path=$(echo "$old_path" | sed "s,@rpath,$(dirname "$i"),")
124 install_name_tool -change "$old_path" "$new_path" "$i" || true
125 done
126 fi
127 done
128
129 "$out"/libexec/gcc/${upstreamTriplet}/${gccVersion}/install-tools/mkheaders -v -v \
130 "$out" "${stdenv.cc.libc}"
131 '';
132
133 passthru = {
134 langC = true; # TRICK for gcc-wrapper to wrap it
135 langCC = false;
136 langFortran = false;
137 langAda = true;
138 isGNU = true;
139 };
140
141 meta = with lib; {
142 description = "GNAT, the GNU Ada Translator";
143 homepage = "https://www.gnu.org/software/gnat";
144 license = licenses.gpl3;
145 maintainers = with maintainers; [ ethindp ];
146 platforms = [ "x86_64-linux" "x86_64-darwin" ];
147 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
148 };
149})