Suggestion: Object filenames should be fully-qualified module names
Chris Miller
chris at dprogramming.com
Sat Jan 20 08:29:00 PST 2007
On Sat, 20 Jan 2007 07:17:45 -0500, Kirk McDonald
<kirklin.mcdonald at gmail.com> wrote:
[snip]
> This ambiguity can be disposed of if an object file's name is its
> fully-qualified module name. If this were true, then we could just say
>
> $ dmd test.d testpkg/test.d -odbuild
>
> and the result would be the build directory looking like this:
>
> build
> test.obj
> testpkg.test.obj
>
> I find this very clean and simple. Since the compiler fails anyway if
> two modules have the same name, there should not ever be overlaps in
> object file names with this scheme. The -op option could probably be
> safely deprecated.
Agreed, this is a much better way of handling it.
>
> As someone pointed out in #d, this would fail on NTFS if the module's
> fully-qualified name exceeds 255 characters. Though I cannot recall ever
> using a module whose name even approached that limit, this should be
> solved in most cases by truncating the filename at the start.
> (Hopefully, the last 255 characters are unique.) If the object file
> would fail to be unique even then, it can probably be safely declared
> the coder's fault for using a stupid naming scheme.
>
I don't think it's an actual limitation of NTFS, but rather most programs
use buffers for file paths of MAX_PATH characters (260), and to use more
requires special handling (using some path prefix). I believe the linker
would be one of those programs that can't handle larger paths.
As a compromise, perhaps N characters from both the head and tail of the
fully-qualified module name could be used, such as 75 chars from the
beginning and 75 from the end, and then it still leaves almost half the
range (MAX_PATH chars) available for storing the path that leads up to the
module.
For example:
C:\dmd\src\phobos\std\D\is\a\systems\programming\language\Its\focus\is\on\combining\the\power\and\high\performance\of\C\and\Cpp\with\the\programmer\productivity\of\modern\languages\like\Ruby\and\Python\Special\attention\is\given\to\the\needs\of\quality\assurance\documentation\management\portability\and\reliability.d
Would shrink down to:
std.D.is.a.systems.programming.language.Its.focus.is.on.combining.the.powers.of.quality.assurance.documentation.management.portability.and.reliability.obj
and still have room to store the directory it's saved in (e.g.
C:\dmd\src\phobos on the front).
;)
More information about the Digitalmars-d
mailing list