Skip to content

add a owi llvm or owi bc command#967

Merged
redianthus merged 12 commits intoOCamlPro:mainfrom
FUJIZZ:main
Apr 30, 2026
Merged

add a owi llvm or owi bc command#967
redianthus merged 12 commits intoOCamlPro:mainfrom
FUJIZZ:main

Conversation

@FUJIZZ
Copy link
Copy Markdown
Contributor

@FUJIZZ FUJIZZ commented Apr 26, 2026

What does this PR do ?

Add a command to compile .ll and .bc files.
Add llvm command cramtests.
Add llvm command docs.

Not a native symbolic execution for LLVM -> convert files into wasm and then use Owi Symbolic Execution.
Here is the pipeline to compile the LLVM file (in the order).

  • llvm-as : .ll file -> .bc file
  • llc : bitcode compilation -> .o wasm files
  • wasm-ld : link .o files to produce final wasm file
  • Owi symex executed on the wasm file

Why this change needed ?

Add a new command to facilitate .bc and .ll files.

How to test ?

The following cramtest are provided to validate the feature :

./test/cram/llvm/empty.t
./test/cram/llvm/not_exists.t
./test/cram/llvm/simple.t
./test/cram/llvm/trap_div_zero.t
./test/cram/llvm/unsupported_ext.t

To test :

dune runtest {test}

Issue

Closes #300

N-B: This contribution is part of work carried out as a student at Université Paris-Cité.
Apologies if this is inappropriate or if the contribution does not meet the project's standards, any feedback is welcome.

@redianthus
Copy link
Copy Markdown
Member

Hi !

Thanks for the contribution. I think you need to run dune fmt (with the correct ocamlformat version installed) for the Nix CI to pass (the others CI are broken and you can ignore them).

Comment thread test/cram/llvm/simple.ll Outdated
@@ -0,0 +1,6 @@
target triple = "wasm32-unknown-unknown"
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 really necessary? I think it'd be better if we could omit this from the llvm file and simply pass it inside Owi when calling llvm. It will allow people to use it on any llvm file rather than on file that were made specifically for Wasm (but I don't know if it's possible as I'm not familiar with llvm).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, I agree with you and I can remove it.
The target is already enforced by the option -march=wasm32, in the command llc , in cmd_llvm.ml file.
We can eventually add the target triple option in the llc command with the option -mtriple=wasm32-unknown-unknown if necessary.

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.

Yes, I think it would be much better!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It still work if we remove the line though.

Moreover, I didn't test my code with any other env/distro, so I don't known if the compilation may fail.

@FUJIZZ
Copy link
Copy Markdown
Contributor Author

FUJIZZ commented Apr 27, 2026

I have made the corrections you suggested to me, but the Nix CI seems still fail, even after dune fmt.

@redianthus
Copy link
Copy Markdown
Member

redianthus commented Apr 27, 2026

Yes, this time it seems you are using an old version of cmdliner and the output is different which makes the cram tests fail. Which version of cmdliner are you using? Could you try to use a more recent one? (If you use opam, it may be that our opam file is not updated to use the latest cmdliner version, in which case, you could fix it along the way by changing dune-project and then dune build owi.opam).

@FUJIZZ
Copy link
Copy Markdown
Contributor Author

FUJIZZ commented Apr 27, 2026

Yes I was using cmdliner 1.3.0, I updated it manually to 2.1.1 version.

I also updated the dune-project file.

@redianthus
Copy link
Copy Markdown
Member

Thanks! You need to run dune runtest and then dune promote now.

@FUJIZZ
Copy link
Copy Markdown
Contributor Author

FUJIZZ commented Apr 28, 2026

Actually, when I'm running dune runtest, there is a lot of test (not llvm's ones) with different outputs from the original outputs.

I seems like there is a problem with my env (missing deps or other...).
Therefore, I'm not sure about dune promote now.

Maybe I can show you through Zulip?

@redianthus
Copy link
Copy Markdown
Member

Looks all good now, thanks for the contribution! :)

@redianthus redianthus merged commit b4861f1 into OCamlPro:main Apr 30, 2026
3 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add a owi llvm or owi bc command

2 participants