Your message dated Fri, 03 Jun 2016 22:23:04 +0000
with message-id <e1b8xue-0002oi...@franck.debian.org>
and subject line Bug#826253: fixed in libf2c2 20130926-2
has caused the Debian Bug report #826253,
regarding libf2c2: not suitable for creating libraries to be used in 
non-Fortran programs
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact ow...@bugs.debian.org
immediately.)


-- 
826253: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=826253
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems
--- Begin Message ---
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
Description: Make MAIN__ a weak symbol
 Make MAIN__ a weak symbol, to make sure that non-f2c binaries can link
 against libraries created by it. Also make main() a weak symbol, just
 in case, because we really don't want to override a C program's main
 routine.
Author: Christian Seiler <christ...@iwakd.de>

--- a/main.c
+++ b/main.c
@@ -53,6 +53,20 @@ extern int MAIN__(void);
 #define Int int
 #endif
 
+/* Make main() a weak symbol. */
+int main(int argc, char **argv) __attribute__((weak));
+
+/* Create dummy MAIN__ function and make MAIN__ a weak alias to it.
+ * If linked against a program that exports MAIN__, i.e. one compiled
+ * by f2c, this MAIN__ will resolve to the program's MAIN__ instead,
+ * whereas normal C programs will still be able to link against this
+ * library. */
+static int weak_MAIN__()
+{
+  return -1;
+}
+extern int MAIN__() __attribute__((weak, alias("weak_MAIN__")));
+
 static VOID sigfdie(Sigarg)
 {
 Use_Sigarg;

Attachment: signature.asc
Description: OpenPGP digital signature


--- End Message ---
--- Begin Message ---
Source: libf2c2
Source-Version: 20130926-2

We believe that the bug you reported is fixed in the latest version of
libf2c2, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 826...@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Andreas Tille <ti...@debian.org> (supplier of updated libf2c2 package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmas...@ftp-master.debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Format: 1.8
Date: Fri, 03 Jun 2016 22:11:58 +0200
Source: libf2c2
Binary: libf2c2 libf2c2-dev
Architecture: source
Version: 20130926-2
Distribution: unstable
Urgency: medium
Maintainer: Barak A. Pearlmutter <b...@debian.org>
Changed-By: Andreas Tille <ti...@debian.org>
Description:
 libf2c2    - Shared libraries for use with FORTRAN applications
 libf2c2-dev - Development libraries for use with f2c
Closes: 826253
Changes:
 libf2c2 (20130926-2) unstable; urgency=medium
 .
   * Team upload
   * Make suitable for creating libraries to be used in non-Fortran programs
     (thanks for the patch to Christian Seiler <christ...@iwakd.de>)
     Closes: #826253
Checksums-Sha1:
 bd644d23afba47bbe5c8ee772aa8d85c8f04631b 1916 libf2c2_20130926-2.dsc
 72cd6b7cb2fdfab467c3f31c982576ea78889099 54760 libf2c2_20130926-2.debian.tar.xz
Checksums-Sha256:
 28f1a05fde02361bdd218ff7163cf32a12844d1ef0c65b18836f77408a61a46f 1916 
libf2c2_20130926-2.dsc
 565b72022ba4d3d1afab2905a372b21d7351bc0b2ce2f1eaf6839d072a3bdaf8 54760 
libf2c2_20130926-2.debian.tar.xz
Files:
 2ae879be93c4d8085d1f1a492f9d4734 1916 devel optional libf2c2_20130926-2.dsc
 ee67375bde01bb9d4452fd28db422e28 54760 devel optional 
libf2c2_20130926-2.debian.tar.xz

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCAAGBQJXUeXiAAoJEFeKBJTRxkbRT8kP/1pju6jyPC+teGuSWMMsL1E6
1VkrcBcy8Ojz27urRlQXRCPkBdqk8IHdfFdIXt/HeEtKSTysLJfWrudmp/7p8pvW
m2pMcblcUqa9Z6DpZdYvQG2hWZ0Kpe6t2u20dv2Bl21O22AhFl7nmcGO9HP5LvQO
YQJP3w9SOl9gNLqUAfQfRYXNm9fQY1kIJ8o90MhMyV3w0ytzR407YA4wF4jQNy3Y
KGKsz4RDSgpguZWDgL2yXk58KGKisvk0dyTvI2+LM2jEGaxKNH9XhwY4bYQBbx0+
AnCrxdqBSPEMBlHdF5Qf1HEov9kRbwtwoDAE5GNW733QpRlZcPDbtBM5i1DtAZB+
0lod1Oghfp+4SGUgtZRusiwyBMWkshH4h+JzTlg1hYtroTpDaplxh8Z7Zj38Tq3c
Tajnnx6E8Y4PiijfCwJs5bm6KFRYYeV8CeXdpiJxVsF0kdTsYBdjmDUBtbvQGlwT
zI3vcCtAqaaoBasvp3fyUc9bETvT8wnDh9YC+4dVHCUMoyNM5X0AgvrAYkJIVQeB
rFjx0QmPWe/4kB+IkTXbzqTfwKFlbpsxcTQ3YiAalrVpBqAUuc6TisTXPiJWP0hT
DcFX8Kki6esTLxlnta+O+qwayZ/jb/Td17TC4gdNXmn6NKTbQ8zjv1Bny+HqFfM6
ti0g7jdRam4o1ebuKSot
=Xv69
-----END PGP SIGNATURE-----

--- End Message ---

Reply via email to