-
Notifications
You must be signed in to change notification settings - Fork 465
Ignore self-cycles on bsb_helper to suppress false positives #5393
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
Ignore self-cycles on bsb_helper to suppress false positives #5393
Conversation
Signed-off-by: Yuta Sato <[email protected]>
Aside: build tests are running on Mac GitHub ci. |
@cannorin one issue is
And after this change it's empty. |
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.
See comments about editor integration.
Since it's currently missing and did not get caught, a test should check what goes into |
// Demo2.res
module Foo2 = {}
// Foo2.res
open Demo2
include Foo2 So The point of this PR is to prevent the compiler from failing by falsely detecting it as a self cycle, so I suppose these errors in
Yes, but I think this means this test was failing silently, so we didn't notice the problem. I checked out |
What I meant is that in case of a real self cycle, after this change, it's not reported in |
I should say that non-self cycles were never reported in |
Then I will add real (self and non-self) cyclic test cases to I'm not very sure about how to write a real self-cycle, though. I have a feeling that it would end up in a different kind of compile error such as // A.res
include A // module A not found In contrast, non-self cycle is easy to write: // A.res
include B
// B.res
include A |
% cat src/A.res
module B = B
% cat src/B.res
module A = A
% npx rescript
rescript: [1/3] src/B.d
FAILED: dependency cycle: src/A.cmj -> src/B.cmj -> src/A.cmj.
% cat lib/bs/.compiler.log
#Start(1653569073904)
#Done(1653569073915) I believe it's ninja speaking when it says "dependency cycle". The build system generates a ninja file, and ninja finds the cycle before the compiler ever runs. |
It seems there is already a test to check the cycle error: https://github.com/rescript-lang/rescript-compiler/tree/master/jscomp/build_tests/cycle I'll modify this to check |
(this should fail) Signed-off-by: Yuta Sato <[email protected]>
9c38815
to
a77da2e
Compare
Looks like the test fails where it's expected to fail. |
It looks like we should fix I'm still trying to figure it out how the code works, so it may take some time. |
ninja is a separate standalone project which is forked and vendored as a submodule. It should not have direct access to compiler log if possible. |
It should be possible. We can |
@cristianoc It turned out it is almost impossible without modifying the bundled ninja.
|
@cannorin thanks for figuring all that out! What's the smallest change to ninja that would give us what's needed? |
I've done a little cleanup of branches in the ninja fork. Now the branch is called |
It should be enough to modify https://github.com/rescript-lang/ninja/blob/rescript/src/ninja.cc#L1175-L1179 so that it also writes to There is also https://github.com/rescript-lang/ninja/blob/rescript/src/build.cc#L155-L159 who says |
Isn't that basically this PR: https://github.com/rescript-lang/ninja/pull/2/files? |
Ohh indeed it looks like ninja is already writing to compiler log: fprintf(compiler_log_,"#Start(%" PRId64 ")\n", GetTimeMillis()); So I guess it just needs to write one more thing there. Sorry for giving wrong advice. |
@cannorin this is now merged: rescript-lang/ninja#2 I think one needs to update the vendored binaries:
|
It looks like I can only update Can someone handle the win32 and darwin binaries? |
(I will revert the above commit if we decide to do this in a separate commit/PR) |
You can take it from CI: which generates them for you: That said there was something red on that build, taking a look. |
It was just the arm64 build, which is not yet shipped with the compiler anyway. |
Taking it back:
|
OK it has run again and is green now. |
Signed-off-by: Yuta Sato <[email protected]>
41ece46
to
b587186
Compare
$ file darwinarm64/ninja.exe
darwinarm64/ninja.exe: Mach-O 64-bit arm64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|BINDS_TO_WEAK|PIE>
$ file darwin/ninja.exe
darwin/ninja.exe: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|BINDS_TO_WEAK|PIE>
$ file linux/ninja.exe
linux/ninja.exe: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=21200f70515e3c50b7ae2962f6caf2ebf577ebd5, for GNU/Linux 3.2.0, stripped
$ file win32/ninja.exe
win32/ninja.exe: PE32+ executable (console) x86-64, for MS Windows 👍 |
Signed-off-by: Yuta Sato <[email protected]>
I added a self-cycle test
|
Signed-off-by: Yuta Sato <[email protected]>
and these tests are now passing on my machine. @cristianoc can you trigger the CI and see if they also pass in CI? |
Signed-off-by: Yuta Sato <[email protected]>
|
I think
|
Good catch. |
Here: #5420 |
@cristianoc thank you very much for taking care of this PR! 🙏 |
@cannorin thanks for the great work! This was a tricky one to pull off. |
Great work @cannorin ! 👏 |
This PR disables the self-cycle checking in bsb_helper, because it is causing many false positives.
Notes:
It seems thatbuild_tests
are currently disabled in CI, which contains the original test for False positive dependency cycle when a module refers to another of the same name #2249 but left uncaught for a while.