-
Notifications
You must be signed in to change notification settings - Fork 753
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
Warn when running a pass not compatible with DWARF #3506
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Maybe addIfDWARFPreserved
instead of addIfDWARFAllowed
?
@@ -14,3 +15,14 @@ def test_no_crash(self): | |||
args = [os.path.join(path, name)] + \ | |||
['-g', '--dwarfdump', '--roundtrip', '--dwarfdump'] | |||
shared.run_process(shared.WASM_OPT + args, capture_output=True) | |||
|
|||
def test_dwarf_incompatibility(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could make a really simple lit test:
;; RUN: wasm-opt -g <path to cubescript.wasm> --flatten 2>&1 | filecheck %s --check-prefix WARN
;; RUN: wasm-opt -g <path to cubescript.wasm> --metrics 2>&1 | filecheck %s --check-prefix OK
;; WARN: not fully compatible with DWARF
;; OK-NOT: not fully compatible with DWARF
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, happy to try to join the lit bandwagon...
Do we have instructions anywhere for how to set things up locally? ./check.py lit
gives me errors,
parse-error.wast.script: line 1: filecheck: command not found
I have done pip install filecheck
(that worked for lit
in the past iirc) but that appears to not be enough. Do I need a build of LLVM or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pip3 install -r dev-requirements.txt
should get you up and running. Thanks to @sbc100 for suggesting that we use such a file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(looks like it's requirements-dev.txt
?)
Ok, I ran pip3 install -r requirements-dev.txt
and it succeeded, but I still get filecheck: command not found
.
I am not very familiar with pip
. It did not install anything called *filecheck*
under my current dir. Does it install to a global location?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pip install (when run without --system) install things into a user-local PATH. On linux (at least on my machine) this is $HOME/.local/bin
. I think the expectation is that this would be in your PATH, or that you would add it to your path. I'm having trouble finding docs on best practices around how to ensure its added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Indeed that location is not in my path. Adding it fixes things...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, looks like I need to add it as a .wast
file, even though it's not a wast. Now it passes.
However, I am a little unsure this is better. It has
;; WARN: not fully compatible with DWARF
;; OK-NOT: not fully compatible with DWARF
The first line is robust in that a typo will make the test fail. The second line is brittle, however. In the python version a single string is used to avoid that risk, but it must be duplicated in the lit...?
If that's true then I think I'd prefer to keep it as python. But I don't feel strongly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the line has to be duplicated in the lit test, but on the whole I still prefer the lit test over the Python test due to the relative verbosity of the latter. If you want to use a different file extension, you can add it to the lit config here: https://github.com/WebAssembly/binaryen/blob/main/test/lit/lit.cfg.py#L6.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I don't feel strongly so let's make it lit. Pushed now, PTAL.
Hmm, but it's "if DWARF must be preserved, or the pass doesn't mess with DWARF"... maybe |
The tricky thing about the name is that you're not really selecting on a property of the pass itself, but rather a property of the current configuration combined with the pass. That's all kind of pedantic, though, so whatever sounds best to you is fine with me :) |
auto pass = PassRegistry::get()->createPass(passName); | ||
if (!pass->invalidatesDWARF() || | ||
!Debug::shouldPreserveDWARF(options, *wasm)) { | ||
doAdd(std::move(pass)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the pass does not support DWARF, In which case we don't add the pass and in which case we just warn? doAdd
seems to just warn, but this function, which calls doAdd
, seems not call doAdd
in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doAdd
always adds. It may warn as needed.
This method addIfDWARFAllowed
should be something like addPassIfNoDWARFWarningWouldBeShown
. That is, this method is called when the addition is optional, and in that case it's best to not add the pass if there are issues.
I renamed to |
I had to revert the lit test and return to the old one. For some reason with lit it fails like this: https://github.com/WebAssembly/binaryen/runs/1764105570 - it just stops, without a clear error. It does not reproduce locally. I spent some time on this, tested some theories like maybe the new warning increases our logs to a dangerous size, but it's not that - and the tests now pass again without the lit test. Maybe the lit tests use more memory because they run in parallel or some other resource exhaustion? (Not urgent for this PR, I don't think, but I can file an issue for it unless this is something obvious that you recognize.) |
I suspect that the working directory for the test on the bots is different than in your local setup, so the relative path the test uses works for you but not for the bots. The working directory for the lit tests is configured here to be the It's probably not worth reconfiguring the lit tests or duplicating the cubescript.wasm input file (assuming it's used by other tests), so keeping this as a python test lgtm. |
@tlively I see, thanks - yes, that could make sense. Any idea why it doesn't show a proper error though? That's really confusing... |
The error looks fine from what I can see. From the logs:
|
Oh, sorry @tlively , I was reading the log incorrectly... |
Previously the
addDefault*
methods would avoid adding opt passes that weknow are incompatible with DWARF. However, that didn't handle the case of
passes that are added in other ways. For example, when running Asyncify,
emcc will run
--flatten
before, and that pass is not compatible with DWARF.This PR lets us warn on that by annotating the passes themselves. Then we
use those annotation to either not run a pass at all (matching the previous
behavior) or to show a warning when necessary.
Open to better ideas for the
addIfDWARFAllowed
name - ?Fixes emscripten-core/emscripten#13288 . That is, concretely
after this PR running asyncify + DWARF will show a warning to the user.