Skip to content

Conversation

@katrinafyi
Copy link
Member

@katrinafyi katrinafyi commented Dec 13, 2024

This has been my pet project for a while and my continuous focus for the last week and a bit. It has been through a fair bit of beta-testing to work out some kinks. Hopefully, it is a well-prepared change.

The effect of this PR is to remove all of the committed lifter outputs from src/test/ and replace them with a system to compile and lift them in a reproducible way. This is done with a Docker image which contains fixed versions of the required tools, a number of scripts to tie it together, and hashes recorded within the repository in place of the committed files.

Please see https://github.com/UQ-PAC/BASIL/blob/nix-docker-build/src/test/readme.md for documentation about the Docker build. If you want to try out the changes, that readme should have all the steps needed (let me know if anything is not clear).

Note! The SystemTests are not passing. I will need some help to work these out, since the changes to ADT/GTIRB files might be very large since they were last updated in the repository.

There are obvious benefits:

  • Clear provenance for lifted examples. Versions of tools are clearly tracked by the Docker image, generated by Nix.
  • Consistency across different operating systems. The existing makefile implicitly assumes some version of Ubuntu and a x86_64-linux system.
  • Reduced repository size and preventing further increases as the binary files are updated.

We foresaw the following pain points and have worked to reduce them:

  • Strong dependency on Docker for CI and running tests. We avoid this by uploading a tarball of the Docker-compiled files and adding a Makefile rule which simply downloads and extracts them. This is fast and suitable for CI as well as users who do not need to change test cases. We hope this will not worsen the Basil onboarding experience.
  • Accidentally mixing locally-compiled files and Docker-compiled files when making the hashes. The md5sum-updating rules are written to ensure they are run within Docker. To avoid files being built without Docker, then activating Docker and updating hashes, we track whether each intermediate file was made inside or outside Docker. Updating hashes is only allowed when they are all from Docker.

There are also drawbacks / limitations.

  • Lifted files differences are not visible in web view. This may be a benefit as it cleans up diffs. However, it is more troublesome to find the diffs if you want to see them.
  • Size and complexity of Docker image. It is a little bulky to handle and takes up sizable disk space. Hopefully, this burden is lessened by the pre-built tarball. Unused Docker images can also be pruned frequently from your computer.
  • Dependency on Docker to start developing test cases. This is true, but I think the trade-off is worthwhile to get consistency. Building using local tools is still possible using the old Makefile infrastructure.
  • To ensure identical file hashes, BAP adt and bir files are normalised by replacing variable Tid addresses with deterministic ones, starting from %00000000 and incrementing. Basil might have made assumptions on these IDs.
  • The use of some scripts here might have bugs. We make efforts to program defensively and have tested on Linux and MacOS, but some bugs might remain.
  • The Makefiles inherit the existing limitation that test cases must be a single C file. This can be extracted to only handle the lifting / hashing part, to make this more flexible and usable with binaries such as cntlm.

Anticipated questions:

  • Why not Git LFS? LFS only solves one part of the problem (the distribution of binaries). The versioning of compilers and tools is still unknown. Github also has tight limits on LFS storage and bandwidth.
  • Why not Docker by itself instead of Docker via Nix? I think that it would be fairly difficult to make a traditional Dockerfile build have the level of consistency which we want. If the Docker build is not repeatable, it has much the same problems as the existing committed binaries, just in GHCR instead of the git repository. Nix is already used to distribute some of the lifter tools, and there is Nix tooling to easily bundle these into a Docker image which can be built by anyone with Nix.
  • Okay, but who knows Nix? Sadly not too many. People should learn! However, for the purposes of building this Docker image, it pulls directly from the packages already in Nix. Updating these packages is already automatic, so all you have to do here is update the docker-flake reference.
  • Why not what we already had? See benefits.

Catalogue of changed files:

To make the changes easier to see, I have made a diff which excludes all the generated file changes: https://gist.github.com/katrinafyi/23f9a7de5b99cf1843814ccb72302e18.

In summary,

  • Most of the changes are to the Makefiles in src/test, including the .mk files in make/.
  • Helper scripts in make/docker-helper.sh and make/bap-normalise.py.
    • Maybe bap-normalise should live in the bap-aslp Nix package. That way, it would also be versioned by the Docker image.
  • make/docker-flake.txt pins the Docker flake to a particular pac-nix commit (and hence the packages of that commit). src/test/docker-contents.txt lists all Nix derivations within the Docker image.
  • Each test case's compiler directory, e.g. correct/arrays_simple/clang, has a new md5sums file which tracks the hashes of a.out, adt, bir, relf, and gts files.
  • src/test/compiled.md5sums collates the md5sums from all subdirectories, for easier checking
  • src/test/compiled.url.txt is a URL to an online file holding the pre-compiled files, in a .tar.zst file. This is extracted on top of src/test to populate the files.
    • maybe we should hash the tarball, in case our file host ever becomes malicious [update: tarball is hashed now]
  • src/test/readme.md extensively documents this system. docs/... is updated to point to this.

Orthogonal but related changes:

  • Makefile fix and improvements to be more robust and customisable (e.g. lifting individual tests or folders).
  • Restructuring DSA and irreducible loops folders to be lifted by the makefile.

TODO

  • update expected files
  • ci tarball creation and download
  • docker-hash in one directory, next to big md5sum. name could be docker-contents.txt or similar
  • problem: since makefiles wildcard directories, it is easy for leftover empty directories to cause unknowable errors like "clang no input files". maybe fixed by writing makefile expression to filter for directories containing C files.
  • document above problem

@katrinafyi
Copy link
Member Author

issue with make md5sum-check

I can't encounter this, even after forcing git to use crlf by default. You can try (very carefully) resetting the src/test directory: rm -rf src/test && git checkout src/test. Otherwise, does make extract work? how about md5sum -c compiled.md5sum?

@l-kent
Copy link
Contributor

l-kent commented Dec 18, 2024

md5sum -c compiled.md5sum

worked fine once I fixed the line endings in compiled.md5sum, which is how I knew the md5sums were fine, but the \rs were still getting into make md5sum-check somewhere. I'll try it again

@katrinafyi
Copy link
Member Author

katrinafyi commented Dec 18, 2024

@l-kent For correct/syscall/gcc_O2, can I trouble you to build the test case with -O2 -v , then post the log output and binary? I didn't have success with either gcc 11, 12, or 13. It would be good to do this on an OS as similar to the one you think was used before.

update: i've docker-installed ubuntu:22.04 and it looks like it has -pie by default:

Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.4.0-1ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin
>>>>>>>>>>>--enable-default-pie<<<<<<< --with-system-zlib --enable-libphobos-checking=release --without-target-system-zlib --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=aarch64-linux-gnu --program-prefix=aarch64-linux-gnu- --includedir=/usr/aarch64-linux-gnu/include --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04) 

This leads to -pie in the collect2 (linker?) call:

 /usr/lib/gcc-cross/aarch64-linux-gnu/11/collect2
-plugin /usr/lib/gcc-cross/aarch64-linux-gnu/11/liblto_plugin.so -plugin-opt=/usr/lib/gcc-cross/aarch64-linux-gnu/11/lto-wrapper -plugin-opt=-fresolution=/tmp/ccUysZL9.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_s --sysroot=/ --build-id --eh-frame-hdr --hash-style=gnu --as-needed -dynamic-linker /lib/ld-linux-aarch64.so.1 -X -EL -maarch64linux --fix-cortex-a53-843419
>>>>>>>-pie<<<<<<<< -z now -z relro /usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/lib/../lib/Scrt1.o /usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/lib/../lib/crti.o /usr/lib/gcc-cross/aarch64-linux-gnu/11/crtbeginS.o -L/usr/lib/gcc-cross/aarch64-linux-gnu/11 -L/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/lib/../lib -L/lib/aarch64-linux-gnu -L/lib/../lib -L/usr/lib/aarch64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/lib /tmp/cccMXoL0.o -lgcc --push-state --as-needed -lgcc_s --pop-state -lc -lgcc --push-state --as-needed -lgcc_s --pop-state /usr/lib/gcc-cross/aarch64-linux-gnu/11/crtendS.o /usr/lib/gcc-cross/aarch64-linux-gnu/11/../../../../aarch64-linux-gnu/lib/../lib/crtn.o

So, I feel justified in adding -pie to all the gcc configs. I have every hope that this will fix the correct/syscall/gcc_O2 example. Let me know if you agree.

@katrinafyi
Copy link
Member Author

katrinafyi commented Dec 19, 2024

Diffs in ./mill test output as of time of this comment: https://gist.github.com/katrinafyi/01181184e153a75a8c0d710ee089c6da

We fail 54 tests compared to 30 failing in main. I'll take a look, maybe it's BAP-related.

Edit: As of 05e7deb, indirect call tests are fixed and 38 tests fail.

@katrinafyi katrinafyi marked this pull request as draft January 13, 2025 08:18
@katrinafyi katrinafyi marked this pull request as ready for review January 29, 2025 03:54
Conflicts:
.github/workflows/run-examples.yml
docs/development/readme.md
src/main/scala/ir/IRCursor.scala
src/main/scala/ir/Program.scala
src/test/correct/arrays_simple/clang/arrays_simple.expected
src/test/correct/arrays_simple/clang/arrays_simple_gtirb.expected
src/test/correct/basic_arrays_read/clang/basic_arrays_read.expected
src/test/correct/basic_arrays_read/clang/basic_arrays_read_gtirb.expected
src/test/correct/basic_arrays_read/clang_pic/basic_arrays_read.expected
src/test/correct/basic_arrays_read/clang_pic/basic_arrays_read_gtirb.expected
src/test/correct/basic_arrays_read/gcc/basic_arrays_read.expected
src/test/correct/basic_arrays_read/gcc/basic_arrays_read_gtirb.expected
src/test/correct/basic_arrays_read/gcc_pic/basic_arrays_read.expected
src/test/correct/basic_arrays_read/gcc_pic/basic_arrays_read_gtirb.expected
src/test/correct/basic_arrays_write/clang/basic_arrays_write.expected
src/test/correct/basic_arrays_write/clang/basic_arrays_write_gtirb.expected
src/test/correct/basic_arrays_write/clang_O2/basic_arrays_write.expected
src/test/correct/basic_arrays_write/clang_O2/basic_arrays_write_gtirb.expected
src/test/correct/basic_arrays_write/clang_pic/basic_arrays_write.expected
src/test/correct/basic_arrays_write/clang_pic/basic_arrays_write_gtirb.expected
src/test/correct/basic_assign_assign/clang/basic_assign_assign.expected
src/test/correct/basic_assign_assign/clang/basic_assign_assign_gtirb.expected
src/test/correct/basic_assign_assign/clang_pic/basic_assign_assign.expected
src/test/correct/basic_assign_assign/clang_pic/basic_assign_assign_gtirb.expected
src/test/correct/basic_assign_increment/clang/basic_assign_increment.expected
src/test/correct/basic_assign_increment/clang/basic_assign_increment_gtirb.expected
src/test/correct/basic_assign_increment/clang_pic/basic_assign_increment.expected
src/test/correct/basic_assign_increment/clang_pic/basic_assign_increment_gtirb.expected
src/test/correct/basic_function_call_caller/clang/basic_function_call_caller.expected
src/test/correct/basic_function_call_caller/clang/basic_function_call_caller_gtirb.expected
src/test/correct/basic_function_call_caller/clang_O2/basic_function_call_caller.expected
src/test/correct/basic_function_call_caller/clang_O2/basic_function_call_caller_gtirb.expected
src/test/correct/basic_function_call_caller/clang_pic/basic_function_call_caller.expected
src/test/correct/basic_function_call_caller/clang_pic/basic_function_call_caller_gtirb.expected
src/test/correct/basic_function_call_reader/clang/basic_function_call_reader.expected
src/test/correct/basic_function_call_reader/clang/basic_function_call_reader_gtirb.expected
src/test/correct/basic_function_call_reader/clang_O2/basic_function_call_reader.expected
src/test/correct/basic_function_call_reader/clang_O2/basic_function_call_reader_gtirb.expected
src/test/correct/basic_function_call_reader/clang_pic/basic_function_call_reader.expected
src/test/correct/basic_function_call_reader/clang_pic/basic_function_call_reader_gtirb.expected
src/test/correct/basic_lock_read/clang/basic_lock_read.expected
src/test/correct/basic_lock_read/clang/basic_lock_read_gtirb.expected
src/test/correct/basic_lock_read/clang_O2/basic_lock_read.expected
src/test/correct/basic_lock_read/clang_O2/basic_lock_read_gtirb.expected
src/test/correct/basic_lock_read/clang_pic/basic_lock_read.expected
src/test/correct/basic_lock_read/clang_pic/basic_lock_read_gtirb.expected
src/test/correct/basic_lock_security_read/clang/basic_lock_security_read.expected
src/test/correct/basic_lock_security_read/clang/basic_lock_security_read_gtirb.expected
src/test/correct/basic_lock_security_read/clang_O2/basic_lock_security_read.expected
src/test/correct/basic_lock_security_read/clang_O2/basic_lock_security_read_gtirb.expected
src/test/correct/basic_lock_security_read/clang_pic/basic_lock_security_read.expected
src/test/correct/basic_lock_security_read/clang_pic/basic_lock_security_read_gtirb.expected
src/test/correct/basic_lock_security_write/clang/basic_lock_security_write.expected
src/test/correct/basic_lock_security_write/clang/basic_lock_security_write_gtirb.expected
src/test/correct/basic_lock_security_write/clang_O2/basic_lock_security_write.expected
src/test/correct/basic_lock_security_write/clang_O2/basic_lock_security_write_gtirb.expected
src/test/correct/basic_lock_security_write/clang_pic/basic_lock_security_write.expected
src/test/correct/basic_lock_security_write/clang_pic/basic_lock_security_write_gtirb.expected
src/test/correct/basic_lock_unlock/clang/basic_lock_unlock.expected
src/test/correct/basic_lock_unlock/clang/basic_lock_unlock_gtirb.expected
src/test/correct/basic_lock_unlock/clang_pic/basic_lock_unlock.expected
src/test/correct/basic_lock_unlock/clang_pic/basic_lock_unlock_gtirb.expected
src/test/correct/basic_loop_assign/clang/basic_loop_assign.expected
src/test/correct/basic_loop_assign/clang/basic_loop_assign_gtirb.expected
src/test/correct/basic_loop_assign/clang_pic/basic_loop_assign.expected
src/test/correct/basic_loop_assign/clang_pic/basic_loop_assign_gtirb.expected
src/test/correct/basic_operation_evaluation/clang/basic_operation_evaluation.expected
src/test/correct/basic_operation_evaluation/clang/basic_operation_evaluation_gtirb.expected
src/test/correct/basic_operation_evaluation/gcc/basic_operation_evaluation.expected
src/test/correct/basic_operation_evaluation/gcc/basic_operation_evaluation_gtirb.expected
src/test/correct/basic_sec_policy_read/clang/basic_sec_policy_read.expected
src/test/correct/basic_sec_policy_read/clang/basic_sec_policy_read_gtirb.expected
src/test/correct/basic_sec_policy_read/clang_O2/basic_sec_policy_read.expected
src/test/correct/basic_sec_policy_read/clang_O2/basic_sec_policy_read_gtirb.expected
src/test/correct/basic_sec_policy_read/clang_pic/basic_sec_policy_read.expected
src/test/correct/basic_sec_policy_read/clang_pic/basic_sec_policy_read_gtirb.expected
src/test/correct/basic_sec_policy_write/clang/basic_sec_policy_write.expected
src/test/correct/basic_sec_policy_write/clang/basic_sec_policy_write_gtirb.expected
src/test/correct/basic_sec_policy_write/clang_O2/basic_sec_policy_write.expected
src/test/correct/basic_sec_policy_write/clang_O2/basic_sec_policy_write_gtirb.expected
src/test/correct/basic_sec_policy_write/clang_pic/basic_sec_policy_write.expected
src/test/correct/basic_sec_policy_write/clang_pic/basic_sec_policy_write_gtirb.expected
src/test/correct/basicassign_gamma0/clang/basicassign_gamma0.expected
src/test/correct/basicassign_gamma0/clang/basicassign_gamma0_gtirb.expected
src/test/correct/basicassign_gamma0/clang_pic/basicassign_gamma0.expected
src/test/correct/basicassign_gamma0/clang_pic/basicassign_gamma0_gtirb.expected
src/test/correct/basicfree/clang/basicfree.expected
src/test/correct/basicfree/clang/basicfree_gtirb.expected
src/test/correct/basicfree/gcc/basicfree.expected
src/test/correct/basicfree/gcc/basicfree_gtirb.expected
src/test/correct/cjump/clang/cjump.expected
src/test/correct/cjump/clang/cjump_gtirb.expected
src/test/correct/cjump/clang_pic/cjump.expected
src/test/correct/cjump/clang_pic/cjump_gtirb.expected
src/test/correct/cjump/gcc/cjump.expected
src/test/correct/cjump/gcc/cjump_gtirb.expected
src/test/correct/cjump/gcc_pic/cjump.expected
src/test/correct/cjump/gcc_pic/cjump_gtirb.expected
src/test/correct/floatingpoint/clang/floatingpoint_gtirb.expected
src/test/correct/floatingpoint/gcc/floatingpoint_gtirb.expected
src/test/correct/function/clang/function.expected
src/test/correct/function/clang/function_gtirb.expected
src/test/correct/function/clang_pic/function.expected
src/test/correct/function/clang_pic/function_gtirb.expected
src/test/correct/function/gcc/function.expected
src/test/correct/function/gcc/function_gtirb.expected
src/test/correct/function/gcc_pic/function.expected
src/test/correct/function/gcc_pic/function_gtirb.expected
src/test/correct/function1/gcc/function1.expected
src/test/correct/function1/gcc/function1_gtirb.expected
src/test/correct/function1/gcc_O2/function1.expected
src/test/correct/function1/gcc_O2/function1_gtirb.expected
src/test/correct/functionpointer/gcc/functionpointer_gtirb.expected
src/test/correct/functionpointer/gcc_O2/functionpointer_gtirb.expected
src/test/correct/functionpointer/gcc_pic/functionpointer_gtirb.expected
src/test/correct/functions_with_params/clang/functions_with_params.expected
src/test/correct/functions_with_params/clang/functions_with_params_gtirb.expected
src/test/correct/functions_with_params/gcc/functions_with_params.expected
src/test/correct/functions_with_params/gcc/functions_with_params_gtirb.expected
src/test/correct/ifbranches/clang/ifbranches.expected
src/test/correct/ifbranches/clang/ifbranches_gtirb.expected
src/test/correct/ifbranches/clang_O2/ifbranches.expected
src/test/correct/ifbranches/clang_O2/ifbranches_gtirb.expected
src/test/correct/ifbranches/gcc/ifbranches.expected
src/test/correct/ifbranches/gcc/ifbranches_gtirb.expected
src/test/correct/ifbranches/gcc_O2/ifbranches.expected
src/test/correct/ifbranches/gcc_O2/ifbranches_gtirb.expected
src/test/correct/ifglobal/clang/ifglobal.expected
src/test/correct/ifglobal/clang/ifglobal_gtirb.expected
src/test/correct/ifglobal/clang_O2/ifglobal.expected
src/test/correct/ifglobal/clang_O2/ifglobal_gtirb.expected
src/test/correct/ifglobal/clang_pic/ifglobal.expected
src/test/correct/ifglobal/clang_pic/ifglobal_gtirb.expected
src/test/correct/indirect_call/gcc/indirect_call_gtirb.expected
src/test/correct/indirect_call/gcc_pic/indirect_call_gtirb.expected
src/test/correct/initialisation/clang/initialisation.expected
src/test/correct/initialisation/clang/initialisation_gtirb.expected
src/test/correct/initialisation/clang_O2/initialisation.expected
src/test/correct/initialisation/clang_O2/initialisation_gtirb.expected
src/test/correct/initialisation/clang_pic/initialisation.expected
src/test/correct/initialisation/clang_pic/initialisation_gtirb.expected
src/test/correct/jumptable2/clang/jumptable2_gtirb.expected
src/test/correct/jumptable2/clang_O2/jumptable2_gtirb.expected
src/test/correct/jumptable2/clang_pic/jumptable2_gtirb.expected
src/test/correct/jumptable2/gcc/jumptable2_gtirb.expected
src/test/correct/jumptable2/gcc_O2/jumptable2_gtirb.expected
src/test/correct/jumptable2/gcc_pic/jumptable2_gtirb.expected
src/test/correct/malloc_with_local/gcc/malloc_with_local.expected
src/test/correct/malloc_with_local/gcc/malloc_with_local_gtirb.expected
src/test/correct/malloc_with_local/gcc_O2/malloc_with_local.expected
src/test/correct/malloc_with_local/gcc_O2/malloc_with_local_gtirb.expected
src/test/correct/malloc_with_local2/gcc/malloc_with_local2.expected
src/test/correct/malloc_with_local2/gcc/malloc_with_local2_gtirb.expected
src/test/correct/malloc_with_local3/gcc/malloc_with_local3.expected
src/test/correct/malloc_with_local3/gcc/malloc_with_local3_gtirb.expected
src/test/correct/malloc_with_local3/gcc_O2/malloc_with_local3.expected
src/test/correct/malloc_with_local3/gcc_O2/malloc_with_local3_gtirb.expected
src/test/correct/multi_malloc/gcc/multi_malloc.expected
src/test/correct/multi_malloc/gcc/multi_malloc_gtirb.expected
src/test/correct/no_interference_update_x/clang/no_interference_update_x.expected
src/test/correct/no_interference_update_x/clang/no_interference_update_x_gtirb.expected
src/test/correct/no_interference_update_x/clang_pic/no_interference_update_x.expected
src/test/correct/no_interference_update_x/clang_pic/no_interference_update_x_gtirb.expected
src/test/correct/no_interference_update_y/clang/no_interference_update_y.expected
src/test/correct/no_interference_update_y/clang/no_interference_update_y_gtirb.expected
src/test/correct/no_interference_update_y/clang_pic/no_interference_update_y.expected
src/test/correct/no_interference_update_y/clang_pic/no_interference_update_y_gtirb.expected
src/test/correct/secret_write/clang/secret_write.expected
src/test/correct/secret_write/clang/secret_write_gtirb.expected
src/test/correct/secret_write/clang_O2/secret_write.expected
src/test/correct/secret_write/clang_O2/secret_write_gtirb.expected
src/test/correct/secret_write/clang_pic/secret_write.expected
src/test/correct/secret_write/clang_pic/secret_write_gtirb.expected
src/test/correct/secret_write/gcc/secret_write.expected
src/test/correct/secret_write/gcc/secret_write_gtirb.expected
src/test/correct/secret_write/gcc_O2/secret_write.expected
src/test/correct/secret_write/gcc_O2/secret_write_gtirb.expected
src/test/correct/secret_write/gcc_pic/secret_write.expected
src/test/correct/secret_write/gcc_pic/secret_write_gtirb.expected
src/test/correct/switch/clang/switch.expected
src/test/correct/switch/clang/switch_gtirb.expected
src/test/correct/switch/clang_O2/switch.expected
src/test/correct/switch/clang_O2/switch_gtirb.expected
src/test/correct/switch/gcc/switch.expected
src/test/correct/switch/gcc/switch_gtirb.expected
src/test/correct/switch/gcc_O2/switch.expected
src/test/correct/switch/gcc_O2/switch_gtirb.expected
src/test/correct/syscall/clang/syscall_gtirb.expected
src/test/correct/syscall/clang_O2/syscall_gtirb.expected
src/test/correct/syscall/gcc/syscall_gtirb.expected
src/test/correct/syscall/gcc_O2/syscall_gtirb.expected
src/test/correct/using_gamma_conditional/clang/using_gamma_conditional.expected
src/test/correct/using_gamma_conditional/clang/using_gamma_conditional_gtirb.expected
src/test/correct/using_gamma_conditional/clang_O2/using_gamma_conditional.expected
src/test/correct/using_gamma_conditional/clang_O2/using_gamma_conditional_gtirb.expected
src/test/correct/using_gamma_conditional/clang_pic/using_gamma_conditional.expected
src/test/correct/using_gamma_conditional/clang_pic/using_gamma_conditional_gtirb.expected
src/test/correct/using_gamma_write_z/clang/using_gamma_write_z.expected
src/test/correct/using_gamma_write_z/clang/using_gamma_write_z_gtirb.expected
src/test/correct/using_gamma_write_z/clang_pic/using_gamma_write_z.expected
src/test/correct/using_gamma_write_z/clang_pic/using_gamma_write_z_gtirb.expected
src/test/correct/using_gamma_write_z/gcc/using_gamma_write_z.expected
src/test/correct/using_gamma_write_z/gcc/using_gamma_write_z_gtirb.expected
src/test/correct/using_gamma_write_z/gcc_O2/using_gamma_write_z.expected
src/test/correct/using_gamma_write_z/gcc_O2/using_gamma_write_z_gtirb.expected
src/test/correct/using_gamma_write_z/gcc_pic/using_gamma_write_z.expected
src/test/correct/using_gamma_write_z/gcc_pic/using_gamma_write_z_gtirb.expected
src/test/incorrect/basicassign/clang/basicassign.expected
src/test/incorrect/basicassign/clang/basicassign_gtirb.expected
src/test/incorrect/basicassign/clang_O2/basicassign.expected
src/test/incorrect/basicassign/clang_O2/basicassign_gtirb.expected
src/test/incorrect/basicassign/clang_pic/basicassign.expected
src/test/incorrect/basicassign/clang_pic/basicassign_gtirb.expected
src/test/incorrect/basicassign/gcc/basicassign.expected
src/test/incorrect/basicassign/gcc/basicassign_gtirb.expected
src/test/incorrect/basicassign/gcc_O2/basicassign.expected
src/test/incorrect/basicassign/gcc_O2/basicassign_gtirb.expected
src/test/incorrect/basicassign/gcc_pic/basicassign.expected
src/test/incorrect/basicassign/gcc_pic/basicassign_gtirb.expected
src/test/incorrect/basicassign1/clang/basicassign1.expected
src/test/incorrect/basicassign1/clang/basicassign1_gtirb.expected
src/test/incorrect/basicassign1/clang_O2/basicassign1.expected
src/test/incorrect/basicassign1/clang_O2/basicassign1_gtirb.expected
src/test/incorrect/basicassign1/clang_pic/basicassign1.expected
src/test/incorrect/basicassign1/clang_pic/basicassign1_gtirb.expected
src/test/incorrect/basicassign1/gcc/basicassign1.expected
src/test/incorrect/basicassign1/gcc/basicassign1_gtirb.expected
src/test/incorrect/basicassign1/gcc_O2/basicassign1.expected
src/test/incorrect/basicassign1/gcc_O2/basicassign1_gtirb.expected
src/test/incorrect/basicassign1/gcc_pic/basicassign1.expected
src/test/incorrect/basicassign1/gcc_pic/basicassign1_gtirb.expected
src/test/incorrect/basicassign2/clang/basicassign2.expected
src/test/incorrect/basicassign2/clang/basicassign2_gtirb.expected
src/test/incorrect/basicassign2/clang_O2/basicassign2.expected
src/test/incorrect/basicassign2/clang_O2/basicassign2_gtirb.expected
src/test/incorrect/basicassign2/clang_pic/basicassign2.expected
src/test/incorrect/basicassign2/clang_pic/basicassign2_gtirb.expected
src/test/incorrect/basicassign2/gcc/basicassign2.expected
src/test/incorrect/basicassign2/gcc/basicassign2_gtirb.expected
src/test/incorrect/basicassign2/gcc_O2/basicassign2.expected
src/test/incorrect/basicassign2/gcc_O2/basicassign2_gtirb.expected
src/test/incorrect/basicassign2/gcc_pic/basicassign2.expected
src/test/incorrect/basicassign2/gcc_pic/basicassign2_gtirb.expected
src/test/incorrect/basicassign3/clang/basicassign3.expected
src/test/incorrect/basicassign3/clang/basicassign3_gtirb.expected
src/test/incorrect/basicassign3/clang_O2/basicassign3.expected
src/test/incorrect/basicassign3/clang_O2/basicassign3_gtirb.expected
src/test/incorrect/basicassign3/clang_pic/basicassign3.expected
src/test/incorrect/basicassign3/clang_pic/basicassign3_gtirb.expected
src/test/incorrect/basicassign3/gcc/basicassign3.expected
src/test/incorrect/basicassign3/gcc/basicassign3_gtirb.expected
src/test/incorrect/basicassign3/gcc_O2/basicassign3.expected
src/test/incorrect/basicassign3/gcc_O2/basicassign3_gtirb.expected
src/test/incorrect/basicassign3/gcc_pic/basicassign3.expected
src/test/incorrect/basicassign3/gcc_pic/basicassign3_gtirb.expected
src/test/incorrect/iflocal/clang/iflocal.expected
src/test/incorrect/iflocal/clang/iflocal_gtirb.expected
src/test/incorrect/iflocal/gcc/iflocal.expected
src/test/incorrect/iflocal/gcc/iflocal_gtirb.expected
src/test/make/lift-directories.mk
src/test/procedure_summaries/procedure_summary3/gcc_O2/procedure_summary3.adt
src/test/procedure_summaries/procedure_summary3/gcc_O2/procedure_summary3.gts
src/test/procedure_summaries/procedure_summary3/gcc_O2/procedure_summary3.relf
src/test/readme.md
src/test/scala/IndirectCallTests.scala
src/test/scala/LiveVarsAnalysisTests.scala
katrinafyi added a commit that referenced this pull request Jul 17, 2025
this introduces the src/test/make/docker-helper.sh script which is
a (hopefully) developer-friendly method for lifting examples in a Docker
container provided by [pac-nix][].

to ensure reproducibility, this uses an x86_64-linux docker container
with cross-compiler provided by nix. for more details, also see
#288.

the usage is comprehensively documented in [nix-docker-build readme].
the general flow is:
1. activate the docker-helper.sh environment: `eval $(docker-helper.sh env)`.
   (you will need to re-run this if you close your terminal)
2. pull the docker image: `docker-helper.sh pull`
3. start the docker container: `docker-helper.sh start`
4. (optional) clean the directory you want to lift:
   `make SUBDIRS=extraspec_incorrect/malloc_memcpy_strlen_memset_free clean`
5. compile and lift the directory:
   `make SUBDIRS=extraspec_incorrect/malloc_memcpy_strlen_memset_free`
6. commit the results (eventually, we want to move the binaries into
   another repo. but until then, committing is fine.)

[pac-nix]: https://github.com/katrinafyi/pac-nix/
[nix-docker-build readme]: https://github.com/UQ-PAC/BASIL/blob/nix-docker-build/src/test/readme.md
katrinafyi added a commit that referenced this pull request Aug 4, 2025
this introduces the src/test/make/docker-helper.sh script which is
a (hopefully) developer-friendly method for lifting examples in a Docker
container provided by [pac-nix][].

to ensure reproducibility, this uses an x86_64-linux docker container
with cross-compiler provided by nix. for more details, see #288 which
the
docker-helper.sh is stolen from.

the usage is comprehensively documented in [readme].
the general flow is:
1. activate the docker-helper.sh environment: `eval $(docker-helper.sh
env)`.
   (you will need to re-run this if you close your terminal)
2. pull the docker image: `docker-helper.sh pull`
3. start the docker container: `docker-helper.sh start`
4. (optional) clean the directory you want to lift:
`make SUBDIRS=extraspec_incorrect/malloc_memcpy_strlen_memset_free
clean`
5. compile and lift the directory:
   `make SUBDIRS=extraspec_incorrect/malloc_memcpy_strlen_memset_free`
6. commit the results (eventually, we want to move the binaries into
an out-of-repo location. but until then, committing is probably fine.)

[pac-nix]: https://github.com/katrinafyi/pac-nix/
[readme]:
https://github.com/UQ-PAC/BASIL/blob/docker-helper/src/test/readme.md

this PR does not make any changes to the existing examples. it only
serves to make the Docker container available and accessible for people
who want to use it as a uniform lifting environment.

I do think that all examples should eventually be re-lifted using a
consistent method, but this will come later.
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.

4 participants