[Bug ld/17479] New: Shared object missing symbol explicitly specified in --retain-symbols-file

2014-10-11 Thread predictivestatmech at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=17479

Bug ID: 17479
   Summary: Shared object missing symbol explicitly specified in
--retain-symbols-file
   Product: binutils
   Version: 2.20
Status: NEW
  Severity: normal
  Priority: P2
 Component: ld
  Assignee: unassigned at sourceware dot org
  Reporter: predictivestatmech at gmail dot com

I'm creating a shared library packaging a monstrous proliferation of small
static libraries (compiled from fortran sources using -fPIC ... with objects
from each directory bundled to the static libs with ar).

Since there is some duplication in symbol names between the .a files, I am
specifying the complete list of (77) exports with
--retain-symbols-file=sym.list inside the final link line:

gfortran -shared -Wl,--retain-symbols-file=sym.list
-L$HOME/build/nwchem-6.3/lib/LINUX64
-L$HOME/build/nwchem-6.3/src/tools/install/lib -fPIC -o
$HOME/build/nwchem-6.3/lib/LINUX64/libnwchem.so libnwchem.o stubs.o
-Wl,--start-group -lnwctask -lccsd -lmcscf -lselci -lmp2 -lmoints -lstepper
-ldriver -loptim -lnwdft -lgradients -lcphf -lesp -lddscf -ldangchang -lguess
-lhessian -lvib -lnwcutil -lrimp2 -lproperty -lnwints -lprepar -lnwmd -lnwpw
-lofpw -lpaw -lpspw -lband -lnwpwlib -lnwxc -lcafe -lspace -lanalyze -lqhop
-lpfft -ldplot -ldrdy -lvscf -lqmmm -lqmd -letrans -lpspw -ltce -lbq -lcons
-lperfm -ldntmc -lccca -lnwcutil -lga -larmci -lpeigs -lperfm -lcons -lbq
-lnwcutil -Wl,--end-group (external dependency libraries)

Although linking produces an 80Mb library which loads without errors with
python's ctypes (CDLL("libnwchem.so")), when trying to use it, I found that at
least two of the functions are missing.

File "/usr/lib64/python2.6/ctypes/__init__.py", line 371, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: libnwchem.so: undefined symbol: push_inp_cstring

Which I think is a bit odd, since that is specifically listed as the first line
at the top of the sym.list file,

push_inp_cstring
input_parse_
nwchem_init_
nwchem_dtor_
task_input_
task_
...

If I ignore the missing push_inp_cstring, the next missing function out of the
list above is "task_".


The relevant object is in the static library:

nm -s ../lib/LINUX64/libnwcutil.a | grep push_inp
push_inp_string_ in nw_inp_from_file.o
push_inp_cstring in push_inp_cstring.o
0430 T push_inp_string_
0038 d push_inp_string_$BLK$format_pack.0.4
push_inp_cstring.o:
 T push_inp_cstring
 U push_inp_string_

but not in the dynamic one (verified with readelf --syms).

The same happens for task_
nm -s ../lib/LINUX64/libnwctask.a | grep "task_ *$"
 U stpr_walk_task_
 T task_


Is the zero-address a clue here, or the source of a failed link?

-- 
You are receiving this mail because:
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/17479] Shared object missing symbol explicitly specified in --retain-symbols-file

2014-10-11 Thread predictivestatmech at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=17479

David Rogers  changed:

   What|Removed |Added

   Host||Linux
   ||2.6.32-431.23.3.el6.x86_64
   ||#1 SMP Tue Jul 29 11:12:56
   ||CDT 2014 x86_64 x86_64
   ||x86_64 GNU/Linux

--- Comment #1 from David Rogers  ---
GNU ld version 2.20.51.0.2-5.36.el6 20100205
(rpm binutils-2.20.51.0.2-5.36.el6.x86_64)
GNU Fortran (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)

The object files were produced by:
ifort (IFORT) 11.1 20091130

-- 
You are receiving this mail because:
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/17479] Shared object missing symbol explicitly specified in --retain-symbols-file

2014-10-17 Thread predictivestatmech at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=17479

--- Comment #3 from David Rogers  ---
On 10/14/14, 5:40 AM, amodra at gmail dot com wrote:
> https://sourceware.org/bugzilla/show_bug.cgi?id=17479
>
> Alan Modra  changed:
>
> What|Removed |Added
> 
>   CC||amodra at gmail dot com
>
> --- Comment #2 from Alan Modra  ---
> If you omit -Wl,--retain-symbols-file=sym.list does the shared library contain
> the symbols you seem to have misplaced?  I suspect the reason they are missing
> is simply that their object file is not included in the link.  An object 
> within
> an archive library won't be extracted unless it satisfies some undefined 
> symbol
> at the point the archive is searched.  See also the --whole-archive option.
>
No, omitting

-Wl,--retain-symbols-file=sym.list

makes the shared library even smaller, and is still missing the 
functions I'm looking for.

I'm trying to create a shared library containing lots of individual 
functions, so I don't have a single object file that references them.

I did get linking to succeed as you suggest using --whole-archive on two 
specific static ".a" libraries (after removing some useless functions 
that didn't link due to undefined references).  However, I thought the 
retain-symbols-file was supposed to offer more fine-grained control.  
That way, I could cherry pick just the individual functions I need for 
the shared library (and are sure to link).  I suppose another hack would 
be to create an object file that calls each function, but that seems 
unsatisfactory in general.

~ David.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug ld/17479] Shared object missing symbol explicitly specified in --retain-symbols-file

2014-10-17 Thread predictivestatmech at gmail dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=17479

--- Comment #5 from David Rogers  ---
I guess the documentation on --retain-symbols-file should be clarified
[https://sourceware.org/bugzilla/show_bug.cgi?id=11650] if it can't be used for
thus purpose.  I thought the listed symbols would be added to the unresolved
list, which is why I put it first in the link-line.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils