comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: The Dreaded "Missing Subunits"
Date: Thu, 19 Sep 2002 00:00:07 GMT
Date: 2002-09-19T00:00:07+00:00	[thread overview]
Message-ID: <wccfzw6n914.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: uelbqc442.fsf@gsfc.nasa.gov

Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov> writes:

> Robert A Duff <bobduff@shell01.TheWorld.com> writes:
> 
> > Anyway, this all seems rather convoluted.  Why can't the
> > compiler/builder automatically determine which compilation units are in
> > which files?  Why is a separate tool needed?  And a separate file of
> > pragmas Source_File_Name to maintain?
> 
> In order for the compiler to determine which compilation units are in
> which files, it has to read all the files in the compilation
> environment, build the list of file -> unit name mappings, and then
> compile them. gnatname + gnatmake does this (caveat; I don't use
> gnatname). 

No, it does not have to do all that every time you rebuild.

I am writing a tool that analyzes Ada programs.  It's not a compiler,
but it has the same issues with respect to this discussion (how to find
package Mumble when somebody says "with Mumble;").  I didn't want to
build in the conventions of any particular Ada compiler.  The solution I
chose is that the user specifies a wildcard specification of which files
constitute the "universe" (or the "program library").  So you might say
"*.ada" or "*.ads and *.adb".  Or you might mention several directories.
You can tell the tool whatever conventions you use (presumably whatever
your Ada compiler wants you to use).  This is in some sort of config
file.

Every time you tell the tool to re-analyze the world, it has to do this:
(1) Expand the wildcard(s), to see if there are any new files or any
files have been deleted.  Then (2) check the timestamp on each source
file to see if it has been changed.  Then it has to re-parse all the
files that have changed, or are new (and it has to forget about
information related to deleted files).  This process is quite fast, even
for large programs.  It's essentially what 'make' does when you say
'make main_program', or what 'gnatmake' does when told to build a
program.

(Actually, it also has to notice when the config file itself is
changed.)

The point is: it doesn't have to reparse *all* the source code -- just
what has changed since last time, and it can detect those files quickly.
(Of course, the *first* time you run it, it has to parse *all* the
source code.)  An Ada compiler could do likewise, but none do.

> You said this would be "too slow"; which requirement do you really
> want? speed or naming convenience?

I want both.  ;-)

I outlined above how to achieve it.

> It's faster if you cache the results of the name scan; gnatname does
> this. But as you say, the make system has to be able to determine when
> to rerun gnatname, or do it incrementally.
> 
> One of the requirements of the GNAT design is the source-based
> "library"; there are no data structures required to run the compiler,
> other than the source files. Running gnatname automatically starts to
> violate this principle.

The tool I mentioned above is entirely source based.

> ObjectAda takes a different approach; you have to manually tell it
> what files are in the compilation environment (at least, last time I
> used it; one reason I gave it up :). No possibility to automatically
> rescan for new files.

I think ObjectAda allows you to use the "adareg" command to "register"
new Ada source files.  It's similar to the gnatname idea.

> > Furthermore, none of this mumbo-jumbo would be necessary at all, if
> > only all Ada compilers agreed on the file naming convention. 
> 
> Doesn't seem likely, especially now.

True.  I'm just griping -- not expecting any improvement.  ;-)

> > (I must admit, that wasn't easy in the days when operating systems
> > had unreasonable limits on file names (like only one dot, or only 8
> > characters). Are those bad-old-days over?)
> 
> I hope they are over. But we are stuck with their legacy; all of the
> GNAT compiler source files are krunched to 8.3 names.

Yeah, I find that annoying.

> > I also admit that C has it easy in this regard, since it has no
> > proper notion of "module" separate from source file.
> 
> That is part of the problem.
> 
> -- 
> -- Stephe

- Bob



  reply	other threads:[~2002-09-19  0:00 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-12 22:49 The Dreaded "Missing Subunits" Peter Richtmyer
2002-09-13  8:16 ` Peter Amey
2002-09-13  8:51   ` Ada2005 temp solo child (was: " Peter Hermann
2002-09-14  2:33     ` Robert A Duff
2002-09-13  9:24   ` Emmanuel Briot
2002-09-13 20:46     ` Simon Wright
2002-09-14  0:25     ` Chad R. Meiners
2002-09-14  2:53     ` Robert A Duff
2002-09-14 20:20       ` Simon Wright
2002-09-16 13:48         ` Ted Dennison
2002-09-16 16:33           ` Keith Thompson
2002-09-17  2:42             ` Ted Dennison
2002-09-18 20:56           ` Robert A Duff
2002-09-19  8:26             ` Emmanuel Briot
2002-09-19  9:55             ` Preben Randhol
2002-09-19 10:53             ` Marc A. Criley
2002-09-19 11:26             ` Marin David Condic
2002-09-19 21:49             ` Dmitry A.Kazakov
2002-09-19  9:47               ` Preben Randhol
2002-09-20  2:42                 ` Dmitry A.Kazakov
2002-09-19 15:33                   ` Stephen Leake
2002-09-19 15:36                   ` Preben Randhol
2002-09-20 22:31                     ` Dmitry A.Kazakov
2002-09-16 15:10       ` Emmanuel Briot
2002-09-18 21:17         ` Robert A Duff
2002-09-18 22:41           ` Stephen Leake
2002-09-19  0:00             ` Robert A Duff [this message]
2002-09-19  1:39               ` Keith Thompson
2002-09-19 15:19                 ` Stephen Leake
2002-09-19  4:02               ` Larry Kilgallen
2002-09-19 15:24               ` Stephen Leake
2002-09-19 20:34               ` Randy Brukardt
2002-09-19 14:44           ` Peter Richtmyer
2002-09-19 20:25           ` Randy Brukardt
2002-09-13 17:15 ` Mark Johnson
2002-09-13 20:56 ` Stephen Leake
2002-09-13 20:58 ` Simon Wright
2002-09-16 17:28   ` Peter Richtmyer
2002-09-19 20:05     ` Brian Gaffney
  -- strict thread matches above, loose matches on Subject: below --
2002-09-19  1:41 Alexandre E. Kopilovitch
2002-09-19 14:25 ` Peter Hermann
2002-09-19 11:37 Grein, Christoph
2002-09-20  6:03 Grein, Christoph
2002-09-20  7:30 ` Preben Randhol
2002-09-20 14:01   ` Robert A Duff
2002-09-20  9:05 Grein, Christoph
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox