August 11, 2011
On Thursday, August 11, 2011 06:58 simendsjo wrote:
> On 11.08.2011 14:56, Vladimir Panteleev wrote:
> > On Thu, 11 Aug 2011 14:59:03 +0300, Vladimir Panteleev
> > 
> > <vladimir@thecybershadow.net> wrote:
> >> I don't see what the problem is. Is your program buggy? Don't use -release. Are you done fixing bugs? Use -release to remove pointless clutter. Is the program segfaulting on a user's PC? Send him a debug build!
> > 
> > By the way, I'd like to add some thoughts on how wrong I think it is to rely on a single debugging feature like this in release builds. Asserts (both conditional and unconditional), contracts, invariants and native language features such as array bounds checking all work together to find bugs as soon as possible. If you get an error message on an assert(0) and you attempt to debug it from that, you may be led on a wild goose chase, because the program might have actually failed much earlier and ran for a while in an undetermined state, corrupting memory left and right or spreading internal state inconsistencies uncaught by invariants. I know about this all too well from my experience of debugging memory corruption - the garbage collector is compiled with no invariants as its performance is critical, but recompiling my program with a version of Phobos with contracts enabled would have saved me tracing a few steps to find the source of corruption.
> 
> Which reminds me.. Why isn't a phobos shipped with a precompiled version containing contracts?

Because that would be inefficient. As it stands, there's no way to tell the compiler, "use this library in release mode but use this library in debug mode." So, you're stuck with one or the other, and going with the debug version of Phobos would negatively impact all D programs as far as efficiency goes. We _could_ have the debug version in a separate folder with instructions somewhere telling you to adjust your build scripts so that you use one for debug and one for release, but that does complicate things. It also increases the size of the zip file, and I don't think that it makes sense at all with an installer or Linux package.

Now, the _templated_ code in Phobos will use contracts just fine (as long you're not compiling your project in release mode), since that's compiled when the programmer uses it rather than compiled into the library itself. So, most of the cases where you actually need contracts based on what the programmer using Phobos is doing (as opposed to Phobos itself) should still work.

To actually, reasonably distribute Phobos in a debug and release state would probably necessitate setting it up so that dmd was smart enough to use one set of libraries in release mode and another in debug mode.

- Jonathan M Davis
August 11, 2011
On Thu, 11 Aug 2011 20:44:15 +0300, Jonathan M Davis <jmdavisProg@gmx.com> wrote:

> As it stands, there's no way to tell the compiler, "use this library in release mode but use this library in debug mode."

Would it be possible to use something like pragma(lib) or pragma(link) to specify the Phobos version to link against?

-- 
Best regards,
 Vladimir                            mailto:vladimir@thecybershadow.net
August 11, 2011
"Jonathan M Davis" <jmdavisProg@gmx.com> wrote:
[snip]
> Because that would be inefficient. As it stands, there's no way to
> tell the
> compiler, "use this library in release mode but use this library in
> debug
> mode."

Can't you use -defaultlib and -debuglib?
August 11, 2011
Timon Gehr:

> Maybe a better solution would be to have @noreturn functions in the language. (or, prettier, a type of which no values exist).

Yeah. Recently Walter has added something like that inside the DMD source code. GNU C uses (noreturn).

Bye,
bearophile
August 11, 2011
On Thursday, August 11, 2011 11:00 kennytm wrote:
> "Jonathan M Davis" <jmdavisProg@gmx.com> wrote:
> [snip]
> 
> > Because that would be inefficient. As it stands, there's no way to
> > tell the
> > compiler, "use this library in release mode but use this library in
> > debug
> > mode."
> 
> Can't you use -defaultlib and -debuglib?

So, you could. I didn't know that they existed. I wonder if they were added after previous discussions about this issue, since in previous discussions, those flags never came up, and I've never noticed them before. Just the same, I'm not sure if we actually want to distribute a non-release version of libphobos though. I expect that it would significantly increase the size of the zip file as well as create some level of confusion, and without a standard place to put debug versions of a library, I don't see how it would work with the distro packages. All someone has to do is compile druntime and Phobos to get it themselves, and all of the source is right there. However, they _would_ have to compile the source, which while relatively easy is not something which is immediately obvious how to do. So, I don't know.

Maybe they could be released as libphobos_debug.a and go in the same place as libphobos.a (along with whatever the equivalents would be on Windows). I'm not quite sure how this is dealt with in C/C++ land though. IIUC, the closest that you get to a debug build on Linux without building a library yourself is installing the version of a library which includes debug symbols (but it's still compiled in release mode aside from that I believe). I don't know what the situation is on Windows.

So, I don't know. On the whole, I don't consider it to be a big deal, but I could see why someone would want it. But I really don't know the best way to handle the situation.

- Jonathan M Davis
August 11, 2011
Vladimir Panteleev:

> Would it be possible to use something like pragma(lib) or pragma(link) to specify the Phobos version to link against?

Andrei likes general solutions. What you write suggests me that maybe there is a solution to a more general problem. Instead of modifying DMD to support just two pre-compiled Phobos, maybe it is possible to add D/DMD a more general feature to support the two debug/release pairs even with user-defined libraries.

Bye,
bearophile
August 11, 2011
On Aug 11, 2011, at 10:44 AM, Jonathan M Davis wrote:

> On Thursday, August 11, 2011 06:58 simendsjo wrote:
>> On 11.08.2011 14:56, Vladimir Panteleev wrote:
>> 
>> Which reminds me.. Why isn't a phobos shipped with a precompiled version containing contracts?
> 
> Because that would be inefficient. As it stands, there's no way to tell the compiler, "use this library in release mode but use this library in debug mode."

Yes there is: -debuglib.

I have a few issues with this as DMD currently works, though.  First, whether to use checked vs. unchecked code has nothing to do with whether it's "release" or "non-release".  The current switch name really has to be changed to -unchecked so people aren't tricked into thinking that shipping checked code is a bad thing.  Once this is done, the DMD switches -defaultlib and -debuglib could be changed to -defaultlib and -uncheckedlib.  Whether or not the user supplies the -debug switch should mean nothing insofar as which external library is used.  More important is that checking be used throughout or not at all.  Once this is sorted, I'd gladly build and ship multiple versions of druntime for these configs.
August 11, 2011
On Aug 11, 2011, at 11:22 AM, Jonathan M Davis wrote:

> On Thursday, August 11, 2011 11:00 kennytm wrote:
>> "Jonathan M Davis" <jmdavisProg@gmx.com> wrote:
>> [snip]
>> 
>>> Because that would be inefficient. As it stands, there's no way to
>>> tell the
>>> compiler, "use this library in release mode but use this library in
>>> debug
>>> mode."
>> 
>> Can't you use -defaultlib and -debuglib?
> 
> So, you could. I didn't know that they existed. I wonder if they were added after previous discussions about this issue, since in previous discussions, those flags never came up, and I've never noticed them before.

They were added to support the use of third-party standard libs after being requested by the Tango folks (me, actually) years ago.
August 11, 2011
On Thursday, August 11, 2011 12:44:02 Sean Kelly wrote:
> On Aug 11, 2011, at 11:22 AM, Jonathan M Davis wrote:
> > On Thursday, August 11, 2011 11:00 kennytm wrote:
> >> "Jonathan M Davis" <jmdavisProg@gmx.com> wrote:
> >> [snip]
> >> 
> >>> Because that would be inefficient. As it stands, there's no way to
> >>> tell the
> >>> compiler, "use this library in release mode but use this library in
> >>> debug
> >>> mode."
> >> 
> >> Can't you use -defaultlib and -debuglib?
> > 
> > So, you could. I didn't know that they existed. I wonder if they were added after previous discussions about this issue, since in previous discussions, those flags never came up, and I've never noticed them before.
> 
> They were added to support the use of third-party standard libs after being requested by the Tango folks (me, actually) years ago.

Well, obviously no one discussing this issue in the past has paid enough attention to dmd's flags, since no one has ever brought it up. Obviously, I need to pay more attention.

- Jonathan M Davis
August 11, 2011
Sean Kelly:

> The current switch name really has to be changed to

Lately Walter seems to appreciate pull requests a lot. So is someone willing to write such patch (it doesn't look too much complex to do)?

Bye,
bearophile
1 2
Next ›   Last »