Subject: Re: Turning off optimization on selected files.
To: Chris Torek <torek@BSDI.COM>
From: None <cgd@netbsd.org>
List: tech-kern
Date: 06/08/2000 15:16:04
torek@BSDI.COM (Chris Torek) writes:
> Oops. Guess I applied this *after* I went to BSDI. :-)
That code came into our tree in '96. 8-)
> Hm, oops#2: this only allows you to override:
This is sort-of the issue, but the fix you propose isn't suffifient
(at least in our sources).
in addfile() we (still) have code that looks like:
if (ht_insert(pathtab, path, oi)) {
free(oi);
if ((oi = ht_lookup(pathtab, path)) == NULL)
panic("addfile: ht_lookup(%s)", path);
error("duplicate file %s", path);
xerror(oi->oi_srcfile, oi->oi_srcline,
"here is the original definition");
}
(we also have it in addobject(), but you can't supply make rules for
objects. 8-)
I agree that the functionality is desirable. I've implemented the
change below, which i'll commit later today unless anyone objects.
a better error message for 'duplicate file' to distinguish the cases
where you've just got a simple dup, and you've got a dup with extra
options spec'd seems appropriate, but i dunno what wording should be.
("duplicate file" vs. "conflicting duplicate file" ? "duplicate file"
vs "illegal duplicate file"?
during testing, i also noticed that fi_srcline is incorrectly updated
to reflect the duplicate definition. the 'goto bad;' fixes that (and
frees optx, which wasn't being done before, though i believe it should
have been).
comments?
cgd
===================================================================
Index: src/files.c
===================================================================
RCS file: /cvsroot/systemsw/tools/src/netbsd-config/src/files.c,v
retrieving revision 1.2
diff -c -r1.2 files.c
*** files.c 2000/05/04 05:54:44 1.2
--- files.c 2000/06/08 22:10:59
***************
*** 133,141 ****
--- 133,152 ----
free(fi);
if ((fi = ht_lookup(pathtab, path)) == NULL)
panic("addfile: ht_lookup(%s)", path);
+
+ /*
+ * if it's a duplicate entry, it is must specify a make
+ * rule, and only a make rule. If it does otherwise,
+ * it is disallowed.
+ */
+ if (rule != NULL && optx == NULL && flags == 0) {
+ fi->fi_mkrule = rule;
+ return;
+ }
error("duplicate file %s", path);
xerror(fi->fi_srcfile, fi->fi_srcline,
"here is the original definition");
+ goto bad;
}
memcpy(base, tail, baselen);
base[baselen] = 0;