www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - .obj files conflict

reply Nick Atamas <nick.atamas gmail.com> writes:
I find that .obj files conflict when I use the -od flag to redirect
intermediate output to a directory. Shouldn't obj files get the name of their
package? So, sdl.timer.obj instead of just timer.obj.

e.g.

c:\proj> bud -odbin src/main.d
[proj]
  |--[bin]
  \--[src]
      |--[A]
      |  \--Timer.d
      |
      |--[sdl]
      |   \--timer.d
      |
      \--main.d  #imports and uses both timers


This will cause a linker error because bin/Timer.obj will be overwritten by
bin/timer.obj.

This isn't just a problem on windows. If we had both lower-case names as in
A/timer.d and sdl/timer.d, there would still be a linker error.
Dec 26 2006
parent reply Derek Parnell <derek psych.ward> writes:
On Tue, 26 Dec 2006 16:53:47 +0000 (UTC), Nick Atamas wrote:

 I find that .obj files conflict when I use the -od flag to redirect
 intermediate output to a directory. Shouldn't obj files get the name of their
 package? So, sdl.timer.obj instead of just timer.obj.
 
 e.g.
 
 c:\proj> bud -odbin src/main.d
 [proj]
   |--[bin]
   \--[src]
       |--[A]
       |  \--Timer.d
       |
       |--[sdl]
       |   \--timer.d
       |
       \--main.d  #imports and uses both timers
 
 
 This will cause a linker error because bin/Timer.obj will be overwritten by
 bin/timer.obj.
 
 This isn't just a problem on windows. If we had both lower-case names as in
 A/timer.d and sdl/timer.d, there would still be a linker error.

By the way, this is not a problem caused by using Bud. It is a function of the way that DMD works. For Bud to 'fix' this, it would either have to compile each source file seperately, adjustng the -od switch accordingly, or copy the entire source code structure to the root mentioned in the -od switch, compile all the copied source with the -op switch instead of -od, then delete the source copies. -- Derek
Dec 26 2006
parent reply Sean Kelly <sean f4.ca> writes:
Derek Parnell wrote:
 On Tue, 26 Dec 2006 16:53:47 +0000 (UTC), Nick Atamas wrote:
 
 I find that .obj files conflict when I use the -od flag to redirect
 intermediate output to a directory. Shouldn't obj files get the name of their
 package? So, sdl.timer.obj instead of just timer.obj.

 e.g.

 c:\proj> bud -odbin src/main.d
 [proj]
   |--[bin]
   \--[src]
       |--[A]
       |  \--Timer.d
       |
       |--[sdl]
       |   \--timer.d
       |
       \--main.d  #imports and uses both timers


 This will cause a linker error because bin/Timer.obj will be overwritten by
 bin/timer.obj.

 This isn't just a problem on windows. If we had both lower-case names as in
 A/timer.d and sdl/timer.d, there would still be a linker error.

By the way, this is not a problem caused by using Bud. It is a function of the way that DMD works. For Bud to 'fix' this, it would either have to compile each source file seperately, adjustng the -od switch accordingly, or copy the entire source code structure to the root mentioned in the -od switch, compile all the copied source with the -op switch instead of -od, then delete the source copies.

I think the -od and -op flags can be used together, so the object files would all end up in subdirectories of bin. Then it's simply a matter of recursively linking all object files in that tree. Sean
Dec 26 2006
parent reply Derek Parnell <derek nomail.afraid.org> writes:
On Tue, 26 Dec 2006 14:20:22 -0800, Sean Kelly wrote:

 On Tue, 26 Dec 2006 16:53:47 +0000 (UTC), Nick Atamas wrote:
 
 I find that .obj files conflict when I use the -od flag to redirect
 intermediate output to a directory.



 I think the -od and -op flags can be used together, so the object files 
 would all end up in subdirectories of bin.  Then it's simply a matter of 
 recursively linking all object files in that tree.

Yes, one would think so, but it just doesn't work. Try setting the -od to reference a different drive than the source file? dmd -op -odD:\bin c:\SOURCE\project.d Absolute chaos follows ;-) In short, -od and -op cannot be safely used together (as far as my testing shows so far). -- Derek (skype: derek.j.parnell) Melbourne, Australia "Down with mediocrity!" 27/12/2006 10:22:13 AM
Dec 26 2006
parent Nick Atamas <nick.atamas gmail.com> writes:
== Quote from Derek Parnell (derek nomail.afraid.org)'s article
 On Tue, 26 Dec 2006 14:20:22 -0800, Sean Kelly wrote:
 On Tue, 26 Dec 2006 16:53:47 +0000 (UTC), Nick Atamas wrote:

 I find that .obj files conflict when I use the -od flag to redirect
 intermediate output to a directory.


would all end up in subdirectories of bin. Then it's simply a matter of recursively linking all object files in that tree.

reference a different drive than the source file? dmd -op -odD:\bin c:\SOURCE\project.d Absolute chaos follows ;-) In short, -od and -op cannot be safely used together (as far as my testing shows so far).

I tried -od and -op together beforing posting this bug. Adding -op seemed to do nothing.
Dec 26 2006