Skip to content
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

ocaml backend fixes for pc, export offline lifter library #120

Merged
merged 17 commits into from
Feb 4, 2025

Conversation

ailrst
Copy link

@ailrst ailrst commented Jan 8, 2025

  • generated dune file now has public name asli.offline so we can link it in gtirb_semantics
  • ocaml offline lifter takes argument ?pc, with the offline lifter producing a run-time error if its required and not provided. If the generated lifter is not configured to supply pc it just ignores the argument.

@ailrst ailrst changed the title tweak ocaml backend supporting pc, and export a library ocaml backend fixes for pc, and export a library Jan 8, 2025
@ailrst ailrst changed the title ocaml backend fixes for pc, and export a library ocaml backend fixes for pc, export offline lifter library Jan 8, 2025
libASL/ocaml_backend.ml Outdated Show resolved Hide resolved
@ailrst ailrst force-pushed the export-offline-lifter branch 5 times, most recently from 0c4c77a to 78c9e58 Compare January 16, 2025 04:56
@ailrst
Copy link
Author

ailrst commented Jan 16, 2025

The last commit separates offline and asli into two separate packages, and makes it possible to build the offline lifter directly with dune (see commit message). If installing through opam asli needs to be explicitly installed first otherwise it tries to find it in the main opam repository.

$ opam pin scan 'git+https://github.com/UQ-PAC/aslp.git#export-offline-lifter'
# Name        # Version  # Url                                                         # Subpath
aslp_offline  0.2.0      git+https://github.com/UQ-PAC/aslp.git#export-offline-lifter  -
asli          0.2.0      git+https://github.com/UQ-PAC/aslp.git#export-offline-lifter  -

@katrinafyi
Copy link
Member

should we turn off marshalling by default

@ailrst ailrst force-pushed the export-offline-lifter branch from c5dce85 to a870076 Compare January 16, 2025 14:30
@katrinafyi
Copy link
Member

i saw this error while building via an opam pin (using the instructions at https://www.github.com/katrinafyi/aslp-web/pull/8). idk if this would happen with dune in a local checkout.

#=== ERROR while compiling aslp_offline.0.2.0 =================================#
# context     2.3.0 | linux/x86_64 | ocaml.4.14.2 | pinned(git+https://github.com/UQ-PAC/aslp#export-offline-lifter#a870076de9b6f998120db2e1c910539338c7315f)
# path        ~/.opam/default/.opam-switch/build/aslp_offline.0.2.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p aslp_offline -j 7 @install
# exit-code   1
# env-file    ~/.opam/log/aslp_offline-114121-dcc48d.env
# output-file ~/.opam/log/aslp_offline-114121-dcc48d.out
### output ###
# Failed to gen 'aarch64_integer_pac_strip_dp_1src.0([],[LiftTime])': Unexpected runtime expression: gen_add_int.0 {{  }} ( gen_add_int.0 {{  }} ( gen_sub_int.0 {{  }} ( gen_sub_int.0 {{  }} ( gen_int_lit.0 {{  }} ( 56 ),gen_cvt_bits_uint.0 {{ 8 }} ( gen_load.0 {{  }} ( CalculateBottomPACBit143__3 ) ) ),gen_int_lit.0 {{  }} ( 1 ) ),gen_int_lit.0 {{  }} ( 1 ) ),gen_int_lit.0 {{  }} ( 8 ) )
# [...]
# Done generating ocaml lifter into '.'.
# (cd _build/default && /home/rina/.opam/default/bin/ocamlc.opt -cclib -lstdc++ -g -bin-annot -I bin/.offline_sem.eobjs/byte -I /home/rina/.opam/default/lib/asli/libASL -I /home/rina/.opam/default/lib/asli/libASL-stage0 -I /home/rina/.opam/default/lib/asli/libASL-stage1 -I /home/rina/.opam/default/lib/asli/libASL-support-native -I /home/rina/.opam/default/lib/asli/libASL-virtual -I /home/rina/.[...]
# File "bin/offline_sem.ml", line 2, characters 5-12:
# 2 | open Asl_ast
#          ^^^^^^^
# Error: Unbound module Asl_ast
# (cd _build/default && /home/rina/.opam/default/bin/ocamlc.opt -cclib -lstdc++ -g -bin-annot -I bin/.offline_coverage.eobjs/byte -I /home/rina/.opam/default/lib/asli/libASL -I /home/rina/.opam/default/lib/asli/libASL-stage0 -I /home/rina/.opam/default/lib/asli/libASL-stage1 -I /home/rina/.opam/default/lib/asli/libASL-support-native -I /home/rina/.opam/default/lib/asli/libASL-virtual -I /home/r[...]
# File "bin/offline_coverage.ml", line 3, characters 5-12:
# 3 | open Asl_ast
#          ^^^^^^^
# Error: Unbound module Asl_ast

@ailrst
Copy link
Author

ailrst commented Jan 21, 2025

i saw this error while building via an opam pin (using the instructions at https://www.github.com/katrinafyi/aslp-web/pull/8). idk if this would happen with dune in a local checkout.

#=== ERROR while compiling aslp_offline.0.2.0 
...
# Error: Unbound module Asl_ast

I can't reproduce this on either of my computers, here with tool versions:

$ ocaml --version ; dune --version ; opam --version 
The OCaml toplevel, version 5.2.1
3.17.1
2.2.1

I don't know why it would do that as offline_sem is still linking libASL directly.

@katrinafyi
Copy link
Member

it looks like it was a my computer problem, my /home/rina/.opam/default/lib/asli/ was an scattered mix of multiple asli versions

@ailrst ailrst force-pushed the export-offline-lifter branch 2 times, most recently from 0df6261 to fbe5d55 Compare January 21, 2025 13:19
ailrst and others added 10 commits January 22, 2025 11:36
We now define two packages, asli and aslp_offline. The offline
lifter library gets a different name depending on whether
its built with pc support which is enabled by default in
offlineASL/gen-command (breaking offline-coverage).

libASL/dune now invokes asli to generate the lifter into the
build directory. This makes everything buildable
so the offline lifter should be useable as an opam pin dependency.

Asli can generate the dune to build the offline lifter,
but there is a little bit bit of manual mess, e.g. regarding
the command to build asli. We also don't properly invalidate the
cached marshalled generated lifter (which appears in
_build/default/marshalled-offline-lifter-*) when we rebuild
asli; to regenerate the lifter you must first run `dune clean`.
the install dependency was requiring a build of all packages.
note, to install asli only, you will have to use `dune install -p asli`
this will also build asli if needed for the offline generation
- Moves Primops, Value and Symbolic into stage0 to support this
- Some fixes for the previous commit
@ailrst ailrst force-pushed the export-offline-lifter branch 2 times, most recently from dd3a31f to 4d99e40 Compare January 22, 2025 02:12
@ailrst ailrst force-pushed the export-offline-lifter branch from 4d99e40 to a31041c Compare January 22, 2025 02:16
@katrinafyi katrinafyi force-pushed the export-offline-lifter branch 2 times, most recently from 52d2cc6 to 9eafc90 Compare January 22, 2025 03:57
@katrinafyi katrinafyi force-pushed the export-offline-lifter branch from 9eafc90 to 6326e83 Compare January 22, 2025 04:04
@katrinafyi katrinafyi force-pushed the export-offline-lifter branch from a5c5244 to 29ab7c1 Compare February 3, 2025 08:01
@katrinafyi katrinafyi self-assigned this Feb 3, 2025
@ailrst
Copy link
Author

ailrst commented Feb 4, 2025

Your changes look really good, dune build @offline-coverage works now from a fresh repo, although it unneccessarily builds the offline lifter with lift-time pc support, that isn't too much of an issue.

@ailrst ailrst merged commit 52726c4 into partial_eval Feb 4, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants