Opened 5 years ago

Closed 5 years ago

Last modified 14 months ago

#9620 closed bug (fixed)

libffi.a is put in the wrong folder

Reported by: rezb1t Owned by:
Priority: normal Milestone: 7.8.4
Component: Build System (make) Version: 7.9
Keywords: libffi lib64 Cc: slyfox
Operating System: Linux Architecture: Unknown/Multiple
Type of failure: Building GHC failed Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

This is dfeuer's error message, but it is equivalent to mine on NixOS x86_64

"/home/dfeuer/GHC/7.8.3.bin/bin/ghc" -o utils/genapply/dist/build/tmp/genapply -hisuf hi -osuf  o -hcsuf hc -static  -O -H64m -package pretty -package-db libraries/bootstrapping.conf   -i -iutils/genapply/. -iutils/genapply/dist/build -iutils/genapply/dist/build/autogen -Iutils/genapply/dist/build -Iutils/genapply/dist/build/autogen         -no-user-package-db -rtsopts      -odir utils/genapply/dist/build -hidir utils/genapply/dist/build -stubdir utils/genapply/dist/build    -static  -O -H64m -package pretty -package-db libraries/bootstrapping.conf   -i -iutils/genapply/. -iutils/genapply/dist/build -iutils/genapply/dist/build/autogen -Iutils/genapply/dist/build -Iutils/genapply/dist/build/autogen         -no-user-package-db -rtsopts      utils/genapply/dist/build/GenApply.o    
libffi/stamp.ffi.static-shared.install exists, but libffi/build/inst/lib/libffi.a does not.
Suggest removing libffi/stamp.ffi.static-shared.install.
make[1]: *** [libffi/build/inst/lib/libffi.a] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2

libffi.a is build and linked into libffi/build/inst/lib64 instead of libffi/build/inst/lib, but the includes and pkg-config specific stuff is still put into libffi/build/inst/lib. GHC looks in lib for libffi.a and fails, the current workaround is to copy the contents of libffi/build/inst/lib64 into libffi/build/inst/lib and type make again. Symlinking won't work because libffi seems to sanitize the build directory before building the library

I'd like to note that when compiling via the Debian source snapshot, libffi is put in the correct place if I run ./configure without using perl boot.

Attachments (1)

config.zip (146.2 KB) - added by rezb1t 5 years ago.
libffi/build/configure libffi/build/x86_64-unknown-linux-gnu/config.log

Download all attachments as: .zip

Change History (18)

comment:1 Changed 5 years ago by rwbarton

I suspect this is due to a distro-specific autotools difference, especially in light of your last sentence.

Can you attach your libffi/build/configure and libffi/build/*/config.log files?

Changed 5 years ago by rezb1t

Attachment: config.zip added

libffi/build/configure libffi/build/x86_64-unknown-linux-gnu/config.log

comment:2 Changed 5 years ago by rezb1t

Added requested logs, I checked autoconf and automake and they don't appear to have patches applied. There could be some other difference happening because of NixOS, though.

comment:3 Changed 5 years ago by dfeuer

Keywords: nixos removed

This is not just NixOS. I'm seeing it here on Fedora 20.

comment:4 Changed 5 years ago by dfeuer

But your workaround does not work for me. I then get a new message:

make[1]: *** No rule to make target `libffi/build/inst/lib/libffi.so',
needed by `rts/dist/build/libffi.so'.  Stop.
Last edited 5 years ago by dfeuer (previous) (diff)

comment:5 Changed 5 years ago by rwbarton

Aha, here is the difference. From libffi's configure.ac:

  multi_os_directory=`$CC $CFLAGS -print-multi-os-directory`
  case $multi_os_directory in
    .) ;; # Avoid trailing /.
    ../*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
  esac

Your gcc -print-multi-os-directory must print ../lib64, while mine prints ../lib.

I don't yet see a great way to fix this, though...

comment:6 in reply to:  5 Changed 5 years ago by dfeuer

Replying to rwbarton:

Your gcc -print-multi-os-directory must print ../lib64, while mine prints ../lib.

I don't yet see a great way to fix this, though...

I can verify that mine prints ../lib64. It sounds likely that someone accidentally hardcoded ../lib somewhere else.

comment:7 Changed 5 years ago by rwbarton

Well it's not accidental. ghc's build system configures libffi with --libdir=$(TOP)/libffi/build/inst/lib with the intention that libffi should install its libraries into libffi/build/inst/lib. However libffi insists on installing its libraries into this mysterious "toolexeclibdir" instead.

Seems like Gentoo ran into the same issue when packaging libffi: https://sourceware.org/ml/libffi-discuss/2014/msg00016.html

Maybe we can adopt their workaround of sed -i 's:@toolexeclibdir@:$(libdir):g' Makefile.in before running libffi's configure script.

comment:8 Changed 5 years ago by rwbarton

dfeuer, could you try building with this patch?

diff --git a/libffi/ghc.mk b/libffi/ghc.mk
index bc62ad9..67dedf9 100644
--- a/libffi/ghc.mk
+++ b/libffi/ghc.mk
@@ -69,6 +69,11 @@ $(libffi_STAMP_CONFIGURE): $(TOUCH_DEP)
        mv libffi/build/Makefile.in libffi/build/Makefile.in.orig
        sed "s/-MD/-MMD/" < libffi/build/Makefile.in.orig > libffi/build/Makefile.in
 
+       # libffi does not properly respect libdir; force it to do so.
+       # (https://sourceware.org/ml/libffi-discuss/2014/msg00016.html)
+       mv libffi/build/Makefile.in libffi/build/Makefile.in.orig
+       sed 's:@toolexeclibdir@:$$(libdir):g' < libffi/build/Makefile.in.orig > libffi/build/Makefile.in
+
        # Their cmd invocation only works on msys. On cygwin it starts
        # a cmd interactive shell. The replacement works in both environments.
        mv libffi/build/ltmain.sh libffi/build/ltmain.sh.orig

comment:9 Changed 5 years ago by slyfox

Cc: slyfox added

comment:10 Changed 5 years ago by slyfox

I'm also on gentoo/am64 and rwbarton's fix unbreaks build for me.

I suggest pushing it as is.

Thanks!

comment:11 Changed 5 years ago by rezb1t

The patch fixes the issue for me as well, thanks!

comment:12 Changed 5 years ago by Reid Barton <rwbarton@…>

In 835d874df1973b7e1c602a747b42b77095592a9c/ghc:

Make libffi install into a predictable directory (#9620)

On some systems (depending on gcc multilib configuration) libffi
would install into libffi/build/inst/lib64 even though we configure
it with --libdir=libffi/build/inst/lib. There appears to be no way
to get libffi to install to a predictable directory "out of the box",
so we apply a small patch to Makefile.in. This is the same fix used
in Gentoo's ebuild (https://bugs.gentoo.org/show_bug.cgi?id=462814).

comment:13 Changed 5 years ago by rwbarton

Resolution: fixed
Status: newclosed

comment:14 Changed 5 years ago by rwbarton

Milestone: 7.10.17.8.4
Status: closedmerge

Actually, might as well merge this too.

comment:15 Changed 5 years ago by thoughtpolice

Milestone: 7.8.47.10.1

Moving (in bulk) to 7.10.4

comment:16 Changed 5 years ago by thoughtpolice

Milestone: 7.10.17.8.4
Status: mergeclosed

Merged to 7.8.4.

comment:17 Changed 14 months ago by bgamari

Component: Build SystemBuild System (make)

The new Hadrian build system has been merged. Relabeling the tickets concerning the legacy make build system to prevent confusion.

Note: See TracTickets for help on using tickets.