[Debian-med-packaging] Bug#826253: libf2c2: not suitable for creating libraries to be used in non-Fortran programs
Christian Seiler
christian at iwakd.de
Fri Jun 3 17:17:31 UTC 2016
Package: libf2c2
Severity: serious
Version: 20130926-1
Tags: patch
Justification: violation of Debian policy 10.2 (libraries may
not depend on symbols that they don't import)
(cf. discussion on debian-mentors:
https://lists.debian.org/debian-mentors/2016/06/msg00090.html
+ followups)
On 06/03/2016 09:59 AM, Andreas Tille wrote:
> ...
> ../munge-help.sh consEntropy.help_src > consEntropy.help
> gcc -O3 -Wall -I/build/phast-1.4/src/util/../../include -DPHAST_VERSION=\"v1.3\" -DPHAST_HOME=\"/build/phast-1.4/src/util/../..\" -I/build/phast-1.4/src/util/../../src/lib/pcre -fno-strict-aliasing -I/usr/lib/INCLUDE -I/usr/lib/F2CLIBS -c indelHistory.c -o indelHistory.o
> gcc -L/build/phast-1.4/src/util/../../lib -L/usr/lib/F2CLIBS -o /build/phast-1.4/src/util/../../bin/indelHistory indelHistory.o -lphast -lclapack -lctmg -lcblas -lc -lf2c -lm
> /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libf2c.so: undefined reference to `MAIN__'
> collect2: error: ld returned 1 exit status
> Makefile:20: recipe for target '/build/phast-1.4/src/util/../../bin/indelHistory' failed
So what appears to be the case is the following: libf2c.so has
a function main(), which will be called with fortran programs
converted via f2c, because there needs to be some setup code
to happen before the actual main converted Fortran program can
be run. This main implementation then calls MAIN__, which f2c
generates for converted Fortran programs - but not subroutines.
As far as I can tell, this has the unfortunate consequence that
f2c can't really be used to generate libraries that are used
from anything but other code that is converted via f2c.
Steps to reproduce this issue:
#include <stdio.h>
int main() { printf("Hello World!\n"); }
gcc -Wall -o hello hello.c -lf2c
In this trivial example, this is not a huge issue (why would
you want to do so), but you can see the problem it creates in
other software.
Fortunately, there's a way out of this, by adding a weak alias
for MAIN__ in libf2c2's main.c. I've attached a patch that does
this (and also makes the main function in libf2c.so weak, just
in case). I've tested it in a sid chroot and at least my simple
hello example now compiles and runs. (Although linking that
against f2c is rather useless... But other programs will now
hopefully also work.)
Regards,
Christian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-weak-MAIN__.patch
Type: text/x-diff
Size: 953 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/debian-med-packaging/attachments/20160603/ecdea629/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: OpenPGP digital signature
URL: <http://lists.alioth.debian.org/pipermail/debian-med-packaging/attachments/20160603/ecdea629/attachment.sig>
More information about the Debian-med-packaging
mailing list