Merge pull request #133176 from sternenseemann/ecl-fix-link-flags

ecl, ecl_16_1_2: fix linking of natively built libraries and executables
This commit is contained in:
Michael Raskin 2021-08-09 09:05:29 +00:00 committed by GitHub
commit 8817b01339
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 15 deletions

View file

@ -38,8 +38,10 @@ stdenv.mkDerivation {
configureFlags = [ configureFlags = [
(if threadSupport then "--enable-threads" else "--disable-threads") (if threadSupport then "--enable-threads" else "--disable-threads")
"--with-gmp-prefix=${gmp.dev}" "--with-gmp-incdir=${lib.getDev gmp}/include"
"--with-libffi-prefix=${libffi.dev}" "--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) (lib.optional (! noUnicode)
@ -69,9 +71,24 @@ stdenv.mkDerivation {
postInstall = '' postInstall = ''
sed -e 's/@[-a-zA-Z_]*@//g' -i $out/bin/ecl-config sed -e 's/@[-a-zA-Z_]*@//g' -i $out/bin/ecl-config
wrapProgram "$out/bin/ecl" \ wrapProgram "$out/bin/ecl" \
--prefix PATH ':' "${gcc}/bin" \ --prefix PATH ':' "${
--prefix NIX_LDFLAGS ' ' "-L${gmp.lib or gmp.out or gmp}/lib" \ lib.makeBinPath [
--prefix NIX_LDFLAGS ' ' "-L${libffi.lib or libffi.out or libffi}/lib" 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.
# 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 = { meta = {

View file

@ -45,20 +45,25 @@ stdenv.mkDerivation {
configureFlags = [ configureFlags = [
(if threadSupport then "--enable-threads" else "--disable-threads") (if threadSupport then "--enable-threads" else "--disable-threads")
"--with-gmp-prefix=${lib.getDev gmp}" "--with-gmp-incdir=${lib.getDev gmp}/include"
"--with-libffi-prefix=${lib.getDev libffi}" "--with-gmp-libdir=${lib.getLib gmp}/lib"
] ++ lib.optional useBoehmgc "--with-libgc-prefix=${lib.getDev boehmgc}" "--with-libffi-incdir=${lib.getDev libffi}/include"
++ lib.optional (!noUnicode) "--enable-unicode"; "--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" ]; hardeningDisable = [ "format" ];
postInstall = let postInstall = ''
ldArgs = lib.strings.concatMapStringsSep " "
(l: ''--prefix NIX_LDFLAGS ' ' "-L${l.lib or l.out or l}/lib"'')
([ gmp libffi ] ++ lib.optional useBoehmgc boehmgc);
in ''
sed -e 's/@[-a-zA-Z_]*@//g' -i $out/bin/ecl-config 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 ':' "${
lib.makeBinPath [
gcc # for the C compiler
gcc.bintools.bintools # for ar
]
}"
''; '';
meta = with lib; { meta = with lib; {