.di header imports with DLL symbols fails to link

2011-03-12 Thread Andrej Mitrovic
On Windows, x86.

http://dl.dropbox.com/u/9218759/DLL_Imports.zip

fail_build.bat runs:
dmd driver.d mydll.lib -I%cd%\include\
but linking fails:
driver.obj(driver)
 Error 42: Symbol Undefined _D5mydll12__ModuleInfoZ
--- errorlevel 1

work_build.bat runs:
dmd driver.d mydll.lib %cd%\include\mydll.di
and this succeeds.

So passing the .di file explicitly works, but via the import switch it does not.

Here's a non-DLL example which works fine when using header files and an import 
switch:
http://dl.dropbox.com/u/9218759/importsWorkUsually.zip

So unless I'm missing something this looks like a linker bug?


Re: .di header imports with DLL symbols fails to link

2011-03-12 Thread Bekenn

On 3/12/2011 5:24 PM, Andrej Mitrovic wrote:

driver.obj(driver)
  Error 42: Symbol Undefined _D5mydll12__ModuleInfoZ
--- errorlevel 1


Your dll is exporting a different symbol: _D5mydll3fooFiZi
Do you have the .def file and the command line used to build the DLL?


Re: .di header imports with DLL symbols fails to link

2011-03-12 Thread Daniel Green

On 3/12/2011 9:15 PM, Bekenn wrote:

On 3/12/2011 5:24 PM, Andrej Mitrovic wrote:

driver.obj(driver)
Error 42: Symbol Undefined _D5mydll12__ModuleInfoZ
--- errorlevel 1


Your dll is exporting a different symbol: _D5mydll3fooFiZi
Do you have the .def file and the command line used to build the DLL?
I believe _D5mydll12__ModuleInfoZ is supposed to be exported by the 
compiler.


It contains static constructor and unittest information used by the 
runtime to initialize it.


Re: .di header imports with DLL symbols fails to link

2011-03-12 Thread Andrej Mitrovic
Actually passing that .di file compiles it in statically, and the exe
ends up not needing the DLL.

It's a bit too late for me to thinker with the linker, I'll have a
clearer head tomorrow.


Re: .di header imports with DLL symbols fails to link

2011-03-12 Thread Andrej Mitrovic
My commands to compile were:
dmd -ofmydll.dll mydll.d
dmd -o- -Hdinclude mydll.d
dmd driver.d mydll.lib -I%cd%\include


Re: .di header imports with DLL symbols fails to link

2011-03-12 Thread Bekenn

On 3/12/2011 7:02 PM, Andrej Mitrovic wrote:

My commands to compile were:
dmd -ofmydll.dll mydll.d
dmd -o- -Hdinclude mydll.d
dmd driver.d mydll.lib -I%cd%\include


Thanks.

I've tried several things, but can't get the _D5mydll12__ModuleInfoZ 
symbol to show up at all.  The behavior is the same with and without a 
.def file (I tried a few versions).  I even went back to 
http://www.digitalmars.com/d/2.0/dll.html and copied everything
in the D code calling D code in DLLs section verbatim.  After fixing a 
few compilation errors (the web page's version of concat needs its 
arguments qualified with in), I ended up with the exact same problem 
you're experiencing.


I'd definitely call this a bug.


Re: .di header imports with DLL symbols fails to link

2011-03-12 Thread Daniel Green

On 3/12/2011 11:39 PM, Bekenn wrote:

On 3/12/2011 7:02 PM, Andrej Mitrovic wrote:

My commands to compile were:
dmd -ofmydll.dll mydll.d
dmd -o- -Hdinclude mydll.d
dmd driver.d mydll.lib -I%cd%\include


Thanks.

I've tried several things, but can't get the _D5mydll12__ModuleInfoZ
symbol to show up at all. The behavior is the same with and without a
.def file (I tried a few versions). I even went back to
http://www.digitalmars.com/d/2.0/dll.html and copied everything
in the D code calling D code in DLLs section verbatim. After fixing a
few compilation errors (the web page's version of concat needs its
arguments qualified with in), I ended up with the exact same problem
you're experiencing.

I'd definitely call this a bug.


Probably unrelated, but this same issue showed up in the GDC backend. 
Apparently, the compiler tried to be smart about exporting ModuleInfo 
only for those modules that needed it.  The fix was to always export it 
regardless.