From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!feeder.erje.net!1.eu.feeder.erje.net!ecngs!feeder2.ecngs.de!81.171.118.64.MISMATCH!peer04.fr7!futter-mich.highwinds-media.com!news.highwinds-media.com!fx44.am4.POSTED!not-for-mail From: Felix Krause Newsgroups: comp.lang.ada Message-ID: <2017101012134578343-contact@flyx.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Getting GNAT GPL 2017 to run on NixOS User-Agent: Unison/2.2 X-Complaints-To: abuse@eweka.nl NNTP-Posting-Date: Tue, 10 Oct 2017 10:13:45 UTC Organization: Eweka Internet Services Date: Tue, 10 Oct 2017 12:13:45 +0200 X-Received-Bytes: 3798 X-Received-Body-CRC: 2690339714 Xref: news.eternal-september.org comp.lang.ada:48414 Date: 2017-10-10T12:13:45+02:00 List-Id: NixOS provides a pretty old GNAT version, so I decided to try and install AdaCore's GNAT GPL 2017 release. I came up with the following nix expression which fetches the 64bit release from AdaCore, patches the ELF binaries to use the correct interpreter for NixOS, and sets some environment variables so that the tools find resources: { stdenv, fetchurl, patchelf, gnugrep, file, makeWrapper, ncurses5 }: stdenv.mkDerivation { name = "gnat-gpl-2017"; src = fetchurl { url = "http://mirrors.cdn.adacore.com/art/591c6d80c7a447af2deed1d7"; sha1 = "9682e2e1f2f232ce03fe21d77b14c37a0de5649b"; }; dontBuild = true; dontStrip = true; unpackCmd = "tar -xzf $curSrc"; buildInputs = [ gnugrep file patchelf makeWrapper ]; installPhase = '' set -e make ins-all prefix="$out" for path in $out/{bin,libexec/gcc/x86_64-pc-linux-gnu/6.3.1,libexec/gprbuild}/*; do if file "$path" | grep -q -i "elf"; then echo "Patching $path" if file "$path" | grep -q -i "executable"; then patchelf --set-interpreter "${stdenv.glibc}/lib/ld-linux-x86-64.so.2" "$path" fi patchelf --set-rpath "${stdenv.glibc}/lib" "$path" fi done mkdir -p $out/share/gnat/bin mv $out/bin/* $out/share/gnat/bin for path in $out/share/gnat/bin/{gnat,gpr}*; do if file "$path" | grep -q -i "elf"; then makeWrapper $path $out/bin/$(basename $path) --prefix PATH : $out/share/gnat/bin --set GNAT_ROOT $out --set GCC_ROOT $out --set LIBRARY_PATH "${stdenv.glibc}/lib" fi done makeWrapper $out/share/gnat/bin/gps $out/bin/gps --prefix PATH : $out/share/gnat/bin --set GNAT_ROOT $out --set GCC_ROOT $out --set GPS_ROOT $out --prefix LD_LIBRARY_PATH : $out/lib/gps/ ''; } I move all binaries into $out/share/gnat/bin because everything in $out/bin would be added to my environment which is undesirable (some tools collide with existing ones). Then I create wrappers for all gnat* and gpr* tools in $out/bin. The wrapper prepends $out/share/gnat/bin to PATH so that the tools can find the accompanying binaries. So far, so good; this got me a working gnatmake. However, the binary gnatmake creates references /lib64/ld-linux-x86-64.so.2 as interpreter instead of the correct NixOS interpreter. Is there a way to teach gnatmake which interpreter to write into the resulting binary? I also tried to use gprbuild, which fails with these lines when called on an existing project: No valid configuration found Generation of configuration files failed GNAT-TEMP-000001.TMP:1:01: "project" expected gprbuild: processing of configuration project "/tmp/GNAT-TEMP-000001.TMP" failed The file in /tmp does not exist (and is not the project I called gprbuild with). I am unsure what goes wrong here, any suggestions? I also did not get GPS to start yet due to a missing libncurses.so.5 which does not seem to be part of the distribution – strange as everything else is bundled. I will try to load NixOS' native ncurses. -- Regards, Felix Krause