Skip to content

Conversation

XVilka
Copy link
Contributor

@XVilka XVilka commented Jun 9, 2020

Travis is too clunky, also it is possible to use new action template from https://discuss.ocaml.org/t/github-actions-for-ocaml-opam-now-available/4745

@ivg
Copy link
Member

ivg commented Jun 9, 2020

It looks very promising, the main roadblocker is #1111, which I think is resolved by #1114 but it looks like that we need to rebase/merge master into this PR.

The other missing thing is running, tests and checks, with make test and make check (as adding --with-tests and --with-docs won't really run them, and they (tests) are built despite the presence of this flag.

@rvantonder
Copy link
Member

rvantonder commented Jun 10, 2020

👋 incidentally I recently tried to get BAP to compile using a GH action. I tried going the ./configure route and not opam install (this would allow make test and make check right?). The furthest I got was

./setup.exe -quiet -build 
ocamlfind ocamlopt -package unix -package ocamlbuild -linkpkg -package findlib myocamlbuild.ml /home/runner/.opam/4.09.0/lib/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
Fatal error: exception Failure("No variable llvm_cxxflags defined when trying to expand \"${llvm_cxxflags}\".")
make: *** [build] Error 1

job. I'm just trying to get it running on ubuntu-latest for a start, so the workflow file is:

name: LSIF
on: [push, pull_request]
jobs:
  build:
    name: Build and push LSIF data
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: OCaml setup
        uses: avsm/setup-ocaml@master
        with:
          ocaml-version: '4.09.0'
      - run: opam depext -yt bap
      - run: sudo apt-get install libcurl4-gnutls-dev # turns out depext didn't pick up this this dependency 🤷 
      - run: opam install -t . --deps-only
      - run: opam exec -- ./configure --enable-everything
      - run: opam exec -- make

@ivg
Copy link
Member

ivg commented Jun 10, 2020

incidentally I recently tried to get BAP to compile using a GH action. I tried going the ./configure route and not opam install (this would allow make test and make check right?). The furthest I got was

Not actually, the opam/opam file which is pinned in the @XVilka's proposal will enable tests and this is the file that is used in Travis. The reason why it didn't work is because of #1111, which is solved by #1114 so we need to rebase/merge #1114 into this PR.

The main culprit why it didn't work with the ./configure approach (which is also viable) is that the ./configure invocation should be slightly more complicated, and query conf-bap-llvm for the actual location/version of LLVM.

P.S. Glad to see you back doing BAPish things :)

@dbrumley
Copy link
Contributor

I probably don't have much, but can share I recently went through some github actions migration recently. One thing we settled on was starting to use shell scripts since it made it easier to test.
Something like: https://github.com/ForAllSecure/VulnerabilitiesLab/blob/master/.github/workflows/docker_publish.yml

Though AFAIK, there is a run syntax for shell scripts. https://github.com/docker-practice/actions-setup-docker/blob/master/.github/workflows/ci.yaml#L32

@XVilka
Copy link
Contributor Author

XVilka commented Jun 11, 2020

@dbrumley there is already existing GitHub Action for publishing to Docker, we use it in radare2 project: https://github.com/marketplace/actions/publish-docker

@XVilka
Copy link
Contributor Author

XVilka commented Jun 11, 2020

I wanted to setup also Windows worker, but strangely z3 is disabled for win32 for some reason by @fdopen in fdopen/opam-repository-mingw@7ca1bb1

@XVilka

This comment has been minimized.

@XVilka

This comment has been minimized.

@XVilka
Copy link
Contributor Author

XVilka commented Jun 15, 2020

After trying MacOS build again it seems there is a new error, and it might be in the code:

┌─ The following actions failed
│ ∗ install bap master
└─ 
╶─ No changes have been performed
# context              2.0.7 | macos/x86_64 | ocaml-base-compiler.4.09.1 | pinned(git+file:///Users/runner/runners/2.263.0/work/bap/bap#HEAD#856b159b)
# path                 ~/.opam/4.09.1/.opam-switch/build/bap.master
# command              ~/.opam/opam-init/hooks/sandbox.sh install make test
# exit-code            2
# env-file             ~/.opam/log/bap-91713-4f4523.env
# output-file          ~/.opam/log/bap-91713-4f4523.out
### output ###
# [...]
# bil.info> providing a lifter for all BIL lifters
# powerpc.info> Providing PowerPC semantics in BIL
# cache.warning> Failed to read config file: ("Unix.Unix_error(Unix.ENOENT, \"open\", \".cache/config.3\")")
# Failed to initialize BAP: Internal error: (Sys_error ".cache/data: No such file or directory")
# Backtrace:
# Raised by primitive operation at file "plugins/cache/bap_cache_gc.ml", line 101, characters 2-18
# Called from file "plugins/cache/bap_cache_gc.ml", line 143, characters 16-43
# Called from file "plugins/cache/bap_cache_main.ml", line 138, characters 2-27
# Called from file "lib/bap_main/bap_main.ml", line 789, characters 37-46
# Called from file "lib/bap_main/bap_main.ml", line 945, characters 25-28
# 
# make: *** [test] Error 1

# Run eval $(opam env) to update the current shell environment
'opam install bap -v --yes --with-test' failed.

@ivg
Copy link
Member

ivg commented Jun 15, 2020

Ok, I've pushed the fix to #1109, reset Oleg's morning attempts and rebased the original patch onto the new master.

@ivg
Copy link
Member

ivg commented Jun 15, 2020

Finally, we passed the test and sandboxing issues, but still failing on macos since we're picking not the installed LLVM, but the LLVM which is shipped with the os (and which is stripped and doesn't have arm,powerpc, and other targets).

First of all, `/usr/local/opt/llvm/bin/llvm-config`
is llvm-config of LLVM that is shipped with MacOS and which is
stripped from any non-native targets so we can't use it. The
requested llvm@9 is installed at `/usr/local/opt/llvm@9` and is not
symlinked to `/usr/local` because it is keg-only:

```
llvm@9 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have llvm@9 first in your PATH run:
  echo 'export PATH="/usr/local/opt/llvm@9/bin:$PATH"' >> /Users/runner/.bash_profile

For compilers to find llvm@9 you may need to set:
  export LDFLAGS="-L/usr/local/opt/llvm@9/lib"
  export CPPFLAGS="-I/usr/local/opt/llvm@9/include"
```

llvm@10 aka llvm is also keg-only so it will be installed only into
the cellar. I have to guess whether the llvm-config binary will be
named llvm-config or llvm-config-9, but I bet for the former.
@XVilka
Copy link
Contributor Author

XVilka commented Jun 16, 2020

The MacOS build looks stuck at:

Running ./bap.tests/api-options.exp ...
##[error]The operation was canceled.

BTW, good we decided to build with MacOS as well - already a few bugs were spotted.

ivg
ivg previously approved these changes Jun 17, 2020
The master branch is already restricted from pushes so the code can reach the master branch only through a pull requested. We don't want to the same work twice.

Also removes (the commented) windows line, we will return it back, once we will have time for that, see also BinaryAnalysisPlatform#512
@XVilka
Copy link
Contributor Author

XVilka commented Jun 17, 2020

It works!

@ivg
Copy link
Member

ivg commented Jun 17, 2020

Finally, thanks to everyone for the hard work! This is the first step, we will move more of our infrastructure to the actions and optimize the testsuite that takes more than hour on Mac (for some unknown to us reason). But anyway, we now have a working CI system, and soon we will get CICD :)

@ivg ivg merged commit f2b844e into BinaryAnalysisPlatform:master Jun 17, 2020
@XVilka XVilka mentioned this pull request Jun 28, 2020
@XVilka XVilka mentioned this pull request Dec 3, 2020
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.

5 participants