www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8856] New: import inside function sometimes causes link errors

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

           Summary: import inside function sometimes causes link errors
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: thelastmammoth gmail.com


--- Comment #0 from thelastmammoth gmail.com 2012-10-19 18:18:13 PDT ---
I sometimes get link errors eg:

void fun(){
    import mypackage.mymodule;
    mypackage.mymodule.myfun(); //might cause link error, depending on contents
of myfun
}

(cf http://forum.dlang.org/thread/xdonaxnahmonhyafhmvd forum.dlang.org)

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


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-10-19
18:44:09 PDT ---
We'll need a failing test-case. What contents cause the linker error?

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



--- Comment #2 from thelastmammoth gmail.com 2012-10-19 20:18:49 PDT ---
(In reply to comment #1)
 We'll need a failing test-case. What contents cause the linker error?

here's a failure case which I simplified to the maximum. Note that link error occurs with rdmd, not with dmd, as shown below. So that is a problem with rdmd failing to find dependencies in some cases. ---- rdmd ${DFLAGS} main =>Undefined symbols for architecture x86_64: "_D9main_aux24fun1FZv", referenced from: _D8main_aux4testFZv in main.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status ---- dmd ${DFLAGS} main main_aux main_aux2 => works ---- Here are the files: . ├── main.d ├── main_aux.d └── main_aux2.d cat main.d import main_aux; void main(){ test; } cat main_aux.d module main_aux; //putting the main function here removes link error //void main(){ // test; //} //import main_aux2; //uncomment removes link error void test(){ import main_aux2; fun1(); } cat main_aux2.d module main_aux2; void fun1() { } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8856



--- Comment #3 from thelastmammoth gmail.com 2012-10-19 20:20:57 PDT ---
In the above post, DFLAGS is just the usual import path to dmdroot/phobos,
druntime/import and phobos library path.

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



--- Comment #4 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-10-19
20:34:14 PDT ---
(In reply to comment #2)
 snip

The problem is DMD's -v option doesn't output dependencies when an import is function local. test.d: module test; import foo; void main() { } foo.d: module foo; import bar; bar.d is empty $ dmd -c -v test.d
 import    foo   (foo.d)
 import    bar   (bar.d)

Now use a local import in foo.d: foo.d: module foo; void loc() { import bar; } $ dmd -c -v test.d
 import    foo   (foo.d)

DMD doesn't output the import to bar.d when using -v. That has to be fixed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 19 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8856


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE


--- Comment #5 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-01-11
19:15:13 PST ---
Caused by same issue as in Issue 7016.

*** This issue has been marked as a duplicate of issue 7016 ***

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