www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11342] New: shared libs don't play well with etc.c.zlib

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11342

           Summary: shared libs don't play well with etc.c.zlib
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: nobody puremagic.com
        ReportedBy: lomereiter gmail.com



PDT ---
If I compile a file importing etc.c.zlib into a shared library as
rdmd --build-only -shared -fPIC -lphobos2 testsharedlib.d,

I get this when trying to load the library:

Fatal Error while loading
'/home/lomereiter/dmd2/linux/lib64/libphobos2.so.0.64':
        The module 'etc.c.zlib' is already defined in './testsharedlib'.


---
testsharedlib.d:

import etc.c.zlib;
void main() {}

---
loading from Python:

import ctypes
lib = ctypes.CDLL('./testsharedlib')

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 24 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11342


Artem Tarasov <lomereiter gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |major


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 24 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11342


Artem Tarasov <lomereiter gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|major                       |regression



PDT ---
AFAIU DMD 2.064 should come with a shared version of Zlib library, because
otherwise its symbols become duplicated, and module collision detector prevents
loading user-produced shared libraries (that behaviour was introduced in
https://github.com/D-Programming-Language/druntime/pull/487)

So I mark that as a regression, 'cause I don't wanna be stuck with buggy 2.063
shared library support.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 27 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11342


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |INVALID



22:59:45 PDT ---
Don't link in the unshared version of phobos when building a shared library,
otherwise you'll get multiple definitions of the same symbols.

Any shared libs you create should be linked against libphobos2.so, not
-lphobos2.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 27 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11342


Artem Tarasov <lomereiter gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |



PDT ---
But it is linked against _shared_ version. Moreover, it is impossible to link
against libphobos2.a because it's not compiled with -fPIC.

I have to specify -L-lphobos2 on the command line just for that, otherwise DMD
tries to use static libphobos2.a, and linker barks that it should be recompiled
with -fPIC

 /usr/bin/ld: /home/artem/dmd2/linux/bin64/../lib64/libphobos2.a(
ifetime_46c_6c8.o): relocation R_X86_64_32 against
`_D15TypeInfo_Shared7__ClassZ' can not be used when making a shared object;
recompile with -fPIC
 /home/artem/dmd2/linux/bin64/../lib64/libphobos2.a: could not read symbols:
Bad value
 collect2: ld returned 1 exit status
-- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 28 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11342


Martin Nowak <code dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |INVALID



Seems like rdmd includes the etc in the build so the error message is correct
because the etc.c.zlib module is already defined in libphobos2.so.
Try the --exclude=etc option to avoid this.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 29 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11342





 Seems like rdmd includes the etc in the build so the error message is correct
 because the etc.c.zlib module is already defined in libphobos2.so.
 Try the --exclude=etc option to avoid this.
The other part of the story is that rdmd should know about this and not build etc.c phobos modules. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 29 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11342




PDT ---

 Seems like rdmd includes the etc in the build so the error message is correct
 because the etc.c.zlib module is already defined in libphobos2.so.
 Try the --exclude=etc option to avoid this.
Thanks, that works. But such behavior of rdmd is quite confusing to the users; speaking for myself, I never had a use case for the --exclude option before. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 29 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11342


Martin Nowak <code dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |
            Summary|shared libs don't play well |rdmd doesn't exclude phobos
                   |with etc.c.zlib             |etc.c modules
           Severity|regression                  |normal



OK I renamed the bug and lowered the priority.
Sadly there is no tools Component in this Bugzilla.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 30 2013