Dynamic Libraries

2012-03-07 Thread Doug Hardie
I have encountered something that I do not understand.  Everything works fine.  
Basically I have a bunch of user modules (low level) that are built into a 
dynamic library.  If I write top level code that calls modules in that library, 
everything works just fine on i386 and AMD64.  However, the application 
involved has another library of modules.  Some of them call modules in the low 
level library.  The top level code call modules in both libraries.  Often when 
it calls a module in the mid level library, that module calls several modules 
in the low level library.

All this works just fine on i386.  However, when I compile everything on AMD64 
I get an error message that says the lower level library needs to be compiled 
with fPIC.  If I add that to the Makefile for the lower level library and 
rebuild everything, it all works again.  I don't understand why the fPIC is 
required for AMD64.

Also, how do I tell if the lower level library is being dynamically linked at 
run time, or being directly incorporated into the mid level library or top 
level application?  Since both of these libraries are quite large, and they are 
in use by a number of top level applications, I want just one copy to exist in 
physical memory.___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Dynamic Libraries

2012-03-07 Thread Volodymyr Kostyrko

Doug Hardie wrote:

I have encountered something that I do not understand.  Everything works fine.  
Basically I have a bunch of user modules (low level) that are built into a 
dynamic library.  If I write top level code that calls modules in that library, 
everything works just fine on i386 and AMD64.  However, the application 
involved has another library of modules.  Some of them call modules in the low 
level library.  The top level code call modules in both libraries.  Often when 
it calls a module in the mid level library, that module calls several modules 
in the low level library.

All this works just fine on i386.  However, when I compile everything on AMD64 
I get an error message that says the lower level library needs to be compiled 
with fPIC.  If I add that to the Makefile for the lower level library and 
rebuild everything, it all works again.  I don't understand why the fPIC is 
required for AMD64.

Also, how do I tell if the lower level library is being dynamically linked at 
run time, or being directly incorporated into the mid level library or top 
level application?  Since both of these libraries are quite large, and they are 
in use by a number of top level applications, I want just one copy to exist in 
physical memory.


This sounds exactly like compiling with clang through ccache. There are 
issues with clang and ccache cooperation. Actually the one you may hit 
is libtool detecting implicit fPIC requirement when running clang 
through ccache.


--
Sphinx of black quartz judge my vow.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Dynamic Libraries

2012-03-07 Thread Doug Hardie

On 7 March 2012, at 01:40, Volodymyr Kostyrko wrote:

 Doug Hardie wrote:
 I have encountered something that I do not understand.  Everything works 
 fine.  Basically I have a bunch of user modules (low level) that are built 
 into a dynamic library.  If I write top level code that calls modules in 
 that library, everything works just fine on i386 and AMD64.  However, the 
 application involved has another library of modules.  Some of them call 
 modules in the low level library.  The top level code call modules in both 
 libraries.  Often when it calls a module in the mid level library, that 
 module calls several modules in the low level library.
 
 All this works just fine on i386.  However, when I compile everything on 
 AMD64 I get an error message that says the lower level library needs to be 
 compiled with fPIC.  If I add that to the Makefile for the lower level 
 library and rebuild everything, it all works again.  I don't understand why 
 the fPIC is required for AMD64.
 
 Also, how do I tell if the lower level library is being dynamically linked 
 at run time, or being directly incorporated into the mid level library or 
 top level application?  Since both of these libraries are quite large, and 
 they are in use by a number of top level applications, I want just one copy 
 to exist in physical memory.
 
 This sounds exactly like compiling with clang through ccache. There are 
 issues with clang and ccache cooperation. Actually the one you may hit is 
 libtool detecting implicit fPIC requirement when running clang through ccache.


The Makefile specifies GCC and its FreeBSD 8.0.  I don't believe clang was in 
that soon, but I may be wrong.  How can I check that?  Where is clang?  I have 
installed 9.0 on another system but haven't had time to try that out yet.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: Dynamic Libraries

2012-03-07 Thread Roland Smith
On Wed, Mar 07, 2012 at 12:53:13AM -0800, Doug Hardie wrote:

 All this works just fine on i386.  However, when I compile everything on
 AMD64 I get an error message that says the lower level library needs to be
 compiled with fPIC.  If I add that to the Makefile for the lower level
 library and rebuild everything, it all works again.  I don't understand why
 the fPIC is required for AMD64.

It is a requirement of the architecture. It is explained e.g. in: 
http://www.technovelty.org/code/c/amd64-pic.html
 
 Also, how do I tell if the lower level library is being dynamically linked
 at run time, or being directly incorporated into the mid level library or
 top level application? 

Examine the application with 'ldd -a binary'. That will give you a list of
all dynamic objects used by an application, and for each of those dynamic
objects the dynamic objects that they depend on. See ldd(1).

If your low-level libraries don't show up in that, they are not dynamically
loaded.

Roland
-- 
R.F.Smith   http://www.xs4all.nl/~rsmith/
[plain text _non-HTML_ PGP/GnuPG encrypted/signed email much appreciated]
pgp: 1A2B 477F 9970 BA3C 2914  B7CE 1277 EFB0 C321 A725 (KeyID: C321A725)


pgpAWHZ4rNFFt.pgp
Description: PGP signature