Bug 10386 – Package import feature breaks with static libraries

Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-16T17:06:00Z
Last change time
2013-06-20T04:05:36Z
Keywords
link-failure, pull
Assigned to
nobody
Creator
andrej.mitrovich

Attachments

IDFilenameSummaryContent-TypeSize
1227package_test.ziptestcaseapplication/zip1103

Comments

Comment #0 by andrej.mitrovich — 2013-06-16T17:06:36Z
Created attachment 1227 testcase See the attached test-case and run build.bat to reproduce. Note that using a regular module import in the client code works, but using the package import triggers linker errors.
Comment #1 by andrej.mitrovich — 2013-06-16T17:06:58Z
The linker error: > Error 42: Symbol Undefined _D3foo3bar3fooFiZv
Comment #2 by andrej.mitrovich — 2013-06-16T17:07:41Z
Using latest git-head version of DMD. I've only verified this on Windows, but the test-case is simple enough for people to test it on Posix.
Comment #3 by bugzilla — 2013-06-17T17:51:38Z
For tiny files like that, it's a lot more user-friendly to just put the text of them in a comment. Otherwise, only a small fraction of people will look at it.
Comment #4 by andrej.mitrovich — 2013-06-17T17:55:39Z
(In reply to comment #3) > For tiny files like that, it's a lot more user-friendly to just put the text of > them in a comment. Otherwise, only a small fraction of people will look at it. The reason I zipped it is because it has a directory structure, which is always painful to recreate manually. Here's the zip contents anyway: ./test.d: ----- module test; // import lib.foo.bar; // ok import lib.foo; // linker failure void main() { foo(1); } ----- ./lib/foo/bar.d ----- module lib.foo.bar; void foo(int x) { assert(x == 1); } ----- ./lib/foo/package.d ----- module lib.foo; public import lib.foo.bar; ----- On Windows compile with: $ dmd -lib lib\foo\bar.d lib\foo\package.d -offoo.lib $ dmd test.d foo.lib On Posix it's probably: $ dmd -lib lib/foo/bar.d lib/foo/package.d -oflibfoo.a $ dmd test.d -L-lfoo
Comment #5 by code — 2013-06-18T01:10:19Z
(In reply to comment #1) > The linker error: > > > Error 42: Symbol Undefined _D3foo3bar3fooFiZv Looks like the mangling is wrong. It should be _D3lib3foo3bar3fooFiZv right?
Comment #6 by andrej.mitrovich — 2013-06-18T06:23:12Z
(In reply to comment #5) > (In reply to comment #1) > > The linker error: > > > > > Error 42: Symbol Undefined _D3foo3bar3fooFiZv > > Looks like the mangling is wrong. It should be _D3lib3foo3bar3fooFiZv right? Yeah I think so.
Comment #7 by k.hara.pg — 2013-06-19T22:10:07Z
Comment #8 by github-bugzilla — 2013-06-20T04:03:30Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/4ddfbcb9aee814cddc82939ecd37928059f3e670 fix Issue 10386 - Package import feature breaks with static libraries