Skip to content

Fix loading of C source files#19

Merged
stilscher merged 8 commits intomasterfrom
fix-c-file-loading
Feb 28, 2023
Merged

Fix loading of C source files#19
stilscher merged 8 commits intomasterfrom
fix-c-file-loading

Conversation

@stilscher
Copy link
Copy Markdown
Member

This PR fixes issues that emerged when building and using Gobview:

  • adds some additional stubs that are necessary to successfully build Gobview
  • fixes the broken favicon
  • fixes the C file loading. It now loads C files based on their unique name (that is looked up in the unmarshalled file name location mapping) from the file directory where Goblint copies them to.
  • fixes the type of the unmarshalled timing statistics to match the one used for marshalling and warns if the timing is 0s because the timing option was possibly not enabled

Depends on goblint/analyzer#993
Fixes #2

@stilscher stilscher marked this pull request as ready for review February 17, 2023 14:04
@sim642 sim642 added the bug Something isn't working label Feb 17, 2023
runtime/stubs.js Outdated
Comment on lines +33 to +37
//Provides: ml_z_of_int
//Requires: ml_z_of_int64, ml_z_to_int64
function ml_z_of_int(x) {
return ml_z_of_int64(ml_z_to_int64(x));
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right? The name suggests a conversion int → Z.t, but the implementation does Z.t → int64 → Z.t. Shouldn't it be int → int64 → Z.t instead, where the first half is some standard OCaml conversion?

Actually I'm kind of confused about this function altogether. ml_z_of_int is defined in Zarith's C code, but never actually used, so how come we need it for JS? Since it's not used by Zarith's OCaml interface, zarith_stubs_js probably doesn't have it for that reason.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, there seems to be a mistake in the stub's implementation. I guess, the js_of_ocaml version for OCamls Int64.of_int would be the right thing to call instead?

I am also not sure were it is required, but it throws this error when one tries to run Gobview:

Uncaught TypeError: runtime.ml_z_of_int is not a function
    at _b_ (findlib_config.ml:0:0)
    at _q_ (findlib_config.ml:0:0)
    at caml_call2 (findlib_config.ml:0:0)
    at eval (cilint.ml:25:11)
    at eval (findlib_config.ml:0:0)
    at ./src/App.bc.js (main.js:7891:1)
    at __webpack_require__ (main.js:8006:42)
    at main.js:8254:37
    at main.js:8256:12

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured out where it's being used from. Our Gobview-compatible Zarith restores its usage: goblint/Zarith@db75b80#diff-2f0def1d12de7f2f0820477b20db522ead8e232b5327b3b81273f00ab32d0662R126.

Prior to it being changed in Zarith (ocaml/Zarith@2933e9a), zarith_stubs_js had an implementation for it, which I suppose we could just copy for our own usage: janestreet/zarith_stubs_js@0484894#diff-620d8f84607e4a3c91579ab868c89080849559f6533315da0c0ec092f9899a11L182-L188.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the implementation you suggested. I am still wondering a little though, because it is the same as for of_int32 but different from the one for of_int64.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that might just be because int64 doesn't fit into JavaScript's number type, which is a double, but int32 does. And AFAIK js_of_ocaml's int is 31-bit (hence the whole business with our custom Zarith to marshal things specially for js_of_ocaml) and thus directly fits.

@stilscher stilscher merged commit dcc2b4d into master Feb 28, 2023
@stilscher stilscher deleted the fix-c-file-loading branch February 28, 2023 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

File not found in file view

3 participants