Thread overview
[Issue 11342] New: shared libs don't play well with etc.c.zlib
Oct 24, 2013
Artem Tarasov
Oct 24, 2013
Artem Tarasov
Oct 27, 2013
Artem Tarasov
Oct 28, 2013
Walter Bright
Oct 28, 2013
Artem Tarasov
Oct 30, 2013
Martin Nowak
Oct 30, 2013
Martin Nowak
Oct 30, 2013
Artem Tarasov
[Issue 11342] rdmd doesn't exclude phobos etc.c modules
Oct 30, 2013
Martin Nowak
October 24, 2013
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


--- Comment #0 from Artem Tarasov <lomereiter@gmail.com> 2013-10-24 12:16:18 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: -------
October 24, 2013
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: -------
October 27, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11342


Artem Tarasov <lomereiter@gmail.com> changed:

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


--- Comment #1 from Artem Tarasov <lomereiter@gmail.com> 2013-10-27 14:56:26 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: -------
October 28, 2013
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


--- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2013-10-27 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: -------
October 28, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11342


Artem Tarasov <lomereiter@gmail.com> changed:

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


--- Comment #3 from Artem Tarasov <lomereiter@gmail.com> 2013-10-28 01:19:20 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(lifetime_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: -------
October 30, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11342


Martin Nowak <code@dawg.eu> changed:

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


--- Comment #4 from Martin Nowak <code@dawg.eu> 2013-10-29 20:30:37 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.

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



--- Comment #5 from Martin Nowak <code@dawg.eu> 2013-10-29 20:32:23 PDT ---
(In reply to comment #4)
> 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: -------
October 30, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11342



--- Comment #6 from Artem Tarasov <lomereiter@gmail.com> 2013-10-29 23:47:13 PDT ---
(In reply to comment #4)
> 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: -------
October 30, 2013
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


--- Comment #7 from Martin Nowak <code@dawg.eu> 2013-10-30 13:41:42 PDT ---
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: -------