2022-07-14 12:49:19 +00:00
|
|
|
{ stdenv, lib, autoPatchelfHook, fetchzip, xz, ncurses5, readline, gmp, mpfr
|
|
|
|
, expat, libipt, zlib, dejagnu, sourceHighlight, python3, elfutils, guile, glibc
|
2022-11-27 09:42:12 +00:00
|
|
|
, majorVersion
|
2022-07-14 12:49:19 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-11-27 09:42:12 +00:00
|
|
|
let
|
2023-01-20 10:41:00 +00:00
|
|
|
throwUnsupportedSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}";
|
2023-10-09 19:29:22 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation(finalAttrs:
|
|
|
|
let versionMap =
|
|
|
|
let url = "https://github.com/alire-project/GNAT-FSF-builds/releases/download/gnat-${finalAttrs.version}/gnat-${stdenv.hostPlatform.system}-${finalAttrs.version}.tar.gz";
|
|
|
|
in {
|
2022-11-27 09:42:12 +00:00
|
|
|
"11" = {
|
2023-01-20 10:41:00 +00:00
|
|
|
gccVersion = "11.2.0";
|
|
|
|
alireRevision = "4";
|
|
|
|
} // {
|
|
|
|
x86_64-darwin = {
|
2023-10-09 19:29:22 +00:00
|
|
|
inherit url;
|
2023-01-20 10:41:00 +00:00
|
|
|
hash = "sha256-FmBgD20PPQlX/ddhJliCTb/PRmKxe9z7TFPa2/SK4GY=";
|
|
|
|
upstreamTriplet = "x86_64-apple-darwin19.6.0";
|
|
|
|
};
|
|
|
|
x86_64-linux = {
|
2023-10-09 19:29:22 +00:00
|
|
|
inherit url;
|
2023-01-20 10:41:00 +00:00
|
|
|
hash = "sha256-8fMBJp6igH+Md5jE4LMubDmC4GLt4A+bZG/Xcz2LAJQ=";
|
|
|
|
upstreamTriplet = "x86_64-pc-linux-gnu";
|
|
|
|
};
|
|
|
|
}.${stdenv.hostPlatform.system} or throwUnsupportedSystem;
|
2022-11-27 09:42:12 +00:00
|
|
|
"12" = {
|
2023-01-20 10:41:00 +00:00
|
|
|
gccVersion = "12.1.0";
|
|
|
|
alireRevision = "2";
|
|
|
|
} // {
|
|
|
|
x86_64-darwin = {
|
2023-10-09 19:29:22 +00:00
|
|
|
inherit url;
|
2023-01-20 10:41:00 +00:00
|
|
|
hash = "sha256-zrcVFvFZMlGUtkG0p1wST6kGInRI64Icdsvkcf25yVs=";
|
|
|
|
upstreamTriplet = "x86_64-apple-darwin19.6.0";
|
|
|
|
};
|
|
|
|
x86_64-linux = {
|
2023-10-09 19:29:22 +00:00
|
|
|
inherit url;
|
2023-01-20 10:41:00 +00:00
|
|
|
hash = "sha256-EPDPOOjWJnJsUM7GGxj20/PXumjfLoMIEFX1EDtvWVY=";
|
|
|
|
upstreamTriplet = "x86_64-pc-linux-gnu";
|
|
|
|
};
|
|
|
|
}.${stdenv.hostPlatform.system} or throwUnsupportedSystem;
|
2022-11-27 09:42:12 +00:00
|
|
|
};
|
2023-10-09 19:29:22 +00:00
|
|
|
inherit (versionMap.${majorVersion}) gccVersion alireRevision upstreamTriplet;
|
|
|
|
in {
|
2023-04-29 16:46:19 +00:00
|
|
|
pname = "gnat-bootstrap";
|
2023-10-09 19:29:22 +00:00
|
|
|
inherit (versionMap.${majorVersion}) gccVersion alireRevision;
|
2023-01-20 10:41:00 +00:00
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
version = "${gccVersion}${lib.optionalString (alireRevision!="") "-"}${alireRevision}";
|
2021-08-05 21:33:18 +00:00
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
src = fetchzip {
|
2023-10-09 19:29:22 +00:00
|
|
|
inherit (versionMap.${majorVersion}) url hash;
|
2022-07-14 12:49:19 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
dejagnu
|
|
|
|
expat
|
|
|
|
gmp
|
|
|
|
guile
|
|
|
|
libipt
|
|
|
|
mpfr
|
|
|
|
ncurses5
|
|
|
|
python3
|
|
|
|
readline
|
|
|
|
sourceHighlight
|
|
|
|
xz
|
|
|
|
zlib
|
2023-03-15 16:39:30 +00:00
|
|
|
] ++ lib.optionals stdenv.buildPlatform.isLinux [
|
2023-01-20 10:41:00 +00:00
|
|
|
autoPatchelfHook
|
|
|
|
elfutils
|
|
|
|
glibc
|
2022-07-14 12:49:19 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-01-20 10:41:00 +00:00
|
|
|
postPatch = lib.optionalString (stdenv.hostPlatform.isDarwin) ''
|
|
|
|
substituteInPlace lib/gcc/${upstreamTriplet}/${gccVersion}/install-tools/mkheaders.conf \
|
|
|
|
--replace "SYSTEM_HEADER_DIR=\"/usr/include\"" "SYSTEM_HEADER_DIR=\"/include\""
|
|
|
|
''
|
|
|
|
# The included fixincl binary that is called during header fixup has a
|
|
|
|
# hardcoded execvp("/usr/bin/sed", ...) call, but /usr/bin/sed isn't
|
|
|
|
# available in the Nix Darwin stdenv. Fortunately, execvp() will search the
|
|
|
|
# PATH environment variable for the executable if its first argument does not
|
|
|
|
# contain a slash, so we can just change the string to "sed" and zero the
|
|
|
|
# other bytes.
|
|
|
|
+ ''
|
|
|
|
sed -i "s,/usr/bin/sed,sed\x00\x00\x00\x00\x00\x00\x00\x00\x00," libexec/gcc/${upstreamTriplet}/${gccVersion}/install-tools/fixincl
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out
|
2022-07-14 12:49:19 +00:00
|
|
|
cp -ar * $out/
|
2023-01-20 10:41:00 +00:00
|
|
|
''
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
# So far with the Darwin gnat-bootstrap binary packages, there have been two
|
2023-01-20 10:41:00 +00:00
|
|
|
# types of dylib path references to other dylibs that need fixups:
|
|
|
|
#
|
|
|
|
# 1. Dylibs in $out/lib with paths starting with
|
|
|
|
# /Users/runner/.../gcc/install that refer to other dylibs in $out/lib
|
|
|
|
# 2. Dylibs in $out/lib/gcc/*/*/adalib with paths starting with
|
|
|
|
# @rpath that refer to other dylibs in $out/lib/gcc/*/*/adalib
|
|
|
|
#
|
|
|
|
# Additionally, per Section 14.4 Fixed Headers in the GCC 12.2.0 manual [2],
|
|
|
|
# we have to update the fixed header files in current Alire GCC package, since it
|
|
|
|
# was built against macOS 10.15 (Darwin 19.6.0), but Nix currently
|
|
|
|
# builds against macOS 10.12, and the two header file structures differ.
|
|
|
|
# For example, the current Alire GCC package has a fixed <stdio.h>
|
|
|
|
# from macOS 10.15 that contains a #include <_stdio.h>, but neither the Alire
|
|
|
|
# GCC package nor macOS 10.12 have such a header (<xlocale/_stdio.h> and
|
|
|
|
# <secure/_stdio.h> in 10.12 are not equivalent; indeed, 10.15 <_stdio.h>
|
|
|
|
# says it contains code shared by <stdio.h> and <xlocale/_stdio.h>).
|
|
|
|
#
|
|
|
|
# [2]: https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Fixed-Headers.html
|
|
|
|
|
|
|
|
+ lib.optionalString (stdenv.hostPlatform.isDarwin) ''
|
|
|
|
upstreamBuildPrefix="/Users/runner/work/GNAT-FSF-builds/GNAT-FSF-builds/sbx/x86_64-darwin/gcc/install"
|
|
|
|
for i in "$out"/lib/*.dylib "$out"/lib/gcc/*/*/adalib/*.dylib; do
|
|
|
|
if [[ -f "$i" && ! -h "$i" ]]; then
|
|
|
|
install_name_tool -id "$i" "$i" || true
|
|
|
|
for old_path in $(otool -L "$i" | grep "$upstreamBuildPrefix" | awk '{print $1}'); do
|
|
|
|
new_path=`echo "$old_path" | sed "s,$upstreamBuildPrefix,$out,"`
|
|
|
|
install_name_tool -change "$old_path" "$new_path" "$i" || true
|
|
|
|
done
|
|
|
|
for old_path in $(otool -L "$i" | grep "@rpath" | awk '{print $1}'); do
|
|
|
|
new_path=$(echo "$old_path" | sed "s,@rpath,$(dirname "$i"),")
|
|
|
|
install_name_tool -change "$old_path" "$new_path" "$i" || true
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
"$out"/libexec/gcc/${upstreamTriplet}/${gccVersion}/install-tools/mkheaders -v -v \
|
|
|
|
"$out" "${stdenv.cc.libc}"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
passthru = {
|
|
|
|
langC = true; # TRICK for gcc-wrapper to wrap it
|
|
|
|
langCC = false;
|
|
|
|
langFortran = false;
|
|
|
|
langAda = true;
|
2023-01-20 10:41:00 +00:00
|
|
|
isGNU = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2022-07-14 12:49:19 +00:00
|
|
|
description = "GNAT, the GNU Ada Translator";
|
|
|
|
homepage = "https://www.gnu.org/software/gnat";
|
|
|
|
license = licenses.gpl3;
|
|
|
|
maintainers = with maintainers; [ ethindp ];
|
2023-01-20 10:41:00 +00:00
|
|
|
platforms = [ "x86_64-linux" "x86_64-darwin" ];
|
2023-04-29 16:46:19 +00:00
|
|
|
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2023-10-09 19:29:22 +00:00
|
|
|
})
|