Thread overview
[Issue 6822] New: New ubuntu linking rules prevent dmd from linking programs on Ubuntu 11.10
Oct 19, 2011
Brad Roberts
Oct 19, 2011
Walter Bright
October 17, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6822

           Summary: New ubuntu linking rules prevent dmd from linking
                    programs on Ubuntu 11.10
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Keywords: link-failure
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: schveiguy@yahoo.com


--- Comment #0 from Steven Schveighoffer <schveiguy@yahoo.com> 2011-10-17 05:42:28 PDT ---
I recently upgraded to Ubuntu 11.10, and dmd complains during link that functions defined in -lrt are missing.

using dmd -v, I get:

gcc testbool.o -o testbool -m32 -Xlinker -L/home/steves/dmd-2.054/linux/bin32/../lib32 -Xlinker -L/home/steves/dmd-2.054/linux/bin32/../lib64 -Xlinker --no-warn-search-mismatch -Xlinker --export-dynamic -lrt -lphobos2 -lpthread -lm

Note that -lrt comes before -lphobos2, where the functions are needed.

I'm not sure how the compiler worked on ubuntu 11.04 (the previous release), but apparently there are stricter rules.

I don't know how to fix this, you want to be able to link libs before and after phobos is specified on the command line, so we may need to either explicitly name phobos2 in the dmd.conf, or have two sets of DFLAGS.

However, as of now, I cannot link anything without using -v and manually running the link step, adding -lrt to the end.

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


Brad Roberts <braddr@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |braddr@puremagic.com


--- Comment #1 from Brad Roberts <braddr@puremagic.com> 2011-10-19 09:16:00 PDT ---
The right answer for this one probably is moving the -lrt part out of dmd.conf and into core/time.d as pragma(lib, "rt"), conditional on linux.  I haven't tried it though.

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



--- Comment #2 from Steven Schveighoffer <schveiguy@yahoo.com> 2011-10-19 09:31:13 PDT ---
That doesn't work.  pragma(lib) only works if you are compiling all files at
the same time.

This fails to compile:

void main() {}

I didn't import std.datetime at all, so the compiler would never know that it had to link -lrt.

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



--- Comment #3 from Steven Schveighoffer <schveiguy@yahoo.com> 2011-10-19 09:31:54 PDT ---
(In reply to comment #2)
> I didn't import std.datetime at all

or rather core.time...

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


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2011-10-19 11:37:15 PDT ---
https://github.com/D-Programming-Language/dmd/commit/1ff6ad8509cbfa73ae5519fa40898c5b005ab6ca

You'll still need to remove -lrt from your dmd.conf

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



--- Comment #5 from Steven Schveighoffer <schveiguy@yahoo.com> 2011-10-19 11:47:11 PDT ---
works, thanks.  Note that it still works even if you leave -L-rt in dmd.conf, even though it's not necessary to have it there.

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