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.
This commit is contained in:
sternenseemann 2021-08-08 20:16:36 +02:00
parent 38b4a4364d
commit ccef83bd40

View file

@ -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 = {