From 38b4a4364de02412795e4a452a0cfab9189d228f Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Sun, 8 Aug 2021 20:09:38 +0200 Subject: [PATCH 1/3] ecl: inform ecl about libraries to link against via configure flags All libraries that ecl will have compiled libraries and executables link against now have their own --with--incdir and --with--libdir flag which is perfect for our distinct lib and dev outputs. Consequently, we can get rid of the NIX_LDFLAGS-based hack in the wrapper since ecl can figure out which flags to pass on its own. --- pkgs/development/compilers/ecl/default.nix | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkgs/development/compilers/ecl/default.nix b/pkgs/development/compilers/ecl/default.nix index 269beef9e7a..e891c898c47 100644 --- a/pkgs/development/compilers/ecl/default.nix +++ b/pkgs/development/compilers/ecl/default.nix @@ -45,20 +45,20 @@ stdenv.mkDerivation { configureFlags = [ (if threadSupport then "--enable-threads" else "--disable-threads") - "--with-gmp-prefix=${lib.getDev gmp}" - "--with-libffi-prefix=${lib.getDev libffi}" - ] ++ lib.optional useBoehmgc "--with-libgc-prefix=${lib.getDev boehmgc}" - ++ lib.optional (!noUnicode) "--enable-unicode"; + "--with-gmp-incdir=${lib.getDev gmp}/include" + "--with-gmp-libdir=${lib.getLib gmp}/lib" + "--with-libffi-incdir=${lib.getDev libffi}/include" + "--with-libffi-libdir=${lib.getLib libffi}/lib" + ] ++ lib.optionals useBoehmgc [ + "--with-libgc-incdir=${lib.getDev boehmgc}/include" + "--with-libgc-libdir=${lib.getLib boehmgc}/lib" + ] ++ lib.optional (!noUnicode) "--enable-unicode"; hardeningDisable = [ "format" ]; - postInstall = let - ldArgs = lib.strings.concatMapStringsSep " " - (l: ''--prefix NIX_LDFLAGS ' ' "-L${l.lib or l.out or l}/lib"'') - ([ gmp libffi ] ++ lib.optional useBoehmgc boehmgc); - in '' + postInstall = '' sed -e 's/@[-a-zA-Z_]*@//g' -i $out/bin/ecl-config - wrapProgram "$out/bin/ecl" --prefix PATH ':' "${gcc}/bin" ${ldArgs} + wrapProgram "$out/bin/ecl" --prefix PATH ':' "${gcc}/bin" ''; meta = with lib; { From ccef83bd40028cb2dd852e9c170307d4936f40d8 Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Sun, 8 Aug 2021 20:16:36 +0200 Subject: [PATCH 2/3] ecl_16_1_2: fix linking of compiled programs * Use --with-gmp-incdir and --with-gmp-libdir (like for the main ecl derivation), so ecl can figure out the flags to pass on its own. Remove NIX_LDFLAGS hack for gmp. * Make sure ecl can find boehmgc when linking programs / libraries via NIX_LDFLAGS. Pass correct -I for boehmgc via NIX_CFLAGS_COMPILE since there's no --with-boehmgc-prefix configure flag to achieve the same result. * Use correct suffixSalt for every flag. This makes NIX_CFLAGS_COMPILE work properly in the first place and should prevent the extra flags hacks leaking into other places in some edge cases. --- pkgs/development/compilers/ecl/16.1.2.nix | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pkgs/development/compilers/ecl/16.1.2.nix b/pkgs/development/compilers/ecl/16.1.2.nix index 0789addb337..e0017c42f8e 100644 --- a/pkgs/development/compilers/ecl/16.1.2.nix +++ b/pkgs/development/compilers/ecl/16.1.2.nix @@ -38,8 +38,10 @@ stdenv.mkDerivation { configureFlags = [ (if threadSupport then "--enable-threads" else "--disable-threads") - "--with-gmp-prefix=${gmp.dev}" - "--with-libffi-prefix=${libffi.dev}" + "--with-gmp-incdir=${lib.getDev gmp}/include" + "--with-gmp-libdir=${lib.getLib gmp}/lib" + # -incdir, -libdir doesn't seem to be supported for libffi + "--with-libffi-prefix=${lib.getDev libffi}" ] ++ (lib.optional (! noUnicode) @@ -70,8 +72,18 @@ stdenv.mkDerivation { sed -e 's/@[-a-zA-Z_]*@//g' -i $out/bin/ecl-config wrapProgram "$out/bin/ecl" \ --prefix PATH ':' "${gcc}/bin" \ - --prefix NIX_LDFLAGS ' ' "-L${gmp.lib or gmp.out or gmp}/lib" \ - --prefix NIX_LDFLAGS ' ' "-L${libffi.lib or libffi.out or libffi}/lib" + '' + # ecl 16.1.2 is too old to have -libdir for libffi and boehmgc, so we need to + # use NIX_LDFLAGS_BEFORE to make gcc find these particular libraries. + # Since it is missing even the prefix flag for boehmgc we also need to inject + # the correct -I flag via NIX_CFLAGS_COMPILE. Since we have access to it, we + # create the variables with suffixSalt (which seems to be necessary for + # NIX_CFLAGS_COMPILE even). + + lib.optionalString useBoehmgc '' + --prefix NIX_CFLAGS_COMPILE_${gcc.suffixSalt} ' ' "-I${lib.getDev boehmgc}/include" \ + --prefix NIX_LDFLAGS_BEFORE_${gcc.bintools.suffixSalt} ' ' "-L${lib.getLib boehmgc}/lib" \ + '' + '' + --prefix NIX_LDFLAGS_BEFORE_${gcc.bintools.suffixSalt} ' ' "-L${lib.getLib libffi}/lib" ''; meta = { From 18a4e4f94f50b991280148c9b3b3325d577d5c2b Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Mon, 9 Aug 2021 03:01:02 +0200 Subject: [PATCH 3/3] ecl, ecl_16_1_2: make sure ar is in PATH --- pkgs/development/compilers/ecl/16.1.2.nix | 7 ++++++- pkgs/development/compilers/ecl/default.nix | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/ecl/16.1.2.nix b/pkgs/development/compilers/ecl/16.1.2.nix index e0017c42f8e..7736b71e56e 100644 --- a/pkgs/development/compilers/ecl/16.1.2.nix +++ b/pkgs/development/compilers/ecl/16.1.2.nix @@ -71,7 +71,12 @@ stdenv.mkDerivation { postInstall = '' sed -e 's/@[-a-zA-Z_]*@//g' -i $out/bin/ecl-config wrapProgram "$out/bin/ecl" \ - --prefix PATH ':' "${gcc}/bin" \ + --prefix PATH ':' "${ + lib.makeBinPath [ + gcc # for the C compiler + gcc.bintools.bintools # for ar + ] + }" \ '' # ecl 16.1.2 is too old to have -libdir for libffi and boehmgc, so we need to # use NIX_LDFLAGS_BEFORE to make gcc find these particular libraries. diff --git a/pkgs/development/compilers/ecl/default.nix b/pkgs/development/compilers/ecl/default.nix index e891c898c47..44f7eab62ee 100644 --- a/pkgs/development/compilers/ecl/default.nix +++ b/pkgs/development/compilers/ecl/default.nix @@ -58,7 +58,12 @@ stdenv.mkDerivation { postInstall = '' sed -e 's/@[-a-zA-Z_]*@//g' -i $out/bin/ecl-config - wrapProgram "$out/bin/ecl" --prefix PATH ':' "${gcc}/bin" + wrapProgram "$out/bin/ecl" --prefix PATH ':' "${ + lib.makeBinPath [ + gcc # for the C compiler + gcc.bintools.bintools # for ar + ] + }" ''; meta = with lib; {