-
-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve -MG #903
Comments
"skipping all conditional blocks entirely" wouldn't allow cases like this:
|
Then how should they be handled? Conditionally evaluating all blocks won't work either for example due to macro arg expansion... (As a side note, I feel like we're fighting an uphill battle regarding this due to not being able to run |
I'm not sure; pret uses a custom The initial report sparking this gave this example:
Without |
That's because |
Dependency listing is one of those things where accurate output is more important than fast output. If a project relies on dependency output in its build system, inaccurate output might cause a file not to be rebuilt, leaving stale code/data in the final binary. Scanning assembly files for inclusion statements is a trivial task if anyone wants to build a faster but simpler tool. (I once wrote a |
Unless you have to deal with rgbds macros and equs. I currently first run rgbasm and then append the resulting dependency file with a
Depends on your definition of "correct". From my perspective, the current behavior is incorrect. I ask a file for it's dependencies, and it does not list all dependencies. I had earlier questions about
That sounds like a really bad plan. |
The counter-argument is "we don't use those, so our tool doesn't account for them". This is valid, as "this specific codebase doesn't use these features" lets you optimize for their lack. However, they introduce additional dependencies (typically Python or a C compiler), so removing their need would be useful.
You are correct, but this is by necessity. C dependency generation is performed by the preprocessor, which only cares about its own syntax: % cat c.c
#include "a.h"
rofl 1 { "ah yes" }?$;:
% gcc -MM -MG -MP c.c
c.o: c.c a.h
a.h: And in addition, the preproc's syntax is not context-sensitive; that is, a C file can be correctly parsed (by the preproc) even when some of the files to be included are missing. (I believe RGBASM is not so lucky due to % cat a.asm
INCLUDE "{INC}"
PRINTLN 16 tiles
% cat b.inc
tiles EQUS "* 16"
% cat c.inc
% rgbasm -DINC=b.inc a.asm
$100
% rgbasm -DINC=c.inc a.asm
ERROR: a.asm(2)
syntax error, unexpected identifier
error: Assembly aborted (1 error)! The rest of the syntax can largely be handled: treat "required" yet non-existent variables as 0, ignore macros, etc. But the lack of an Even then, since macros can generate
Since it appears that ignoring all All in all, the lack of robustness in RGBASM programs is why the current behavior is what it is: after a failed This could be improved while staying relatively simple and safe: only abort on the first conditional block or fatal error after a missing dep, which would at least account for a chain of |
A fully accurate mode could be introduced by adding a flag that simply assembles the input into I'm not sure of whether this would be worth it, though. |
I've just explained that it is not possible to assemble the input without the dependencies in the general case. To do so in one go, RGBASM would need to be able to invoke the command responsible for generating the file, and proceed once the file has been generated. (This would flip the paradigm from RGBASM telling |
I disagree, as without |
Parsing continues after a failed |
Sorry, could you be more specific to which changes you are referring? (there is a lot of info in this thread, and my brain is a bit slow today, so most likely my fault for not seeing the exact changes you are referring to) |
and
|
Ah, that first suggestion on aborting on a fatal error after a missing deb most likely solve most common cases. You could still craft very specific examples where this gives the "wrong" result.
(Invoking |
This kind of "wrong result" is why I'm suggesting aborting on the first conditional following a missing dep as well.
The reason why I brought it up again is because I have seen a tool do this at my job. |
This sounds too vulnerable to false positives. For example:
I think it should be the user's responsibility to not write
and then be sure to pass (Or, add a built-in Regardless of how/whether we change |
I agree it's very vulnerable, but it's a conservative and easy to implement option. It may be worth implementing that behavior, and observing the results; given its relative simplicity, it should be easy to revert to switch to something more complex. |
Maybe so, although I'd like to avoid releasing it in one version and switching to something else in the next. Also regarding Edit: I think this snippet from polishedcrystal would already fail with that behavior: (it uses
|
Why? The behavior is pretty much unspecified, and the feature sees little enough use that I think we can get away with some mild behavioral changes for now.
Only because
Well, it would only batch the first few the first time, but on the second run, after all deps before the |
I'm used to pret's way of doing things, so maybe this is wrong; but I would expect most Would it make sense as a new flag?
|
I really don't think it's an issue not to print everything at once, but batching should be done whenever possible to improve performance. I'd really like to avoid an extra flag, because that's a strong commit to backwards compat; as a last-ditch kludge, I can suggest computing the expressions to This covers most conditionals suggested by the above, and allows detecting whether a file has been generated via |
That kludge sounds fragile in the same ways as my no-lazy-expressions implementation of short-circuiting |
Worth trying, though I'd wait until #849 is done to have some testing. |
-MG
only reports new dependencies one by one, it would be much better to do so in batches: generating more dependencies per step reduces the amount of RGBASM invocations, which is better.Some testing with GCC shows that it reports all missing deps, and treats all missing files as empty. (
#if
,#ifdef
etc. are evaluated normally.)This could in theory cause some problems:
...to which I suggest aborting normally on any fatal error. This would be similar to the current behavior, but probably less common. Note however that GCC honors
#error
, still producing the deps, but returning 1 (so the firstmake
errors out, but further ones work correctly). Maybe this could be better handled by skipping all conditional blocks entirely, still producing fatal errors encountered along the way?... Overall, this sounds incredibly fragile, and I'm really not confident in this change, but it's largely a necessity if we want
The text was updated successfully, but these errors were encountered: