Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 277068 - sci-mathematics/octave-3.2.0 fails with forced --as-needed
Summary: sci-mathematics/octave-3.2.0 fails with forced --as-needed
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Linux bug wranglers
URL:
Whiteboard:
Keywords:
: 277466 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-07-08 17:44 UTC by Martin Väth
Modified: 2009-07-12 02:40 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch for liboctave/Makefile.in to include -lpthread dependency (octave-pthread.patch,298 bytes, patch)
2009-07-08 17:45 UTC, Martin Väth
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Väth 2009-07-08 17:44:04 UTC
Linking of the octave binary fails with the forced -Wl,--as-needed
(which is done in gentoo in current gcc versions).
The reason is that liboctave uses libpthread functions but is not linked
with -lpthread. The solution is of course to add -lpthread to the link flags
of liboctave. I append a patch.

Here is the relevant error during emerge:
x86_64-pc-linux-gnu-g++ -I/usr/include/freetype2 -I. -I.. -I../liboctave -I../src -I../libcruft/misc  -DHAVE_CONFIG_H  -Wall -W -Wshadow -Wold-style-cas
t -Wformat -march=native -O2 -fno-ident -pipe -I/usr/include/freetype2 -rdynamic \
        -L..  -fPIC  -o octave \
        main.o  \
        -L../liboctave -L../libcruft -L../src -Wl,-rpath -Wl,/usr/lib64/octave-3.2.0 \
        -loctinterp -loctave  -lcruft   \
          -lamd   \
           -llapack -lblas   -lblas   \
          -larpack -L/usr/X11R6/lib -lGL -lGLU \
        -L/usr/lib64 -lX11  -lreadline  -lncurses -ldl -lblas   -lz -lm  -lfreetype -lz -L/usr/X11R6/lib -lGL -lGLU -L/usr/X11R6/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.0 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.0/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.0/../../../../x86_64-pc-linux-gnu/lib -L/usr/lib/gcc/x86_64-pc-linux-gnu/4.4.0/../../.. -lz -lgfortranbegin -lgfortran -lm -lfreetype -lGL -lGLU
../liboctave/liboctave.so: undefined reference to `pthread_mutexattr_destroy'
../liboctave/liboctave.so: undefined reference to `pthread_mutexattr_init'
../liboctave/liboctave.so: undefined reference to `pthread_mutexattr_settype'
collect2: ld returned 1 exit status
Comment 1 Martin Väth 2009-07-08 17:45:16 UTC
Created attachment 197222 [details, diff]
Patch for liboctave/Makefile.in to include -lpthread dependency
Comment 2 bungernut 2009-07-08 22:18:31 UTC
I have the same bug. I am using the science overlay to get octave-3.2.0

I'm currently struggling to do my first patch ever to confirm the fix...

I copied your patch to:
# cp Desktop/octave-pthread.patch /var/tmp/portage/sci-mathematics/octave-3.2.0/work/octave-3.2.0/

run patch -p0? since your filenames are relitave to this location: 
--- liboctave/Makefile.in
+++ liboctave/Makefile.in

run the following:
octave-3.2.0 # patch -p0 <octave-pthread.patch

# emerge --digest octave

same error!

ln -s liboctinterp.so liboctinterp.so.3.2.0
i686-pc-linux-gnu-g++  -I. -I.. -I../liboctave -I../src -I../libcruft/misc  -DHAVE_CONFIG_H -mieee-fp -I/usr/include/freetype2 -Wall -W -Wshadow -Wold-style-cast -Wformat -march=athlon64 -O2 -pipe -rdynamic \
	-L..  -fPIC -Wl,-O1 -o octave \
	main.o  \
	-L../liboctave -L../libcruft -L../src -Wl,-rpath -Wl,/usr/lib/octave-3.2.0 \
	-loctinterp -loctave  -lcruft   \
	     \
	   -llapack -lblas   -lblas   \
	   -lftgl -lfreetype -lz -L/usr/X11R6/lib -lGL -lGLU \
	-lX11  -lreadline  -lncurses -ldl -lblas   -lz -lm  -L/usr/lib/gcc/i686-pc-linux-gnu/4.1.2 -L/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/../../../../i686-pc-linux-gnu/lib -L/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/../../.. -lz -lgfortranbegin -lgfortran -lm
../liboctave/liboctave.so: undefined reference to `pthread_mutexattr_destroy'
../liboctave/liboctave.so: undefined reference to `pthread_mutexattr_init'
../liboctave/liboctave.so: undefined reference to `pthread_mutexattr_settype'
collect2: ld returned 1 exit status
make[2]: *** [octave] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory `/var/tmp/portage/sci-mathematics/octave-3.2.0/work/octave-3.2.0/src'
make[1]: *** [src] Error 2
make[1]: Leaving directory `/var/tmp/portage/sci-mathematics/octave-3.2.0/work/octave-3.2.0'
make: *** [all] Error 2
 * 
 * ERROR: sci-mathematics/octave-3.2.0 failed.
 * Call stack:
 *               ebuild.sh, line   49:  Called src_compile
 *             environment, line 3157:  Called die
 * The specific snippet of code:
 *       emake || die "emake failed";
 *  The die message:
 *   emake failed
 * 
 * If you need support, post the topmost build error, and the call stack if relevant.
 * A complete build log is located at '/var/tmp/portage/sci-mathematics/octave-3.2.0/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/sci-mathematics/octave-3.2.0/temp/environment'.
 * 

 I'm not saying the patch dident work (it is probably me) .
Comment 3 Martin Väth 2009-07-09 11:26:24 UTC
(In reply to comment #2)
> I'm currently struggling to do my first patch ever to confirm the fix...

The bugtracker is not a support forum. There are certainly some howto's
in the net. Please ask in a forum or on a user mailing list for help if
you cannot find out.
Roughly speaking, you have to copy the ebuild directory to a local overlay,
put the patch in the corresponding files/ directory and add a corresponding
epatch command to the src_unpack or src_prepare function (depending on the
EAPI).
Comment 4 Markus Dittrich (RETIRED) gentoo-dev 2009-07-10 15:46:49 UTC
Hi Martin,

Thanks much for the report and patch. Strangely, everything
compiles fine for me on x86 and amd64 despite the --as-needed.
I am not quite sure why.

In any case, since the patch is fairly unobtrusive I've just
added it to the ebuild which should hopefully fix your problems.

Thanks again,
Markus
Comment 5 Martin Väth 2009-07-10 17:27:42 UTC
Thanks for the fix.

(In reply to comment #4)
> Strangely, everything
> compiles fine for me on x86 and amd64 despite the --as-needed.

For me it failed on both.
There are quite a few possible explanations, but I have not tried which one
applies:

1. The _forced_ --Wl,--as-needed is perhaps only in new gcc versions
(I use gcc-4.4). If it is not forced, it depends on _where_ it occurs on the
linking line: The problem arises only if it occurs before the -loctave
option.

2. It might also play a role that I have "export LD_BIND_NOW=1" in my profile
(although it would surprise me, if this would really be relevant here).

3. Perhaps the function calls are only compiled if certain USE flags (i.e.
./configure options) are set; or perhaps vice versa, if certain USE flags
are set then a certain library might be linked against liboctave which in
turn links to libthreads. The USE flags for octave were in my case:
USE="doc emacs readline zlib -curl -debug -fftw -hdf5 -sparse -xemacs"
Comment 6 Rafał Mużyło 2009-07-12 02:40:45 UTC
*** Bug 277466 has been marked as a duplicate of this bug. ***